Future of SVG's Declarative Animation

F R A Hopgood, D A Duce, P R Hopgood

(frahopgood@gmail.com), daduce@brookes.ac.uk, phopgood@svg-editor.org.uk)

1. Introduction

W3C's Web/Animation document states:

The future for SVG declarative animation appears to be as follows:

The following paper looks at some of these statements from the perspective of somebody interested in SVG animation

The authors' particluar interests in SVG animation include:

2. SVG and SMIL

SVG declarative animation (SVG Animation) consists primarily of animating SVG content via changing path descriptions over time. That is our main interest. It is also possible to change the styling of SVG content via the modification of SVG element attributes (stroke, fill etc) or via equivalent CSS properties where they exist. It is thus possible to change the style of SVG content via a CSS stylesheet if the SVG author allows it to happen. For most of our SVG animations that is inappropriate.

Timing is important in animating SVG content and in SMIL multimedia content. The SYMM working group produced a reference model for scheduling and orchestrating media objects to be selected and rendered under a variety of timing and spatial constraints. It was primarily aimed at SMIL at a time when the duration of playing a video clip was unknown and it was not possible to predict which of two videos would complete first if played in parallel. Playing part of a video clip might have its start delayed while the video was being positioned etc. In consequence, only a small part of the model is required by SVG animation where timing is more precise. A subset of the SMIL timing attributes are sufficient and the time containers are unnecessary. SVG is a creation language for animated objects which are similar to individual SMIL media objects.

The origins of SMIL was the European Union Chameleon project with RAL and CWI as partners. The par and seq functionality was added to ensure that simple multimedia objects from, say, a reporter in the field could add archival footage to a news item consisting of one or two new video clips and a simple par and seq shorthand view of how they should be broadcast.

SMIL 2.0 [1] added styling to multimedia content via transition effects and SMIL Animation. Transition effects are similar to those used by PowerPoint. SMIL Animation was designed to allow the values of visual, aural and position attributes in a SMIL presentation to be changed. Examples are changing the sound level of an aural track, the background colour applied to a video clip or positioning a video clip depending on the presentation system in use. In SMIL, these were only intended for changing the style of a multimedia presentation. The author of SMIL 2.0 made it clear that SMIL was not an animation creation language like SVG but it could be used to display SVG animated content objects and could be used to adjust the timing and rendering properties of the SVG object as a whole while it is being displayed.

Why all the confusion between SMIL Animation and SVG Animation? Partly because the SVG Recommendation refers to the SMIL Recommendation. Also because the general timing control attributes (begin, dur and end), object persistance attribute (fill), repeating objects attributes (repeatCount and repeatDur) are common to both and some of SMIL's inline transition attributes (from, to, by, values, calcMode) are defined for both albeit for different purposes. The other major similarity is that neither use CSS. Both are defined in XML. SMIL 1.0 indicated that its basic layout could be transformed into equivalent CSS-2 notation, but it is a less concise notation than is convenient for multimedia specifications. Even so SMIL tried to make it possible to use either CSS properties or SMIL attributes when compatible as does SVG.

3. The Future of SVG Animation

Our view is that the SVG Working Group belief that SVG animation is inherently presentational is not correct. We do not believe that any of our SVG animations are presentational. SVG geometric content is specified in SVG primarily by the path descriptions as SVG attributes and animating these path descriptions is SVG animation. If area colour or line thickness, say, is part of the SVG content it will use SVG rendering attributes or CSS properties in such a way that they cannot be changed by a change in user stylesheet. Providing SVG animation facilities via CSS is inappropriate. Declarative XML-based content is the best way to define SVG animation and CSS rule-based styling is inappropriate for both SVG and SMIL content. The main part of almost any SVG animation is animating path descriptions as content.

One of the problems is the misuse of the word animation when the person is using it to mean styling transitions of media objects. Such transitions can be considered styling and could be defined in CSS. SMIL defined a timing model for the presentation of multimedia objects and the transitions between such objects. SVG uses parts of both models to define its timing control of SVG content. A step forward would be to separate the part of the model applicable to SVG content animation rather than continuing to try and merge the requirements of styling transitions, multimedia presentations and SVG content animation into a single model.

SVG animation is not as efficiently defined as it might be, especially for large animations. Below we consider what changes could be made to make SVG content animation more efficient. At the same time it might make it more feasible that timing could be controlled by CSS.

2. SVG Content Animation

2.1 A Simple Example

We will use a simple example from Preston Blair's Animation published in 1949 as an example of how to use SVG for content animation. It animates a figure walking forward over an 8-frame cycle.

To animate the figure, the eight path descriptions must be defined and an animate command to animate between the positions.

The SVG code looks something like:

<svg width="200" height="320" xmlns="http://www.w3.org/2000/svg">
<style type="text/css">
path {stroke-width:2;fill:none;stroke:forestgreen}
</style>
<path  d="M84,70l1,-10c-70,-77,80,-77,15,0l-1,10c41,5,76,30,78,60c10,15,-32,15,-22,0c0,-30,-38,-40,-48,-30c10,30,10,50,5,70c11,20,18,40,13,50c40,-40,5,80,-25,35c7,-30,0,-55,-3,-82c-7,3,-14,3,-21,0c-8,17,-2,27,16,49c-8,68,-67,28,-12,3c-30,-15,-30,-45,-24,-57c-1,-20,9,-40,19,-73c-40,20,-11,15,9,5c11,-20,22,10,3,20c-77,30,-77,10,-3,-50l0,0Z">
<animate attributeName="d" values=" 
M84,70l1,-10c-70,-77,80,-77,15,0l-1,10c41,5,76,30,78,60c10,15,-32,15,-22,0c0,-30,-38,-40,-48,-30c10,30,10,50,5,70c11,20,18,40,13,50c40,-40,5,80,-25,35c7,-30,0,-55,-3,-82c-7,3,-14,3,-21,0c-8,17,-2,27,16,49c-8,68,-67,28,-12,3c-30,-15,-30,-45,-24,-57c-1,-20,9,-40,19,-73c-40,20,-11,15,9,5c11,-20,22,10,3,20c-77,30,-77,10,-3,-50z;
M86,70l0,-10c-71,-64,79,-74,14,0l-1,10c11,5,46,30,64,70c10,25,-30,30,-25,15c17,-20,-27,-55,-29,-45c8,20,8,40,6,60c28,20,35,40,0,70c50,0,15,40,-26,10c26,-25,31,-50,8,-70c-7,-4,-14,-4,-21,0c-18,10,-12,20,14,20c-6,90,-45,50,-23,19c-37,-9,-27,-39,-1,-61c-6,-10,3,-30,11,-61c-42,28,-13,23,3,10c10,-17,30,8,0,23c-50,10,-70,-10,6,-60z;
M86,70l0,-14c-76,-60,74,-70,14,-2l-1,13c21,8,56,33,34,83c7,35,-53,20,-13,0c10,-15,0,-50,-20,-70c17,50,17,70,5,80c5,20,35,50,0,90c70,0,25,40,-15,5c15,-20,15,-55,10,-85c-10,6,-15,6,-25,0c-35,20,-25,30,-15,20c60,-40,-25,90,0,10c-55,10,-20,-20,5,-42c-5,-10,0,-30,10,-73c-25,10,-25,25,-23,40c18,-15,18,30,-7,20c-15,-15,-15,-75,41,-75z;
M87,68l0,-12c-73,-60,73,-70,18,-2l-1,11c51,40,51,40,13,79c-27,10,-37,-24,-9,-18c22,-17,22,-17,-2,-34c8,18,15,38,16,58c4,40,2,80,-7,118c50,-8,15,52,-25,-13c20,-20,20,-55,10,-85c-10,2,-15,2,-22,-5c-18,0,-8,25,-3,35c40,60,-90,-20,-10,-8c-40,-22,-25,-47,10,-42c-5,-10,0,-22,10,-55c-35,5,-35,15,-45,32c-10,28,-40,28,-22,-2c2,-15,37,-45,69,-57z;
M85,72l1,-12c-72,-64,74,-74,9,0l0,10c70,45,70,75,0,44c-15,20,-25,-44,0,-12c45,17,35,7,9,-12c10,20,17,40,2,78c20,2,-2,59,0,70c34,22,-6,42,-21,-3c0,-20,5,-40,11,-62c-6,3,-11,3,-16,2c10,10,-10,25,-12,70c27,75,-73,-25,-10,-5c-3,-20,-3,-40,7,-65c-5,-25,-5,-47,11,-91c-26,36,-46,26,-56,43c0,28,-30,-2,-15,-9c15,-8,50,-38,80,-46z;
M85,72l1,-12c-52,-64,84,-60,14,0l0,10c55,45,65,55,5,64c-30,10,-35,-54,0,-17c25,2,25,-8,-3,-22c8,15,13,35,4,73c24,17,29,37,-1,59c45,38,-20,63,-12,-22c22,-10,-8,-18,0,-32c-7,-1,-10,-1,-15,2c-13,20,-18,50,11,75c16,30,-94,40,-27,-5c-22,-15,-17,-55,5,-75c-5,-20,-5,-42,12,-76c-29,26,-49,16,-47,53c-7,18,-37,28,-17,-5c5,-28,40,-62,70,-70z;
M85,72l1,-12c-66,-64,74,-65,12,0l0,11c47,44,57,54,12,81c-18,2,-20,-22,-3,-15c23,-18,18,-28,-5,-40c6,13,11,33,2,66c31,22,41,47,4,44c67,51,-53,8,0,-12c14,7,17,-8,-10,-18c-12,-3,-15,-3,-20,0c-3,18,-8,48,8,73c19,30,-91,35,-18,5c-18,-25,-13,-65,-1,-85c-3,-20,-3,-42,12,-72c-19,22,-29,47,-17,57c8,20,-24,35,-12,0c-30,-11,15,-75,35,-83z;
M86,76l0,-14c-66,-66,74,-67,12,-2l0,14c42,16,72,56,66,68c2,30,-28,28,-16,-5c-18,-20,-23,-28,-43,-30c3,3,8,23,-5,56c35,-28,55,-13,12,35c88,-53,-32,82,-8,7c18,-45,-4,-18,-12,-17c-3,2,-6,2,-10,0c-7,7,-12,37,4,62c9,60,-91,30,-14,15c-24,-35,-19,-75,-12,-92c4,-23,4,-45,19,-75c-19,22,-29,47,-12,49c23,-22,23,38,0,10c-57,7,-22,-77,19,-81z;
M84,70l1,-10c-70,-77,80,-77,15,0l-1,10c41,5,76,30,78,60c10,15,-32,15,-22,0c0,-30,-38,-40,-48,-30c10,30,10,50,5,70c11,20,18,40,13,50c40,-40,5,80,-25,35c7,-30,0,-55,-3,-82c-7,3,-14,3,-21,0c-8,17,-2,27,16,49c-8,68,-67,28,-12,3c-30,-15,-30,-45,-24,-57c-1,-20,9,-40,19,-73c-40,20,-11,15,9,5c11,-20,22,10,3,20c-77,30,-77,10,-3,-50z"
begin="1s" dur="2s" fill="freeze" repeatCount="indefinite"/>
</path>
</svg>

Some things to notice:

Something like the following would handle the timing but CSS cannot currently handle the d values:

path {animation-delay: 1s; animation-duration: 2s; animation-iteration-count: infinite;animation-fill-mode: forwards}
path.d {0%:  ;  12.5%:  ;25%:  ;37.5%:  ;50%:  ; 62.5%:  ; 75%:  ; 87.5%:  ;100%:  }

Each path requires a style rule so we may be talking about 5000 style rules to be added for a short animation. Large companies may well have significantly larger requirements. Is CSS engineered to handle style sheets that large?

2.2 Indirect References to Path Descriptions

Irrespective of whether timing gets moved to CSS or stays with SVG, having an indirect reference to the d value has advantages. The CSS would be something like:

path.d {0%:#frame1; 12.5%:frame2;25%:#frame3;37.5%:#frame4;50%:#frame5;62.5%:#frame6;75%:#frame7;87.5%:#frame8;100%:#frame1}

Currently, CSS accesses URL's with something like url(#frame2). A shorter notation would be appropriate as would shorter names of the other CSS properties.

A change to SVG animation that would be of value to both CSS and SVG would be the way access is made to d values. Consider the following:

<svg xmlns:xlink="http://www.w3.org/1999/xlink" width="900" height="400" xmlns="http://www.w3.org/2000/svg">
<path id="frame1" style="stroke:forestgreen;fill:none" d="M84,70l1,-10c-70,-77,80,-77,15,0l-1,10c41,5,76,30,78,60c10,15,-32,15,-22,0c0,-30,-38,-40,-48,-30c10,30,10,50,5,70c11,20,18,40,13,50c40,-40,5,80,-25,35c7,-30,0,-55,-3,-82c-7,3,-14,3,-21,0c-8,17,-2,27,16,49c-8,68,-67,28,-12,3c-30,-15,-30,-45,-24,-57c-1,-20,9,-40,19,-73c-40,20,-11,15,9,5c11,-20,22,10,3,20c-77,30,-77,10,-3,-50l0,0Z"/>
<defs>
<path id="frame2" d="M86,70l0,-10c-71,-64,79,-74,14,0l-1,10c11,5,46,30,64,70c10,25,-30,30,-25,15c17,-20,-27,-55,-29,-45c8,20,8,40,6,60c28,20,35,40,0,70c50,0,15,40,-26,10c26,-25,31,-50,8,-70c-7,-4,-14,-4,-21,0c-18,10,-12,20,14,20c-6,90,-45,50,-23,19c-37,-9,-27,-39,-1,-61c-6,-10,3,-30,11,-61c-42,28,-13,23,3,10c10,-17,30,8,0,23c-50,10,-70,-10,6,-60z"/>
<path id="frame3" d="M86,70l0,-14c-76,-60,74,-70,14,-2l-1,13c21,8,56,33,34,83c7,35,-53,20,-13,0c10,-15,0,-50,-20,-70c17,50,17,70,5,80c5,20,35,50,0,90c70,0,25,40,-15,5c15,-20,15,-55,10,-85c-10,6,-15,6,-25,0c-35,20,-25,30,-15,20c60,-40,-25,90,0,10c-55,10,-20,-20,5,-42c-5,-10,0,-30,10,-73c-25,10,-25,25,-23,40c18,-15,18,30,-7,20c-15,-15,-15,-75,41,-75z"/>
<path id="frame4" d="M87,68l0,-12c-73,-60,73,-70,18,-2l-1,11c51,40,51,40,13,79c-27,10,-37,-24,-9,-18c22,-17,22,-17,-2,-34c8,18,15,38,16,58c4,40,2,80,-7,118c50,-8,15,52,-25,-13c20,-20,20,-55,10,-85c-10,2,-15,2,-22,-5c-18,0,-8,25,-3,35c40,60,-90,-20,-10,-8c-40,-22,-25,-47,10,-42c-5,-10,0,-22,10,-55c-35,5,-35,15,-45,32c-10,28,-40,28,-22,-2c2,-15,37,-45,69,-57z"/>
<path id="frame5" d="M85,72l1,-12c-72,-64,74,-74,9,0l0,10c70,45,70,75,0,44c-15,20,-25,-44,0,-12c45,17,35,7,9,-12c10,20,17,40,2,78c20,2,-2,59,0,70c34,22,-6,42,-21,-3c0,-20,5,-40,11,-62c-6,3,-11,3,-16,2c10,10,-10,25,-12,70c27,75,-73,-25,-10,-5c-3,-20,-3,-40,7,-65c-5,-25,-5,-47,11,-91c-26,36,-46,26,-56,43c0,28,-30,-2,-15,-9c15,-8,50,-38,80,-46z"/>
<path id="frame6" d="M85,72l1,-12c-52,-64,84,-60,14,0l0,10c55,45,65,55,5,64c-30,10,-35,-54,0,-17c25,2,25,-8,-3,-22c8,15,13,35,4,73c24,17,29,37,-1,59c45,38,-20,63,-12,-22c22,-10,-8,-18,0,-32c-7,-1,-10,-1,-15,2c-13,20,-18,50,11,75c16,30,-94,40,-27,-5c-22,-15,-17,-55,5,-75c-5,-20,-5,-42,12,-76c-29,26,-49,16,-47,53c-7,18,-37,28,-17,-5c5,-28,40,-62,70,-70z"/>
<path id="frame7" d="M85,72l1,-12c-66,-64,74,-65,12,0l0,11c47,44,57,54,12,81c-18,2,-20,-22,-3,-15c23,-18,18,-28,-5,-40c6,13,11,33,2,66c31,22,41,47,4,44c67,51,-53,8,0,-12c14,7,17,-8,-10,-18c-12,-3,-15,-3,-20,0c-3,18,-8,48,8,73c19,30,-91,35,-18,5c-18,-25,-13,-65,-1,-85c-3,-20,-3,-42,12,-72c-19,22,-29,47,-17,57c8,20,-24,35,-12,0c-30,-11,15,-75,35,-83z"/>
<path id="frame8" d="M86,76l0,-14c-66,-66,74,-67,12,-2l0,14c42,16,72,56,66,68c2,30,-28,28,-16,-5c-18,-20,-23,-28,-43,-30c3,3,8,23,-5,56c35,-28,55,-13,12,35c88,-53,-32,82,-8,7c18,-45,-4,-18,-12,-17c-3,2,-6,2,-10,0c-7,7,-12,37,4,62c9,60,-91,30,-14,15c-24,-35,-19,-75,-12,-92c4,-23,4,-45,19,-75c-19,22,-29,47,-12,49c23,-22,23,38,0,10c-57,7,-22,-77,19,-81z"/>
</defs>
<animate xlink:href="#frame1" attributeName="d" values="#frame1;#frame2;#frame3;#frame4;#frame5;#frame6;#frame7;#frame8;#frame1" begin="1s" dur="2s" fill="freeze" repeatCount="indefinite"/>
or
<animate xlink:href="#frame1" attributeName="d" to="#frame2;#frame3;#frame4;#frame5;#frame6;#frame7;#frame8;#frame1" begin="1s" dur="2s" fill="freeze" repeatCount="indefinite"/>
</svg>

If the animate command had the ability to access a d value by specifying the id of the associated path, the SVG code becomes cleaner in that a user would only defined d values in path elements and the animate commands become easier to read. From the CSS perspective, the styling rule for a path would be appropriate for any 8-frame cycle. Furthermore, while debugging other parts of the animation, the CSS style rule could be changed to something like:

path.d {0%:#frame1; 33%:#frame4;66%:#frame8;100%:#frame1}

The suggested modification to the animate command would not be that difficult to implement while retaining the current alternatives.

It might be approprriate not to reuse the current path element but instead introduce a new element, say <gpath> (geometric path definition).

2.3 Indirection for Animate Attributes

In SVG, path elements can only have a single fill attribute or property. In consequence most objects making up an animated scene contain multiple paths. For example, a trivial extension to the example above would be to define the man by:

The animated figure now is:

The SVG code looks something like:

<svg xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="320" xmlns="http://www.w3.org/2000/svg">
<style type="text/css">
path.head {fill:navajowhite;stroke:none}
path.body {fill:green;stroke:none}
path.legs {fill:blue;stroke:none}
</style>
<g id="frame1">
<path class="head" id="head1" d="M84,70l1,-10c-70,-77,80,-77,15,0l-1,10l-15,0Z"/>
<path class="body" id="body1" d="M99,70c41,5,76,30,78,60c10,15,-32,15,-22,0c0,-30,-38,-40,-48,-30c10,30,10,50,5,70l-56,-2c-1,-20,9,-40,19,-73c-40,20,-11,15,9,5c11,-20,22,10,3,20c-77,30,-77,10,-3,-50Z"/>
<path class="legs" id="legs1" d="M112,170c11,20,18,40,13,50c40,-40,5,80,-25,35c7,-30,0,-55,-3,-82c-7,3,-14,3,-21,0c-8,17,-2,27,16,49c-8,68,-67,28,-12,3c-30,-15,-30,-45,-24,-57l56,2Z"/>
</g>
<animate xlink:href="#head1" attributeName="d" values="M84,70l1,-10c-70,-77,80,-77,15,0l-1,10l-15,0Z;M86,70l0,-10c-71,-64,79,-74,14,0l-1,10l-13,0Z;M86,70l0,-14c-76,-60,74,-70,14,-2l-1,13l-13,3Z;M87,68l0,-12c-73,-60,73,-70,18,-2l-1,11l-17,3Z;M85,72l1,-12c-72,-64,74,-74,9,0l0,10l-10,2Z;M85,72l1,-12c-52,-64,84,-60,14,0l0,10l-15,2Z;M85,72l1,-12c-66,-64,74,-65,12,0l0,11l-13,1Z;M86,76l0,-14c-66,-66,74,-67,12,-2l0,14l-12,2Z;M84,70l1,-10c-70,-77,80,-77,15,0l-1,10l-15,0Z" 
begin="1s" dur="2s" fill="freeze" repeatCount="indefinite"/>
<animate xlink:href="#body1" attributeName="d" values="M99,70c41,5,76,30,78,60c10,15,-32,15,-22,0c0,-30,-38,-40,-48,-30c10,30,10,50,5,70l-56,-2c-1,-20,9,-40,19,-73c-40,20,-11,15,9,5c11,-20,22,10,3,20c-77,30,-77,10,-3,-50Z;M99,70c11,5,46,30,64,70c10,25,-30,30,-25,15c17,-20,-27,-55,-29,-45c8,20,8,40,6,60l-49,-12c-6,-10,3,-30,11,-61c-42,28,-13,23,3,10c10,-17,30,8,0,23c-50,10,-70,-10,6,-60z;M99,67c21,8,56,33,34,83c7,35,-53,20,-13,0c10,-15,0,-50,-20,-70c17,50,17,70,5,80l-40,-2c-5,-10,0,-30,10,-73c-25,10,-25,25,-23,40c18,-15,18,30,-7,20c-15,-15,-15,-75,41,-75z;M104,65c51,40,51,40,13,79c-27,10,-37,-24,-9,-18c22,-17,22,-17,-2,-34c8,18,15,38,16,58l-47,0c-5,-10,0,-22,10,-55c-35,5,-35,15,-45,32c-10,28,-40,28,-22,-2c2,-15,37,-45,69,-57z;M95,70c70,45,70,75,0,44c-15,20,-25,-44,0,-12c45,17,35,7,9,-12c10,20,17,40,2,78l-41,7c-5,-25,-5,-47,11,-91c-26,36,-46,26,-56,43c0,28,-30,-2,-15,-9c15,-8,50,-38,80,-46z;M100,70c55,45,65,55,5,64c-30,10,-35,-54,0,-17c25,2,25,-8,-3,-22c8,15,13,35,4,73l-39,2c-5,-20,-5,-42,12,-76c-29,26,-49,16,-47,53c-7,18,-37,28,-17,-5c5,-28,40,-62,70,-70z;M98,71c47,44,57,54,12,81c-18,2,-20,-22,-3,-15c23,-18,18,-28,-5,-40c6,13,11,33,2,66l-37,7c-3,-20,-3,-42,12,-72c-19,22,-29,47,-17,57c8,20,-24,35,-12,0c-30,-11,15,-75,35,-83z;M98,74c42,16,72,56,66,68c2,30,-28,28,-16,-5c-18,-20,-23,-28,-43,-30c3,3,8,23,-5,56l-40,10c4,-23,4,-45,19,-75c-19,22,-29,47,-12,49c23,-22,23,38,0,10c-57,7,-22,-77,19,-81z;M99,70c41,5,76,30,78,60c10,15,-32,15,-22,0c0,-30,-38,-40,-48,-30c10,30,10,50,5,70l-56,-2c-1,-20,9,-40,19,-73c-40,20,-11,15,9,5c11,-20,22,10,3,20c-77,30,-77,10,-3,-50Z" 
begin="1s" dur="2s" fill="freeze" repeatCount="indefinite"/>
<animate xlink:href="#legs1" attributeName="d" values="M112,170c11,20,18,40,13,50c40,-40,5,80,-25,35c7,-30,0,-55,-3,-82c-7,3,-14,3,-21,0c-8,17,-2,27,16,49c-8,68,-67,28,-12,3c-30,-15,-30,-45,-24,-57l56,2Z;M115,170c28,20,35,40,0,70c50,0,15,40,-26,10c26,-25,31,-50,8,-70c-7,-4,-14,-4,-21,0c-18,10,-12,20,14,20c-6,90,-45,50,-23,19c-37,-9,-27,-39,-1,-61l49,12Z;M105,160c5,20,35,50,0,90c70,0,25,40,-15,5c15,-20,15,-55,10,-85c-10,6,-15,6,-25,0c-35,20,-25,30,-15,20c60,-40,-25,90,0,10c-55,10,-20,-20,5,-42l40,2Z;M122,150c4,40,2,80,-7,118c50,-8,15,52,-25,-13c20,-20,20,-55,10,-85c-10,2,-15,2,-22,-5c-18,0,-8,25,-3,35c40,60,-90,-20,-10,-8c-40,-22,-25,-47,10,-42l47,0Z;M106,168c20,2,-2,59,0,70c34,22,-6,42,-21,-3c0,-20,5,-40,11,-62c-6,3,-11,3,-16,2c10,10,-10,25,-12,70c27,75,-73,-25,-10,-5c-3,-20,-3,-40,7,-65l41,-7Z;M106,168c24,17,29,37,-1,59c45,38,-20,63,-12,-22c22,-10,-8,-18,0,-32c-7,-1,-10,-1,-15,2c-13,20,-18,50,11,75c16,30,-94,40,-27,-5c-22,-15,-17,-55,5,-75l39,-2Z;M104,163c31,22,41,47,4,44c67,51,-53,8,0,-12c14,7,17,-8,-10,-18c-12,-3,-15,-3,-20,0c-3,18,-8,48,8,73c19,30,-91,35,-18,5c-18,-25,-13,-65,-1,-85l37,-7Z;M100,163c35,-28,55,-13,12,35c88,-53,-32,82,-8,7c18,-45,-4,-18,-12,-17c-3,2,-6,2,-10,0c-7,7,-12,37,4,62c9,60,-91,30,-14,15c-24,-35,-19,-75,-12,-92l40,-10Z;M112,170c11,20,18,40,13,50c40,-40,5,80,-25,35c7,-30,0,-55,-3,-82c-7,3,-14,3,-21,0c-8,17,-2,27,16,49c-8,68,-67,28,-12,3c-30,-15,-30,-45,-24,-57l56,2Z" 
begin="1s" dur="2s" fill="freeze" repeatCount="indefinite"/>
</svg>

In a realistic example, each hand, arm, leg, foot and facial features would most likely be different leading to a set of animate elements all with the same start time and same duration. Making changes to such an animation is prone to error and the problem with the start times can be eased by:

<animate xlink:href="#head1" attributeName="d" values="M84,70l1 ..."
id="first" begin="1s" dur="2s" fill="freeze" repeatCount="indefinite"/>
<animate xlink:href="#body1" attributeName="d" values="M99,70 ..."
begin="first.begin" dur="2s" fill="freeze" repeatCount="indefinite"/>
<animate xlink:href="#legs1" attributeName="d" values="M112,170..."
begin="first.begin" dur="2s" fill="freeze" repeatCount="indefinite"/>

A simple but helpful extension to SVG content animation would be:

<animate xlink:href="#head1" attributeName="d" values="M84,70l1 ..."
id="first" begin="1s" dur="2s" fill="freeze" repeatCount="indefinite"/>
<animate xlink:href="#body1" attributeName="d" values="M99,70 ..."
begin="first.begin" dur="first.dur" fill="freeze" repeatCount="indefinite"/>
<animate xlink:href="#legs1" attributeName="d" values="M112,170..."
begin="first.begin" dur="first.dur" fill="freeze" repeatCount="indefinite"/>

This does not make any major extension to the animate element as the ability to reference the begin attribute from another animate element already gives the syntax of how it would be achieved. To ensure other characteristics stay in step over a set of animate commands, the technique is appropriate for all the other attributes as well.

2.4 Applying the Same Animation to a Sequence of Paths

Below is a simple but more realistic example of SVG animation that we completed recently for the WWW Conference in Florence in May 2015. The full animation runs for about 6 minutes and the example below is a simple zoom and pan from one frame to the next that lasts for 9 seconds.

The start frame shows the Town Hall of Florence.

It started life as about 1500 paths which none of the browsers could animate smoothly. In consequence, optimisation of the original scene was needed to make it possible for the animation to proceed. After many transformations it was possible to reduce the number of paths to 707.

The requirement was to move to a zoomed in side view of the complete scene.

The 707 path descriptions also appear in the second scene and each path description has to have the same structure.

The complete scene full size is shown below. Hit the arrow at the bottom to see the SVG animation take place.

Here are 3 example paths out of the 707 used (three of the crest just below the bell tower), and their associated animate elements:

<path id="w24strt6a_1p32" class="w24crestg" d="M-260.1,799.2l0.6,17.1l-2.1,1.8l-0.6,-17.2l2.1,-1.7ZM-260.5,800.8l-1.3,1l0.2,5.7c0.2,3.5,0.7,5.9,0.9,6.5c0.2,-0.9,0.5,-4.1,0.4,-7.6l-0.2,-5.6Z"/>
<path id="w24strt6a_1p33" class="w24crestw" d="M-260.1,797.5l-2.2,1.8c-0.4,-9.9,1.8,-11.7,2.2,-1.8ZM-260.1,798.6l-2.2,1.8l0.6,18.4l2.3,-2l-0.7,-18.2ZM-260.1,799.2l0.6,17.1l-2.1,1.8l-0.6,-17.2l2.1,-1.7ZM-260,807.4c0.1,2.8,-0.3,7.5,-0.6,8.6c-0.4,-0.4,-1.1,-4.2,-1.2,-7l0.3,8.5l1.8,-1.7l-0.3,-8.4"/>
<path id="w24strt6a_1p34" class="w24crestb" d="M-260.2,797.6l-2.1,1.6c-0.3,-9.1,1.8,-10.7,2.1,-1.6ZM-259.8,814.7l0,-0.8l-0.1,0.1l0,0.9l0,0.7l0.1,-0.1l0,-0.8ZM-260,813.2l0,-0.7l-0.1,0l0,0.9l0,0.7l0.1,-0.1l0,-0.8ZM-261.3,816.1l-0.1,-0.8l-0.1,0.1l0,0.8l0.1,0.8l0.1,-0.1l0,-0.8ZM-261.2,814.3l-0.1,-0.7l-0.1,0.1l0,0.8l0.1,0.7l0,0l0.1,-0.9Z"/>

<animate attributeName="d"
values="M-260.1,799.2l0.6,17.1l-2.1,1.8l-0.6,-17.2l2.1,-1.7ZM-260.5,800.8l-1.3,1l0.2,5.7c0.2,3.5,0.7,5.9,0.9,6.5c0.2,-0.9,0.5,-4.1,0.4,-7.6l-0.2,-5.6Z;M-302.6,-1122l-0.4,63.3l12.3,1.7l0.5,-63.8l-12.4,-1.2ZM-300.3,-1117.1l7.7,0.8l-0.1,20.9c-0.1,13,-3,23.1,-4.1,25.6c-1.1,-2.7,-3.7,-13.5,-3.6,-26.5l0.1,-20.8Z"
fill="freeze"
begin="w24strt05.end"
dur="9s"
xlink:href="#w24strt6_1p32"
keySplines="0.75 0 0.25 1"
calcMode="spline"/>
<animate attributeName="d"
values="M-260.1,797.5l-2.2,1.8c-0.4,-9.9,1.8,-11.7,2.2,-1.8ZM-260.1,798.6l-2.2,1.8l0.6,18.4l2.3,-2l-0.7,-18.2ZM-260.1,799.2l0.6,17.1l-2.1,1.8l-0.6,-17.2l2.1,-1.7ZM-260,807.4c0.1,2.8,-0.3,7.5,-0.6,8.6c-0.4,-0.4,-1.1,-4.2,-1.2,-7l0.3,8.5l1.8,-1.7l-0.3,-8.4;M-303,-1128l13.3,1.2c0.3,-36.7,-13,-37.6,-13.3,-1.2ZM-303,-1124.1l13.3,1.2l-0.5,68l-13.3,-1.7l0.5,-67.5ZM-302.6,-1122l-0.4,63.3l12.3,1.7l0.5,-63.8l-12.4,-1.2ZM-302.1,-1091.8c-0.1,10.4,3.1,26.4,5.3,29.3c2.2,-2.3,5.6,-17.6,5.7,-28l-0.2,31.3l-11,-1.4l0.2,-31.2"
fill="freeze"
begin="w24strt05.end"
dur="9s"
xlink:href="#w24strt6_1p33"
keySplines="0.75 0 0.25 1"
calcMode="spline"/>
<animate attributeName="d"
values="M-260.2,797.6l-2.1,1.6c-0.3,-9.1,1.8,-10.7,2.1,-1.6ZM-259.8,814.7l0,-0.8l-0.1,0.1l0,0.9l0,0.7l0.1,-0.1l0,-0.8ZM-260,813.2l0,-0.7l-0.1,0l0,0.9l0,0.7l0.1,-0.1l0,-0.8ZM-261.3,816.1l-0.1,-0.8l-0.1,0.1l0,0.8l0.1,0.8l0.1,-0.1l0,-0.8ZM-261.2,814.3l-0.1,-0.7l-0.1,0.1l0,0.8l0.1,0.7l0,0l0.1,-0.9Z;M-302.5,-1127.9l12.4,1.1c0.2,-33.6,-12.2,-34.4,-12.4,-1.1ZM-302,-1065l0.3,-2.9l0.5,0.1l0.3,2.9l-0.3,2.9l-0.6,-0.1l-0.2,-2.9ZM-301.2,-1070.9l0.3,-2.8l0.6,0l0.2,3l-0.3,2.8l-0.5,0l-0.3,-3ZM-292.7,-1063.8l0.3,-2.9l0.6,0.1l0.2,2.9l-0.3,2.9l-0.5,-0.1l-0.3,-2.9ZM-293.5,-1069.9l0.3,-2.9l0.6,0.1l0.3,2.9l-0.3,2.9l-0.6,-0.1l-0.3,-2.9Z"
fill="freeze"
begin="w24strt05.end"
dur="9s"
xlink:href="#w24strt6_1p34"
keySplines="0.75 0 0.25 1"
calcMode="spline"/>

The low-level nature of the SVG code means that the complete scene is about 2Mbytes of SVG, half of which is animate commands. The nature of the animate commands is that they are all identical apart from the path they refer to and the d values.

The overall structure, if we made the changes proposed already, would look like:

<g id="scene1a">
<path id="path001a" d="M..."/>
....
<path id="path703a" d="M..."/>
</g>
<defs>
<g id="scene1b">
<path id="path001b" d="M..."/>
....
<path id="path703b" d="M..."/>
</g>
</defs>
<animate attributeName="d" values="#path001a;#path001b" fill="freeze" begin="strt.end" dur="9s" xlink:href="#path001a" keySplines="0.75 0 0.25 1" calcMode="spline"/>
...
<animate attributeName="d" values="#path703a;#path703b" fill="freeze" begin="strt.end" dur="9s" xlink:href="#path001a" keySplines="0.75 0 0.25 1" calcMode="spline"/>

Most animations of any size will have this kind of structure. Rather than use the link to specify the individual path, it would be possible to reference the enclosing g element. The same provisos could be placed on the g element. The from and to structures must be the same. In this case the 707 animate elements could be reduced to a single element:

<animate xlink:href="#scene1a" to="#scene1b" dur="5s" fill="freeze" begin="strt.end" dur="9s" xlink:href="#path001a" keySplines="0.75 0 0.25 1" calcMode="spline"/>

If the href is to a g element the assumption is that it contains a sequence of path elements. The to attribute also points to a g element and gives the final position. The advantages are that the code is considerably shorter (703 animate lines become 1) and it gives the browser prior knowledge of what is to be animated and only has to decode 1 element rather than 707. If using a link to a g element is unacceptable, the same effect could be achieved by pointing at a defs element with an id attribute.

3. Retaining SVG Content Animation in SVG 2

The current situation appears to be that the browsers want to have animation support for styling in CSS. This is because they want the animated control of multimedia and transitions there as well and only wish to define it in one place.

Having SVG content animation in CSS is not sensible for many reasons and, as shown above, it would introduce significant changes to the values used by CSS if it had to include path descriptions.

The main vehicle for content animation in SVG is animating the d attribute. This can only be done at the moment by using the SVG d attribute.

Content animation in SVG currently also animates SVG presentation attributes and CSS properties.

Almost all SVG content animations could be achieved by just animating SVG presentation attributes.

Therefore, a solution would be to remove the attributeType attribute from SVG animate commands. Only SVG attributes can be animated.

At the same time simplify the timing model to remove features that are only used by transitions and supporting SMIL multimedia.

This would leave a much simpler specification of animating SVG content via the SVG attributes.

CSS could then look at an SVG animation object in much the same way as it looks at a SMIL video object. If CSS wants to apply transitions on it fine. If it wants to make changes to the overall positioning of the SVG content in a multimedia presentation that would also be possible. Web Animations would then be a specification for CSS multimedia facilities.

Existing SVG content animations are probably a mixture of ones that use attributeType="CSS" and ones that don't. For any significant animation, it is unlikley that it will be generated completely by hand. In consequence changes required by the animation author may be significant but a tool that made the necessary changes would not be difficult to create.

A quick and not very thorough markup of the new Chapeter 19 in SVG 1.1 is attached as an Appendix. It gives some idea of what it might look like.

4. Summary

In summary we propose these changes to SVG content animation:

This might ease the load on the browsers somewhat and allow them to reconsider the decision to move SVG animation content to CSS.

References

(1) Bultermann, Dick C.A., Rutledge, Lloyd. SMIL 2.0 (ISBN 3-540-20234-X), Springer 2004.

Appendix: A Rough Draft of a Revised Definition of SVG Animation Excluding Property Animation

19 Animation

Contents