<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.inkscape.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=ToF</id>
	<title>Inkscape Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.inkscape.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=ToF"/>
	<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/Special:Contributions/ToF"/>
	<updated>2026-05-03T23:31:39Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.36.1</generator>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation&amp;diff=28374</id>
		<title>SVG Animation</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation&amp;diff=28374"/>
		<updated>2008-04-29T17:10:43Z</updated>

		<summary type="html">&lt;p&gt;ToF: /* Various thoughts */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is a '''work in progress'''. [[User:ToF|ToF]]&lt;br /&gt;
&lt;br /&gt;
See also the [[SVG_Animation_UI|UI ideas page]] (specific to SMIL animation).&lt;br /&gt;
&lt;br /&gt;
== SVG Animation ==&lt;br /&gt;
&lt;br /&gt;
Animation in SVG is defined in the Animation Module of the [http://www.w3.org/TR/SVG11/animate.html SVG specification]. Animation in SVG conforms to the [http://www.w3.org/TR/2001/REC-smil-animation-20010904/ SMIL specification] (Synchronized Multimedia Integration Language) and extends it (SVG is said to be a ''host'' language of SMIL).&lt;br /&gt;
&lt;br /&gt;
Here I only focus on procedural animation as defined by SMIL and not free-form scripted animation (using e.g. Javascript to manipulate the DOM). &lt;br /&gt;
&lt;br /&gt;
In SMIL an animation is an object which defines the evolution of a given attribute of a given object (here an SVG element - path, rect, group...) over time. Multiple animations can control the evolution of particular attribute: for example, one will tell the object to turn for 1 second starting at t=0 second and another to move across the document for 2 seconds starting at a later time. So we have this relation:&lt;br /&gt;
             1:n&lt;br /&gt;
  Element &amp;lt;-------&amp;gt; Animation&lt;br /&gt;
&lt;br /&gt;
For a given animation the element which is controlled is called the '''target''' element of the animation. The specific attribute/property which is controlled is called the '''target''' attribute/property.&lt;br /&gt;
&lt;br /&gt;
In fact, it's completely legal to have two animations that control the same attribute of the same element, and they can overlap in time: at any particular time there exists a ''stack'' of animations applying to a particular attribute, and SMIL defines the order in which each animation is applied.&lt;br /&gt;
&lt;br /&gt;
== Animation elements ==&lt;br /&gt;
&lt;br /&gt;
SVG defines 5 animation elements:&lt;br /&gt;
* '''animate'''&lt;br /&gt;
This element is used to animate any scalar attribute or property, such as the &amp;lt;code&amp;gt;width&amp;lt;/code&amp;gt; attribute of an svg:rect element or the CCS property &amp;lt;code&amp;gt;opacity&amp;lt;/code&amp;gt;&lt;br /&gt;
* '''animateMotion'''&lt;br /&gt;
This elements only controls the position of a SVG element, by telling it to follow a given path&lt;br /&gt;
* '''animateColor'''&lt;br /&gt;
This element controls the animation of color valued attributes and properties.&lt;br /&gt;
* '''animateTransform'''&lt;br /&gt;
This element controls the transformation which applies to the target element. It replaces or adds up to the &amp;lt;code&amp;gt;transform&amp;lt;/code&amp;gt; attribute of the element.&lt;br /&gt;
* '''set'''&lt;br /&gt;
This element is used to set a particular value for the target attribute during a specified time interval. It is mainly used for animating attributes which do not span a continuous domain, such as boolean values like the &amp;lt;code&amp;gt;visibility&amp;lt;/code&amp;gt; property.&lt;br /&gt;
&lt;br /&gt;
== Specifying the target element and property ==&lt;br /&gt;
&lt;br /&gt;
There are 2 ways to tell which element a given animation will target. The first one is to embed the [[#Animation elements|animation element]] as a child tag of the element to animate. Here is an example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;circle cx=&amp;quot;100px&amp;quot; cy=&amp;quot;100px&amp;quot; r=&amp;quot;20px&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;animate attributeName=&amp;quot;r&amp;quot; attributeType=&amp;quot;XML&amp;quot; begin=&amp;quot;1s&amp;quot; dur=&amp;quot;2s&amp;quot; from=&amp;quot;20px&amp;quot; to=&amp;quot;50px&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/circle&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;animate&amp;lt;/code&amp;gt; element targets the radius (&amp;lt;code&amp;gt;r&amp;lt;/code&amp;gt;) property of the parent &amp;lt;code&amp;gt;circle&amp;lt;/code&amp;gt; element. Starting 1 second after the document start, the radius will grow for 2 seconds from 20 pixels to 50 pixels. When nothing else is specified, the animation only applies in its interval of time, here [1-3] seconds; from 0 to 1 second and then from 3 second and after, the circle's radius is set back to its ''static'' attribute value, here 20 pixels.&lt;br /&gt;
&lt;br /&gt;
The other way to specify the target element is to reference it in via an &amp;lt;code&amp;gt;xlink:href&amp;lt;/code&amp;gt; attribute of the animation element. the previous animation could be written this way:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;circle id=&amp;quot;balloon&amp;quot; cx=&amp;quot;100px&amp;quot; cy=&amp;quot;100px&amp;quot; r=&amp;quot;20px&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;animate xlink:href=&amp;quot;#balloon&amp;quot; attributeName=&amp;quot;r&amp;quot; attributeType=&amp;quot;XML&amp;quot; begin=&amp;quot;1s&amp;quot; dur=&amp;quot;2s&amp;quot; from=&amp;quot;20px&amp;quot; to=&amp;quot;50px&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To specify which property or attribute of the target element is controlled, we use the two attributes &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;attributeType&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; explains itself, it's the name of the controlled attribute. &amp;lt;code&amp;gt;attributeType&amp;lt;/code&amp;gt; tells whether &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; is searched among the SVG attributes of the element (&amp;lt;code&amp;gt;attributeType=&amp;quot;XML&amp;quot;&amp;lt;/code&amp;gt;) or among the CSS properties of the element (&amp;lt;code&amp;gt;attributeType=&amp;quot;CSS&amp;quot;&amp;lt;/code&amp;gt;). [http://www.w3.org/TR/SVG11/animate.html#TargetElement (SPEC)]&lt;br /&gt;
&lt;br /&gt;
== Timing an animation ==&lt;br /&gt;
&lt;br /&gt;
The first thing to stress is that SMIL (and therefore SVG) animation is '''time-based''', as opposed to '''frame-based'''. '''Frame-based''' animation is something traditional animators are used to, because they actually draw each image of the animation on a separate celluloid sheet, and the timing is related to the rate of images per second the camera will capture. When animation is done on a computer, the animator doesn't draw every image but only some ''key'' images (or ''keyframes'') and then the animation software creates all the necessary images for him (the so-called ''in-betweens''). That means the animator can focus back to a (real-)time based timing. Each keyframe is positioned on a timeline with real time values (instead of frame numbers). Of course at the end the animation is discrete and there is a fixed number of images computed inbetween two keyframes, but the neat property of specifying keyframes at time position is that the final animation frame rate is scalable and the animator doesn't have to care about it anymore. He just tells the software to produce 24 images each second if he targets a theatre film or say 10 images per second for low-bandwidth web animation. The animator doesn't need to reposition the keyframes.&lt;br /&gt;
&lt;br /&gt;
=== In-betweening by interpolation ===&lt;br /&gt;
&lt;br /&gt;
Creating the inbetween images on a computer is done by mean of '''interpolation'''. Interpolation is a mathematical tool that can reconstruct a the continuous evolution of a parameter given a set of discrete values of this parameter over time.&lt;br /&gt;
The following image illustrates that. We know that some attribute A must take value A0, A1, A2 and A3 at times t0, t1, t2 and t3. The red curves is one of the possible continuous function that be used to compute inbetween values of A in the interval [t0, t3].&lt;br /&gt;
&lt;br /&gt;
[[Image:interpolation.png]]&lt;br /&gt;
&lt;br /&gt;
* The animation's time interval&lt;br /&gt;
The first aspect that characterizes an animation is the interval of time on which it applies: when does it begin, when does it end or how long does it run.&lt;br /&gt;
Any of the above mentioned [[#Animation elements|animation elements] accept the attributes &amp;lt;code&amp;gt;begin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;dur&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
There are many ways to define a particular point in time and this is what makes SMIL a very rich animation framework (see below). The simplest is to specify a clock-value which syntax is quite intuitive [http://www.w3.org/TR/SVG11/animate.html#ClockValueSyntax (SPEC)]. Depending on the combination of those 3 attributes, the interval of time of the animation will be [begin, end], [begin, begin+dur], [end-dur, end], etc.&lt;br /&gt;
&lt;br /&gt;
* The attribute values&lt;br /&gt;
To specify the values taken by the attribute over the time interval, one need to tell the value that the parameter must have at the begin and at the end of the interval. here again those values are specified by combinations of three attributes: &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;by&amp;lt;/code&amp;gt;. The attribute &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt; correspond to the begin value, the attribute &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; correspond to the end value. The attribute &amp;lt;code&amp;gt;by&amp;lt;/code&amp;gt; let you define either the initial and final values relative to the other one, that is to = from + by or from = to - by. The following image illusttrate this setup for our hypothetical attribute A&lt;br /&gt;
&lt;br /&gt;
[[Image:time_interval.png]]&lt;br /&gt;
&lt;br /&gt;
The values of A are simply interpolated '''linearly''' in between begin and end. This is the more simple form of '''animation function''' that can defined: by the two extremal pairs of (time, attribute value): (begin, from) and (end, to).&lt;br /&gt;
&lt;br /&gt;
=== More complex timing ===&lt;br /&gt;
&lt;br /&gt;
It's possible to specify a whole set of (keytime, keyvalue) pairs to define the animation function. Each item of the pairs are actually given separately:&lt;br /&gt;
* the set of attribute values (keyvalues) are given by the &amp;lt;code&amp;gt;values&amp;lt;/code&amp;gt; attribute.&lt;br /&gt;
* the set of time values (keytimes) are given by the &amp;lt;code&amp;gt;keyTimes&amp;lt;/code&amp;gt; attribute.&lt;br /&gt;
&lt;br /&gt;
Each set as the form of a semicolon-separated list of values. The thing to notice is that the keytimes are actually '''normalized to [0,1]''', which means that 0 maps to begin and 1 maps to end, and those values must start and end the list of keytimes. The image below illustrates all this:&lt;br /&gt;
&lt;br /&gt;
[[Image:time_interval2.png]]&lt;br /&gt;
&lt;br /&gt;
The keyTimes list can actually be omitted, in which case the keytimes are evenly distributed in the interval [0,1] (or equivalently, evenly in the interval [begin, end])&lt;br /&gt;
&lt;br /&gt;
The (keytime, keyvalue) pairs are joined by straight lines in the above graph, which means that '''linear interpolation''' is used for computing the inbetween values. &lt;br /&gt;
&lt;br /&gt;
When applied to the position of an object, linear interpolation results in un-natural robot-like motions (which may be the effect wanted). SMIL allows smoother animations to be defined by using '''spline-based interpolation''' between two (keytime, keyvalue) pairs. For each interval (t0, A0) - (t1, A1) a spline can be defined by two control points defining the tangents of the spline at t0 and t1. Those control points are passed in the attribute &amp;lt;code&amp;gt;keySplines&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[Image:spline_interpolation.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Two other interpolation modes are possible:&lt;br /&gt;
* '''discrete''': this is a degenerate form of interpolation, because the resulting animation function is not continuous. For each interval (t0,A0) - (t1, A1), the attribute value is set to A0 for the whole interval. It ''jumps'' to A1 right when t1 is reached and so on.&lt;br /&gt;
* '''paced''': in this interpolation mode, the attribute is interpolated so that its evolution over time has '''constant speed'''. Because the animation function is defined implicitly, the attribute &amp;lt;code&amp;gt;keyTimes&amp;lt;/code&amp;gt; is not taken into account. This mode is mainly useful for the &amp;lt;code&amp;gt;animateMotion&amp;lt;/code&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
=== Other aspects of animation ===&lt;br /&gt;
* repeating&lt;br /&gt;
* chaining animations.&lt;br /&gt;
* event based synchronisation&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
Examples showcasing some of the effects that can be achieved using procedural animation in SVG.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1px&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 1 --&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces on the floor: there are 6 motions here: fall, squeeze, squeeze-offset and bounce unsqueeze and unsqueeze-offset that are the revert version of 3 first. A classic animation trick is to start squeezing the ball a little before it touches the floor, expressed here by the synchronization &amp;lt;code&amp;gt;begin=fall.end - 0.1s&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td rowspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;path&lt;br /&gt;
   ...&lt;br /&gt;
   transform=&amp;quot;translate(0,4.5456868)&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;animateTransform&lt;br /&gt;
         type=&amp;quot;translate&amp;quot;&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot;&lt;br /&gt;
         from=&amp;quot;0, 0&amp;quot;&lt;br /&gt;
         to=&amp;quot;0, 136&amp;quot;&lt;br /&gt;
         dur=&amp;quot;1s&amp;quot;&lt;br /&gt;
         begin=&amp;quot;0s&amp;quot;&lt;br /&gt;
         attributeType=&amp;quot;XML&amp;quot;&lt;br /&gt;
         attributeName=&amp;quot;transform&amp;quot;&lt;br /&gt;
         id=&amp;quot;fall&amp;quot;&lt;br /&gt;
         keySplines=&amp;quot;0.5 0  0.8 0.5 &amp;quot;&lt;br /&gt;
         calcMode=&amp;quot;spline&amp;quot; /&amp;gt;&lt;br /&gt;
      &amp;lt;animateTransform&lt;br /&gt;
         id=&amp;quot;squeeze&amp;quot;&lt;br /&gt;
         type=&amp;quot;scale&amp;quot;&lt;br /&gt;
         from=&amp;quot;1,1&amp;quot;&lt;br /&gt;
         to=&amp;quot;1.1,0.9&amp;quot;&lt;br /&gt;
         begin=&amp;quot;fall.end-0.1s&amp;quot;&lt;br /&gt;
         attributeName=&amp;quot;transform&amp;quot;&lt;br /&gt;
         attributeType=&amp;quot;XML&amp;quot;&lt;br /&gt;
         dur=&amp;quot;0.2s&amp;quot;&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot; /&amp;gt;&lt;br /&gt;
      &amp;lt;animateTransform&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot;&lt;br /&gt;
         dur=&amp;quot;0.2s&amp;quot;&lt;br /&gt;
         attributeType=&amp;quot;XML&amp;quot;&lt;br /&gt;
         attributeName=&amp;quot;transform&amp;quot;&lt;br /&gt;
         begin=&amp;quot;fall.end-0.1s&amp;quot;&lt;br /&gt;
         to=&amp;quot;-13,0&amp;quot;&lt;br /&gt;
         from=&amp;quot;0,0&amp;quot;&lt;br /&gt;
         type=&amp;quot;translate&amp;quot;&lt;br /&gt;
         id=&amp;quot;squeeze-offset&amp;quot;&lt;br /&gt;
         accumulate=&amp;quot;sum&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball1.png]]&lt;br /&gt;
[http://wiki.inkscape.org/wiki/images/Bouncing_ball1.svg SVG file] |&lt;br /&gt;
[http://www.cdehais.fr/~tof/svg/bouncing_ball1.ogg ogg video]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 2 --&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces between two wall, following a path.&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td rowspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;path&lt;br /&gt;
       ...&lt;br /&gt;
       sodipodi:type=&amp;quot;arc&amp;quot;&lt;br /&gt;
       id=&amp;quot;ball&amp;quot; &lt;br /&gt;
       ... &lt;br /&gt;
&amp;gt;&lt;br /&gt;
      &amp;lt;animateMotion&lt;br /&gt;
         keyTimes=&amp;quot;0; 0.20; 1&amp;quot;&lt;br /&gt;
         keyPoints=&amp;quot;0; 0.33; 1&amp;quot;&lt;br /&gt;
         repeatCount=&amp;quot;indefinite&amp;quot;&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot;&lt;br /&gt;
         rotate=&amp;quot;0&amp;quot;&lt;br /&gt;
         begin=&amp;quot;0s&amp;quot;&lt;br /&gt;
         dur=&amp;quot;2s&amp;quot;&lt;br /&gt;
         calcMode=&amp;quot;linear&amp;quot;&lt;br /&gt;
         id=&amp;quot;animateMotion2680&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;mpath&lt;br /&gt;
           xlink:href=&amp;quot;#motion_path&amp;quot;&lt;br /&gt;
           id=&amp;quot;mpath2682&amp;quot; /&amp;gt;&lt;br /&gt;
      &amp;lt;/animateMotion&amp;gt;&lt;br /&gt;
&amp;lt;/path&amp;gt;&lt;br /&gt;
&amp;lt;path&lt;br /&gt;
   d=&amp;quot;M 82.080559,103.82375 ...&amp;quot;&lt;br /&gt;
   id=&amp;quot;motion_path&amp;quot; ... /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball2.png]]&lt;br /&gt;
[http://wiki.inkscape.org/wiki/images/Bouncing_ball2.svg SVG file] |&lt;br /&gt;
[http://www.cdehais.fr/~tof/svg/bouncing_ball2.ogg ogg video]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 3 --&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces between 2 walls. The motion is defined as a combination a of vertical translation and a horizontal translation. This works because the second animation has an &amp;lt;code&amp;gt;additive=&amp;quot;sum&amp;quot;&amp;lt;/code&amp;gt; attribute, so the corresponding matrix is composited with the matrix defined by the underlying animations.&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td rowspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
&amp;lt;!-- two animation sharing the same path --&amp;gt;&lt;br /&gt;
  &amp;lt;animateMotion&lt;br /&gt;
     id=&amp;quot;animateMotion2302&amp;quot;&lt;br /&gt;
     xlink:href=&amp;quot;#arrow2&amp;quot;&lt;br /&gt;
     dur=&amp;quot;4s&amp;quot;&lt;br /&gt;
     keyTimes=&amp;quot;0; 0.5; 1&amp;quot;&lt;br /&gt;
     keyPoints=&amp;quot;0; 1; 0&amp;quot;&lt;br /&gt;
     calcMode=&amp;quot;linear&amp;quot;&lt;br /&gt;
     repeatCount=&amp;quot;indefinite&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;mpath&lt;br /&gt;
       id=&amp;quot;mpath2305&amp;quot;&lt;br /&gt;
       xlink:href=&amp;quot;#horiz-bounce&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/animateMotion&amp;gt;&lt;br /&gt;
  &amp;lt;animateMotion&lt;br /&gt;
     calcMode=&amp;quot;linear&amp;quot;&lt;br /&gt;
     keyPoints=&amp;quot;0; 1; 0&amp;quot;&lt;br /&gt;
     keyTimes=&amp;quot;0; 0.5; 1&amp;quot;&lt;br /&gt;
     dur=&amp;quot;4s&amp;quot;&lt;br /&gt;
     xlink:href=&amp;quot;#ball&amp;quot;&lt;br /&gt;
     id=&amp;quot;animateMotion2309&amp;quot;&lt;br /&gt;
     repeatCount=&amp;quot;indefinite&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;mpath&lt;br /&gt;
       xlink:href=&amp;quot;#horiz-bounce&amp;quot;&lt;br /&gt;
       id=&amp;quot;mpath2311&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/animateMotion&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
  &amp;lt;animateMotion&lt;br /&gt;
     keySplines=&amp;quot;0.5 0 0.75 0.75, 0 0.5 0.5 0.75&amp;quot;&lt;br /&gt;
     keyPoints=&amp;quot;0;  1; 0&amp;quot;&lt;br /&gt;
     calcMode=&amp;quot;spline&amp;quot;&lt;br /&gt;
     keyTimes=&amp;quot;0;  0.5; 1&amp;quot;&lt;br /&gt;
     id=&amp;quot;animateMotion2298&amp;quot;&lt;br /&gt;
     begin=&amp;quot;0s&amp;quot;&lt;br /&gt;
     dur=&amp;quot;2s&amp;quot;&lt;br /&gt;
     xlink:href=&amp;quot;#ball&amp;quot;&lt;br /&gt;
     additive=&amp;quot;sum&amp;quot;&lt;br /&gt;
     repeatCount=&amp;quot;indefinite&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;mpath&lt;br /&gt;
       id=&amp;quot;mpath2300&amp;quot;&lt;br /&gt;
       xlink:href=&amp;quot;#vert-bounce&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/animateMotion&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball3.png]]&lt;br /&gt;
[http://wiki.inkscape.org/wiki/images/Bouncing_ball3.svg SVG file] |&lt;br /&gt;
[http://www.cdehais.fr/~tof/svg/bouncing_ball3.ogg ogg video]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Useful tools ==&lt;br /&gt;
&lt;br /&gt;
* [http://xmlgraphics.apache.org/batik/tools/browser.html Squiggle ], as part of [http://xmlgraphics.apache.org/batik/ Batik 1.7] has a nearly complete support for SMIL Animation. The [[#Examples|examples]] were all rendered using Squiggle.&lt;br /&gt;
* Inkscape ! I used the xml editor to manually add the animation elements for my test. It's a bit more cumbersome than editing the svg file in a text editor, but doing that in Inkscape eases the computation of key positions (just move the object around and read the position values).&lt;br /&gt;
&lt;br /&gt;
== Various thoughts ==&lt;br /&gt;
&lt;br /&gt;
* There is no direct way to specify a &amp;lt;b&amp;gt;''ping-pong'' animation&amp;lt;/b&amp;gt; in SVG, that is to tell an animation to go back in time when it reaches it's end. To implement this, I see 2 solutions:&lt;br /&gt;
**double the duration d of the animation (&amp;lt;code&amp;gt;dur&amp;lt;/code&amp;gt; attribute) and apply a scale and a symetry around t=0.5 to the animation function. For example the simple linear interpolation defined by &amp;lt;code&amp;gt;keyTimes=&amp;quot;0; 1&amp;quot;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;keyPoints=&amp;quot;0;1&amp;quot;&amp;lt;/code&amp;gt; becomes &amp;lt;code&amp;gt;keyTimes=&amp;quot;0; 0.5; 1&amp;quot;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;keyPoints=&amp;quot;0;1;0&amp;quot;&amp;lt;/code&amp;gt;. This doesn't work for &amp;lt;code&amp;gt;paced&amp;lt;/code&amp;gt; animation though (which make use of an implicit, user-agent dependent animation function).&lt;br /&gt;
** copy the original animation (call it e.g. &amp;lt;code&amp;gt;motion_forward&amp;lt;/code&amp;gt;) and swap the &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; values in the copy. Then specify &amp;lt;code&amp;gt;begin=&amp;quot;motion_forward.end&amp;quot;&amp;lt;/code&amp;gt; to tell the backward animation to start right at the end of the forward animation. This should work for every animation type.&lt;br /&gt;
&lt;br /&gt;
The question is: what maps best to a UI ?&lt;/div&gt;</summary>
		<author><name>ToF</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation&amp;diff=26594</id>
		<title>SVG Animation</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation&amp;diff=26594"/>
		<updated>2008-03-29T13:07:06Z</updated>

		<summary type="html">&lt;p&gt;ToF: /* SVG Animation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is a '''work in progress'''. [[User:ToF|ToF]]&lt;br /&gt;
&lt;br /&gt;
See also the [[SVG_Animation_UI|UI ideas page]] (specific to SMIL animation).&lt;br /&gt;
&lt;br /&gt;
== SVG Animation ==&lt;br /&gt;
&lt;br /&gt;
Animation in SVG is defined in the Animation Module of the [http://www.w3.org/TR/SVG11/animate.html SVG specification]. Animation in SVG conforms to the [http://www.w3.org/TR/2001/REC-smil-animation-20010904/ SMIL specification] (Synchronized Multimedia Integration Language) and extends it (SVG is said to be a ''host'' language of SMIL).&lt;br /&gt;
&lt;br /&gt;
Here I only focus on procedural animation as defined by SMIL and not free-form scripted animation (using e.g. Javascript to manipulate the DOM). &lt;br /&gt;
&lt;br /&gt;
In SMIL an animation is an object which defines the evolution of a given attribute of a given object (here an SVG element - path, rect, group...) over time. Multiple animations can control the evolution of particular attribute: for example, one will tell the object to turn for 1 second starting at t=0 second and another to move across the document for 2 seconds starting at a later time. So we have this relation:&lt;br /&gt;
             1:n&lt;br /&gt;
  Element &amp;lt;-------&amp;gt; Animation&lt;br /&gt;
&lt;br /&gt;
For a given animation the element which is controlled is called the '''target''' element of the animation. The specific attribute/property which is controlled is called the '''target''' attribute/property.&lt;br /&gt;
&lt;br /&gt;
In fact, it's completely legal to have two animations that control the same attribute of the same element, and they can overlap in time: at any particular time there exists a ''stack'' of animations applying to a particular attribute, and SMIL defines the order in which each animation is applied.&lt;br /&gt;
&lt;br /&gt;
== Animation elements ==&lt;br /&gt;
&lt;br /&gt;
SVG defines 5 animation elements:&lt;br /&gt;
* '''animate'''&lt;br /&gt;
This element is used to animate any scalar attribute or property, such as the &amp;lt;code&amp;gt;width&amp;lt;/code&amp;gt; attribute of an svg:rect element or the CCS property &amp;lt;code&amp;gt;opacity&amp;lt;/code&amp;gt;&lt;br /&gt;
* '''animateMotion'''&lt;br /&gt;
This elements only controls the position of a SVG element, by telling it to follow a given path&lt;br /&gt;
* '''animateColor'''&lt;br /&gt;
This element controls the animation of color valued attributes and properties.&lt;br /&gt;
* '''animateTransform'''&lt;br /&gt;
This element controls the transformation which applies to the target element. It replaces or adds up to the &amp;lt;code&amp;gt;transform&amp;lt;/code&amp;gt; attribute of the element.&lt;br /&gt;
* '''set'''&lt;br /&gt;
This element is used to set a particular value for the target attribute during a specified time interval. It is mainly used for animating attributes which do not span a continuous domain, such as boolean values like the &amp;lt;code&amp;gt;visibility&amp;lt;/code&amp;gt; property.&lt;br /&gt;
&lt;br /&gt;
== Specifying the target element and property ==&lt;br /&gt;
&lt;br /&gt;
There are 2 ways to tell which element a given animation will target. The first one is to embed the [[#Animation elements|animation element]] as a child tag of the element to animate. Here is an example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;circle cx=&amp;quot;100px&amp;quot; cy=&amp;quot;100px&amp;quot; r=&amp;quot;20px&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;animate attributeName=&amp;quot;r&amp;quot; attributeType=&amp;quot;XML&amp;quot; begin=&amp;quot;1s&amp;quot; dur=&amp;quot;2s&amp;quot; from=&amp;quot;20px&amp;quot; to=&amp;quot;50px&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/circle&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;animate&amp;lt;/code&amp;gt; element targets the radius (&amp;lt;code&amp;gt;r&amp;lt;/code&amp;gt;) property of the parent &amp;lt;code&amp;gt;circle&amp;lt;/code&amp;gt; element. Starting 1 second after the document start, the radius will grow for 2 seconds from 20 pixels to 50 pixels. When nothing else is specified, the animation only applies in its interval of time, here [1-3] seconds; from 0 to 1 second and then from 3 second and after, the circle's radius is set back to its ''static'' attribute value, here 20 pixels.&lt;br /&gt;
&lt;br /&gt;
The other way to specify the target element is to reference it in via an &amp;lt;code&amp;gt;xlink:href&amp;lt;/code&amp;gt; attribute of the animation element. the previous animation could be written this way:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;circle id=&amp;quot;balloon&amp;quot; cx=&amp;quot;100px&amp;quot; cy=&amp;quot;100px&amp;quot; r=&amp;quot;20px&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;animate xlink:href=&amp;quot;#balloon&amp;quot; attributeName=&amp;quot;r&amp;quot; attributeType=&amp;quot;XML&amp;quot; begin=&amp;quot;1s&amp;quot; dur=&amp;quot;2s&amp;quot; from=&amp;quot;20px&amp;quot; to=&amp;quot;50px&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To specify which property or attribute of the target element is controlled, we use the two attributes &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;attributeType&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; explains itself, it's the name of the controlled attribute. &amp;lt;code&amp;gt;attributeType&amp;lt;/code&amp;gt; tells whether &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; is searched among the SVG attributes of the element (&amp;lt;code&amp;gt;attributeType=&amp;quot;XML&amp;quot;&amp;lt;/code&amp;gt;) or among the CSS properties of the element (&amp;lt;code&amp;gt;attributeType=&amp;quot;CSS&amp;quot;&amp;lt;/code&amp;gt;). [http://www.w3.org/TR/SVG11/animate.html#TargetElement (SPEC)]&lt;br /&gt;
&lt;br /&gt;
== Timing an animation ==&lt;br /&gt;
&lt;br /&gt;
The first thing to stress is that SMIL (and therefore SVG) animation is '''time-based''', as opposed to '''frame-based'''. '''Frame-based''' animation is something traditional animators are used to, because they actually draw each image of the animation on a separate celluloid sheet, and the timing is related to the rate of images per second the camera will capture. When animation is done on a computer, the animator doesn't draw every image but only some ''key'' images (or ''keyframes'') and then the animation software creates all the necessary images for him (the so-called ''in-betweens''). That means the animator can focus back to a (real-)time based timing. Each keyframe is positioned on a timeline with real time values (instead of frame numbers). Of course at the end the animation is discrete and there is a fixed number of images computed inbetween two keyframes, but the neat property of specifying keyframes at time position is that the final animation frame rate is scalable and the animator doesn't have to care about it anymore. He just tells the software to produce 24 images each second if he targets a theatre film or say 10 images per second for low-bandwidth web animation. The animator doesn't need to reposition the keyframes.&lt;br /&gt;
&lt;br /&gt;
=== In-betweening by interpolation ===&lt;br /&gt;
&lt;br /&gt;
Creating the inbetween images on a computer is done by mean of '''interpolation'''. Interpolation is a mathematical tool that can reconstruct a the continuous evolution of a parameter given a set of discrete values of this parameter over time.&lt;br /&gt;
The following image illustrates that. We know that some attribute A must take value A0, A1, A2 and A3 at times t0, t1, t2 and t3. The red curves is one of the possible continuous function that be used to compute inbetween values of A in the interval [t0, t3].&lt;br /&gt;
&lt;br /&gt;
[[Image:interpolation.png]]&lt;br /&gt;
&lt;br /&gt;
* The animation's time interval&lt;br /&gt;
The first aspect that characterizes an animation is the interval of time on which it applies: when does it begin, when does it end or how long does it run.&lt;br /&gt;
Any of the above mentioned [[#Animation elements|animation elements] accept the attributes &amp;lt;code&amp;gt;begin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;dur&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
There are many ways to define a particular point in time and this is what makes SMIL a very rich animation framework (see below). The simplest is to specify a clock-value which syntax is quite intuitive [http://www.w3.org/TR/SVG11/animate.html#ClockValueSyntax (SPEC)]. Depending on the combination of those 3 attributes, the interval of time of the animation will be [begin, end], [begin, begin+dur], [end-dur, end], etc.&lt;br /&gt;
&lt;br /&gt;
* The attribute values&lt;br /&gt;
To specify the values taken by the attribute over the time interval, one need to tell the value that the parameter must have at the begin and at the end of the interval. here again those values are specified by combinations of three attributes: &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;by&amp;lt;/code&amp;gt;. The attribute &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt; correspond to the begin value, the attribute &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; correspond to the end value. The attribute &amp;lt;code&amp;gt;by&amp;lt;/code&amp;gt; let you define either the initial and final values relative to the other one, that is to = from + by or from = to - by. The following image illusttrate this setup for our hypothetical attribute A&lt;br /&gt;
&lt;br /&gt;
[[Image:time_interval.png]]&lt;br /&gt;
&lt;br /&gt;
The values of A are simply interpolated '''linearly''' in between begin and end. This is the more simple form of '''animation function''' that can defined: by the two extremal pairs of (time, attribute value): (begin, from) and (end, to).&lt;br /&gt;
&lt;br /&gt;
=== More complex timing ===&lt;br /&gt;
&lt;br /&gt;
It's possible to specify a whole set of (keytime, keyvalue) pairs to define the animation function. Each item of the pairs are actually given separately:&lt;br /&gt;
* the set of attribute values (keyvalues) are given by the &amp;lt;code&amp;gt;values&amp;lt;/code&amp;gt; attribute.&lt;br /&gt;
* the set of time values (keytimes) are given by the &amp;lt;code&amp;gt;keyTimes&amp;lt;/code&amp;gt; attribute.&lt;br /&gt;
&lt;br /&gt;
Each set as the form of a semicolon-separated list of values. The thing to notice is that the keytimes are actually '''normalized to [0,1]''', which means that 0 maps to begin and 1 maps to end, and those values must start and end the list of keytimes. The image below illustrates all this:&lt;br /&gt;
&lt;br /&gt;
[[Image:time_interval2.png]]&lt;br /&gt;
&lt;br /&gt;
The keyTimes list can actually be omitted, in which case the keytimes are evenly distributed in the interval [0,1] (or equivalently, evenly in the interval [begin, end])&lt;br /&gt;
&lt;br /&gt;
The (keytime, keyvalue) pairs are joined by straight lines in the above graph, which means that '''linear interpolation''' is used for computing the inbetween values. &lt;br /&gt;
&lt;br /&gt;
When applied to the position of an object, linear interpolation results in un-natural robot-like motions (which may be the effect wanted). SMIL allows smoother animations to be defined by using '''spline-based interpolation''' between two (keytime, keyvalue) pairs. For each interval (t0, A0) - (t1, A1) a spline can be defined by two control points defining the tangents of the spline at t0 and t1. Those control points are passed in the attribute &amp;lt;code&amp;gt;keySplines&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[Image:spline_interpolation.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Two other interpolation modes are possible:&lt;br /&gt;
* '''discrete''': this is a degenerate form of interpolation, because the resulting animation function is not continuous. For each interval (t0,A0) - (t1, A1), the attribute value is set to A0 for the whole interval. It ''jumps'' to A1 right when t1 is reached and so on.&lt;br /&gt;
* '''paced''': in this interpolation mode, the attribute is interpolated so that its evolution over time has '''constant speed'''. Because the animation function is defined implicitly, the attribute &amp;lt;code&amp;gt;keyTimes&amp;lt;/code&amp;gt; is not taken into account. This mode is mainly useful for the &amp;lt;code&amp;gt;animateMotion&amp;lt;/code&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
=== Other aspects of animation ===&lt;br /&gt;
* repeating&lt;br /&gt;
* chaining animations.&lt;br /&gt;
* event based synchronisation&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
Examples showcasing some of the effects that can be achieved using procedural animation in SVG.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1px&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 1 --&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces on the floor: there are 6 motions here: fall, squeeze, squeeze-offset and bounce unsqueeze and unsqueeze-offset that are the revert version of 3 first. A classic animation trick is to start squeezing the ball a little before it touches the floor, expressed here by the synchronization &amp;lt;code&amp;gt;begin=fall.end - 0.1s&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td rowspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;path&lt;br /&gt;
   ...&lt;br /&gt;
   transform=&amp;quot;translate(0,4.5456868)&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;animateTransform&lt;br /&gt;
         type=&amp;quot;translate&amp;quot;&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot;&lt;br /&gt;
         from=&amp;quot;0, 0&amp;quot;&lt;br /&gt;
         to=&amp;quot;0, 136&amp;quot;&lt;br /&gt;
         dur=&amp;quot;1s&amp;quot;&lt;br /&gt;
         begin=&amp;quot;0s&amp;quot;&lt;br /&gt;
         attributeType=&amp;quot;XML&amp;quot;&lt;br /&gt;
         attributeName=&amp;quot;transform&amp;quot;&lt;br /&gt;
         id=&amp;quot;fall&amp;quot;&lt;br /&gt;
         keySplines=&amp;quot;0.5 0  0.8 0.5 &amp;quot;&lt;br /&gt;
         calcMode=&amp;quot;spline&amp;quot; /&amp;gt;&lt;br /&gt;
      &amp;lt;animateTransform&lt;br /&gt;
         id=&amp;quot;squeeze&amp;quot;&lt;br /&gt;
         type=&amp;quot;scale&amp;quot;&lt;br /&gt;
         from=&amp;quot;1,1&amp;quot;&lt;br /&gt;
         to=&amp;quot;1.1,0.9&amp;quot;&lt;br /&gt;
         begin=&amp;quot;fall.end-0.1s&amp;quot;&lt;br /&gt;
         attributeName=&amp;quot;transform&amp;quot;&lt;br /&gt;
         attributeType=&amp;quot;XML&amp;quot;&lt;br /&gt;
         dur=&amp;quot;0.2s&amp;quot;&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot; /&amp;gt;&lt;br /&gt;
      &amp;lt;animateTransform&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot;&lt;br /&gt;
         dur=&amp;quot;0.2s&amp;quot;&lt;br /&gt;
         attributeType=&amp;quot;XML&amp;quot;&lt;br /&gt;
         attributeName=&amp;quot;transform&amp;quot;&lt;br /&gt;
         begin=&amp;quot;fall.end-0.1s&amp;quot;&lt;br /&gt;
         to=&amp;quot;-13,0&amp;quot;&lt;br /&gt;
         from=&amp;quot;0,0&amp;quot;&lt;br /&gt;
         type=&amp;quot;translate&amp;quot;&lt;br /&gt;
         id=&amp;quot;squeeze-offset&amp;quot;&lt;br /&gt;
         accumulate=&amp;quot;sum&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball1.png]]&lt;br /&gt;
[http://wiki.inkscape.org/wiki/images/Bouncing_ball1.svg SVG file] |&lt;br /&gt;
[http://www.cdehais.fr/~tof/svg/bouncing_ball1.ogg ogg video]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 2 --&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces between two wall, following a path.&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td rowspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;path&lt;br /&gt;
       ...&lt;br /&gt;
       sodipodi:type=&amp;quot;arc&amp;quot;&lt;br /&gt;
       id=&amp;quot;ball&amp;quot; &lt;br /&gt;
       ... &lt;br /&gt;
&amp;gt;&lt;br /&gt;
      &amp;lt;animateMotion&lt;br /&gt;
         keyTimes=&amp;quot;0; 0.20; 1&amp;quot;&lt;br /&gt;
         keyPoints=&amp;quot;0; 0.33; 1&amp;quot;&lt;br /&gt;
         repeatCount=&amp;quot;indefinite&amp;quot;&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot;&lt;br /&gt;
         rotate=&amp;quot;0&amp;quot;&lt;br /&gt;
         begin=&amp;quot;0s&amp;quot;&lt;br /&gt;
         dur=&amp;quot;2s&amp;quot;&lt;br /&gt;
         calcMode=&amp;quot;linear&amp;quot;&lt;br /&gt;
         id=&amp;quot;animateMotion2680&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;mpath&lt;br /&gt;
           xlink:href=&amp;quot;#motion_path&amp;quot;&lt;br /&gt;
           id=&amp;quot;mpath2682&amp;quot; /&amp;gt;&lt;br /&gt;
      &amp;lt;/animateMotion&amp;gt;&lt;br /&gt;
&amp;lt;/path&amp;gt;&lt;br /&gt;
&amp;lt;path&lt;br /&gt;
   d=&amp;quot;M 82.080559,103.82375 ...&amp;quot;&lt;br /&gt;
   id=&amp;quot;motion_path&amp;quot; ... /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball2.png]]&lt;br /&gt;
[http://wiki.inkscape.org/wiki/images/Bouncing_ball2.svg SVG file] |&lt;br /&gt;
[http://www.cdehais.fr/~tof/svg/bouncing_ball2.ogg ogg video]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 3 --&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces between 2 walls. The motion is defined as a combination a of vertical translation and a horizontal translation. This works because the second animation has an &amp;lt;code&amp;gt;additive=&amp;quot;sum&amp;quot;&amp;lt;/code&amp;gt; attribute, so the corresponding matrix is composited with the matrix defined by the underlying animations.&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td rowspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
&amp;lt;!-- two animation sharing the same path --&amp;gt;&lt;br /&gt;
  &amp;lt;animateMotion&lt;br /&gt;
     id=&amp;quot;animateMotion2302&amp;quot;&lt;br /&gt;
     xlink:href=&amp;quot;#arrow2&amp;quot;&lt;br /&gt;
     dur=&amp;quot;4s&amp;quot;&lt;br /&gt;
     keyTimes=&amp;quot;0; 0.5; 1&amp;quot;&lt;br /&gt;
     keyPoints=&amp;quot;0; 1; 0&amp;quot;&lt;br /&gt;
     calcMode=&amp;quot;linear&amp;quot;&lt;br /&gt;
     repeatCount=&amp;quot;indefinite&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;mpath&lt;br /&gt;
       id=&amp;quot;mpath2305&amp;quot;&lt;br /&gt;
       xlink:href=&amp;quot;#horiz-bounce&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/animateMotion&amp;gt;&lt;br /&gt;
  &amp;lt;animateMotion&lt;br /&gt;
     calcMode=&amp;quot;linear&amp;quot;&lt;br /&gt;
     keyPoints=&amp;quot;0; 1; 0&amp;quot;&lt;br /&gt;
     keyTimes=&amp;quot;0; 0.5; 1&amp;quot;&lt;br /&gt;
     dur=&amp;quot;4s&amp;quot;&lt;br /&gt;
     xlink:href=&amp;quot;#ball&amp;quot;&lt;br /&gt;
     id=&amp;quot;animateMotion2309&amp;quot;&lt;br /&gt;
     repeatCount=&amp;quot;indefinite&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;mpath&lt;br /&gt;
       xlink:href=&amp;quot;#horiz-bounce&amp;quot;&lt;br /&gt;
       id=&amp;quot;mpath2311&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/animateMotion&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
  &amp;lt;animateMotion&lt;br /&gt;
     keySplines=&amp;quot;0.5 0 0.75 0.75, 0 0.5 0.5 0.75&amp;quot;&lt;br /&gt;
     keyPoints=&amp;quot;0;  1; 0&amp;quot;&lt;br /&gt;
     calcMode=&amp;quot;spline&amp;quot;&lt;br /&gt;
     keyTimes=&amp;quot;0;  0.5; 1&amp;quot;&lt;br /&gt;
     id=&amp;quot;animateMotion2298&amp;quot;&lt;br /&gt;
     begin=&amp;quot;0s&amp;quot;&lt;br /&gt;
     dur=&amp;quot;2s&amp;quot;&lt;br /&gt;
     xlink:href=&amp;quot;#ball&amp;quot;&lt;br /&gt;
     additive=&amp;quot;sum&amp;quot;&lt;br /&gt;
     repeatCount=&amp;quot;indefinite&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;mpath&lt;br /&gt;
       id=&amp;quot;mpath2300&amp;quot;&lt;br /&gt;
       xlink:href=&amp;quot;#vert-bounce&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/animateMotion&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball3.png]]&lt;br /&gt;
[http://wiki.inkscape.org/wiki/images/Bouncing_ball3.svg SVG file] |&lt;br /&gt;
[http://www.cdehais.fr/~tof/svg/bouncing_ball3.ogg ogg video]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Useful tools ==&lt;br /&gt;
&lt;br /&gt;
* [http://xmlgraphics.apache.org/batik/tools/browser.html Squiggle ], as part of [http://xmlgraphics.apache.org/batik/ Batik 1.7] has a nearly complete support for SMIL Animation. The [[#Examples|examples]] were all rendered using Squiggle.&lt;br /&gt;
* Inkscape ! I used the xml editor to manually add the animation elements for my test. It's a bit more cumbersome than editing the svg file in a text editor, but doing that in Inkscape eases the computation of key positions (just move the object around and read the position values).&lt;br /&gt;
&lt;br /&gt;
== Various thoughts ==&lt;br /&gt;
&lt;br /&gt;
* There is no direct way to specify a &amp;lt;b&amp;gt;''ping-pong'' animation&amp;lt;/b&amp;gt; in SVG, that is to tell an animation to go back in time when it reaches it's end. To implement this, I see 2 solutions:&lt;br /&gt;
**double the duration d of the animation (&amp;lt;code&amp;gt;dur&amp;lt;/code&amp;gt; attribute) et apply a scale and a symetry around t=0.5 to the animation function. For example the simple linear interpolation defined by &amp;lt;code&amp;gt;keyTimes=&amp;quot;0; 1&amp;quot;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;keyPoints=&amp;quot;0;1&amp;quot;&amp;lt;/code&amp;gt; becomes &amp;lt;code&amp;gt;keyTimes=&amp;quot;0; 0.5; 1&amp;quot;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;keyPoints=&amp;quot;0;1;0&amp;quot;&amp;lt;/code&amp;gt;. This doesn't work for &amp;lt;code&amp;gt;paced&amp;lt;/code&amp;gt; animation though (which make use of an implicit, user-agent dependent animation function).&lt;br /&gt;
** copy the original animation (call it e.g. &amp;lt;code&amp;gt;motion_forward&amp;lt;/code&amp;gt;) and swap the &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; values in the copy. Then specify &amp;lt;code&amp;gt;begin=&amp;quot;motion_forward.end&amp;quot;&amp;lt;/code&amp;gt; to tell the backward animation to start right at the end of the forward animation. This should work for every animation type.&lt;br /&gt;
&lt;br /&gt;
The question is: what maps best to a UI ?&lt;/div&gt;</summary>
		<author><name>ToF</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=SpecSVGAnimation&amp;diff=26584</id>
		<title>SpecSVGAnimation</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=SpecSVGAnimation&amp;diff=26584"/>
		<updated>2008-03-29T12:15:29Z</updated>

		<summary type="html">&lt;p&gt;ToF: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;specification for an initial implementation of SVG animation features.&lt;br /&gt;
&lt;br /&gt;
launchpad [https://blueprints.launchpad.net/inkscape/+spec/svg-animation blueprint]&lt;br /&gt;
&lt;br /&gt;
inkscape-devel [http://www.nabble.com/Animation-%28was%3A-Re%3A-Inkscape---GSoC-%2708-proposal%29-td15791409.html  discussion]&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
&lt;br /&gt;
== Rationale ==&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Document Handling ===&lt;br /&gt;
&lt;br /&gt;
=== User Interface ===&lt;br /&gt;
&lt;br /&gt;
== Deliverables ==&lt;br /&gt;
&lt;br /&gt;
== Discussion ==&lt;br /&gt;
&lt;br /&gt;
* Is the Inkscape canvas fast enough for fast animation ?&lt;br /&gt;
* A complex UI like the timeline widget could benefit from a canvas API (e.g. goocanvas). But hey Inkscape already sports a canvas ! So does the Inkscape canvas could also be used for a custom GtkWidget ?&lt;br /&gt;
* Keep in mind the coming [[0.47_Refactoring_Plan |refactoring effort]]&lt;/div&gt;</summary>
		<author><name>ToF</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation_UI&amp;diff=24874</id>
		<title>SVG Animation UI</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation_UI&amp;diff=24874"/>
		<updated>2008-03-15T16:13:49Z</updated>

		<summary type="html">&lt;p&gt;ToF: /* Editing IPO curves */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''work in progress''' - [[User:ToF|ToF]]&lt;br /&gt;
&lt;br /&gt;
== User Interface ideas for SVG Animation ==&lt;br /&gt;
&lt;br /&gt;
This page gathers some ideas to bind a decent UI to the [[SVG_Animation|SMIL animation features]] of SVG. The bias is toward '''time-based''' animation. I believe that '''frame-based''' animation can easily be layered on top of that, if one's considers a frame as a snapshot of the continuous animation at a particular point in time.&lt;br /&gt;
&lt;br /&gt;
=== Timeline widget ===&lt;br /&gt;
&lt;br /&gt;
[[Image:anim_ui_01.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Editing IPO curves ===&lt;br /&gt;
Those dialogs are popped up when double clicking (or via right click menu) on an animation segment in the timeline widget.&lt;br /&gt;
&lt;br /&gt;
The idea is to make the edition of interpolation curves as similar as the edition of a standard path as done elsewhere in Inkscape. Some code reuse would be great too.&lt;br /&gt;
&lt;br /&gt;
[[Image:ipo_edit_spline.png]] [[Image:ipo_edit_paced.png]]&lt;br /&gt;
&lt;br /&gt;
[[Image:ipo_edit_linear.png]] [[Image:ipo_edit_discrete.png]]&lt;/div&gt;</summary>
		<author><name>ToF</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation_UI&amp;diff=24864</id>
		<title>SVG Animation UI</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation_UI&amp;diff=24864"/>
		<updated>2008-03-15T16:12:15Z</updated>

		<summary type="html">&lt;p&gt;ToF: /* Editing IPO curves */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''work in progress''' - [[User:ToF|ToF]]&lt;br /&gt;
&lt;br /&gt;
== User Interface ideas for SVG Animation ==&lt;br /&gt;
&lt;br /&gt;
This page gathers some ideas to bind a decent UI to the [[SVG_Animation|SMIL animation features]] of SVG. The bias is toward '''time-based''' animation. I believe that '''frame-based''' animation can easily be layered on top of that, if one's considers a frame as a snapshot of the continuous animation at a particular point in time.&lt;br /&gt;
&lt;br /&gt;
=== Timeline widget ===&lt;br /&gt;
&lt;br /&gt;
[[Image:anim_ui_01.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Editing IPO curves ===&lt;br /&gt;
&lt;br /&gt;
The idea is to make the edition of interpolation curves as similar as the edition of a standard path as done elsewhere in Inkscape. Some code reuse would be great too.&lt;br /&gt;
&lt;br /&gt;
[[Image:ipo_edit_spline.png]] [[Image:ipo_edit_paced.png]]&lt;br /&gt;
&lt;br /&gt;
[[Image:ipo_edit_linear.png]] [[Image:ipo_edit_discrete.png]]&lt;/div&gt;</summary>
		<author><name>ToF</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation_UI&amp;diff=24854</id>
		<title>SVG Animation UI</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation_UI&amp;diff=24854"/>
		<updated>2008-03-15T16:09:31Z</updated>

		<summary type="html">&lt;p&gt;ToF: /* User Interface ideas for SVG Animation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''work in progress''' - [[User:ToF|ToF]]&lt;br /&gt;
&lt;br /&gt;
== User Interface ideas for SVG Animation ==&lt;br /&gt;
&lt;br /&gt;
This page gathers some ideas to bind a decent UI to the [[SVG_Animation|SMIL animation features]] of SVG. The bias is toward '''time-based''' animation. I believe that '''frame-based''' animation can easily be layered on top of that, if one's considers a frame as a snapshot of the continuous animation at a particular point in time.&lt;br /&gt;
&lt;br /&gt;
=== Timeline widget ===&lt;br /&gt;
&lt;br /&gt;
[[Image:anim_ui_01.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Editing IPO curves ===&lt;br /&gt;
&lt;br /&gt;
[[Image:ipo_edit_spline.png]] [[Image:ipo_edit_paced.png]]&lt;br /&gt;
&lt;br /&gt;
[[Image:ipo_edit_linear.png]] [[Image:ipo_edit_discrete.png]]&lt;/div&gt;</summary>
		<author><name>ToF</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=File:Ipo_edit_spline.png&amp;diff=24844</id>
		<title>File:Ipo edit spline.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=File:Ipo_edit_spline.png&amp;diff=24844"/>
		<updated>2008-03-15T16:08:53Z</updated>

		<summary type="html">&lt;p&gt;ToF: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>ToF</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=File:Ipo_edit_paced.png&amp;diff=24834</id>
		<title>File:Ipo edit paced.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=File:Ipo_edit_paced.png&amp;diff=24834"/>
		<updated>2008-03-15T16:08:33Z</updated>

		<summary type="html">&lt;p&gt;ToF: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>ToF</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=File:Ipo_edit_linear.png&amp;diff=24824</id>
		<title>File:Ipo edit linear.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=File:Ipo_edit_linear.png&amp;diff=24824"/>
		<updated>2008-03-15T16:08:11Z</updated>

		<summary type="html">&lt;p&gt;ToF: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>ToF</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=File:Ipo_edit_discrete.png&amp;diff=24814</id>
		<title>File:Ipo edit discrete.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=File:Ipo_edit_discrete.png&amp;diff=24814"/>
		<updated>2008-03-15T16:07:56Z</updated>

		<summary type="html">&lt;p&gt;ToF: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>ToF</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=SpecSVGAnimation&amp;diff=24674</id>
		<title>SpecSVGAnimation</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=SpecSVGAnimation&amp;diff=24674"/>
		<updated>2008-03-14T19:03:10Z</updated>

		<summary type="html">&lt;p&gt;ToF: /* Discussion */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;specification for an initial implementation of SVG animation features.&lt;br /&gt;
&lt;br /&gt;
launchpad blueprint: &lt;br /&gt;
&lt;br /&gt;
inkscape-devel [http://www.nabble.com/Animation-%28was%3A-Re%3A-Inkscape---GSoC-%2708-proposal%29-td15791409.html  discussion]&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
&lt;br /&gt;
== Rationale ==&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Document Handling ===&lt;br /&gt;
&lt;br /&gt;
=== User Interface ===&lt;br /&gt;
&lt;br /&gt;
== Deliverables ==&lt;br /&gt;
&lt;br /&gt;
== Discussion ==&lt;br /&gt;
&lt;br /&gt;
* Is the Inkscape canvas fast enough for fast animation ?&lt;br /&gt;
* A complex UI like the timeline widget could benefit from a canvas API (e.g. goocanvas). But hey Inkscape already sports a canvas ! So does the Inkscape canvas could also be used for a custom GtkWidget ?&lt;br /&gt;
* Keep in mind the coming [[0.47_Refactoring_Plan |refactoring effort]]&lt;/div&gt;</summary>
		<author><name>ToF</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=SpecSVGAnimation&amp;diff=24284</id>
		<title>SpecSVGAnimation</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=SpecSVGAnimation&amp;diff=24284"/>
		<updated>2008-03-12T18:29:58Z</updated>

		<summary type="html">&lt;p&gt;ToF: /* Discussion */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;specification for an initial implementation of SVG animation features.&lt;br /&gt;
&lt;br /&gt;
launchpad blueprint: &lt;br /&gt;
&lt;br /&gt;
inkscape-devel [http://www.nabble.com/Animation-%28was%3A-Re%3A-Inkscape---GSoC-%2708-proposal%29-td15791409.html  discussion]&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
&lt;br /&gt;
== Rationale ==&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Document Handling ===&lt;br /&gt;
&lt;br /&gt;
=== User Interface ===&lt;br /&gt;
&lt;br /&gt;
== Deliverables ==&lt;br /&gt;
&lt;br /&gt;
== Discussion ==&lt;br /&gt;
&lt;br /&gt;
* Is the Inkscape canvas fast enough for fast animation ?&lt;br /&gt;
* A complex UI like the timeline widget could benefit from a canvas API (e.g. goocanvas). But hey Inkscape already sports a canvas ! So does the Inkscape canvas could also be used for a custom GtkWidget ?&lt;br /&gt;
* Keep in mind the refactoring effort that should start this summer.&lt;/div&gt;</summary>
		<author><name>ToF</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=SpecSVGAnimation&amp;diff=24224</id>
		<title>SpecSVGAnimation</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=SpecSVGAnimation&amp;diff=24224"/>
		<updated>2008-03-12T16:29:33Z</updated>

		<summary type="html">&lt;p&gt;ToF: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;specification for an initial implementation of SVG animation features.&lt;br /&gt;
&lt;br /&gt;
launchpad blueprint: &lt;br /&gt;
&lt;br /&gt;
inkscape-devel [http://www.nabble.com/Animation-%28was%3A-Re%3A-Inkscape---GSoC-%2708-proposal%29-td15791409.html  discussion]&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
&lt;br /&gt;
== Rationale ==&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Document Handling ===&lt;br /&gt;
&lt;br /&gt;
=== User Interface ===&lt;br /&gt;
&lt;br /&gt;
== Deliverables ==&lt;br /&gt;
&lt;br /&gt;
== Discussion ==&lt;br /&gt;
&lt;br /&gt;
* Is the Inkscape canvas fast enough for fast animation ?&lt;br /&gt;
* A complex UI like the timeline widget could benefit from a canvas API (e.g. goocanvas). But hey Inkscape already sports a canvas ! So does the Inkscape canvas could also be used for a custom GtkWidget ?&lt;/div&gt;</summary>
		<author><name>ToF</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=SpecSVGAnimation&amp;diff=24214</id>
		<title>SpecSVGAnimation</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=SpecSVGAnimation&amp;diff=24214"/>
		<updated>2008-03-12T16:03:19Z</updated>

		<summary type="html">&lt;p&gt;ToF: /* Discussion */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;specification for an initial implementation of SVG animation features.&lt;br /&gt;
&lt;br /&gt;
launchpad blueprint: &lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
&lt;br /&gt;
== Rationale ==&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Document Handling ===&lt;br /&gt;
&lt;br /&gt;
=== User Interface ===&lt;br /&gt;
&lt;br /&gt;
== Deliverables ==&lt;br /&gt;
&lt;br /&gt;
== Discussion ==&lt;br /&gt;
&lt;br /&gt;
* Is the Inkscape canvas fast enough for fast animation ?&lt;br /&gt;
* A complex UI like the timeline widget could benefit from a canvas API (e.g. goocanvas). But hey Inkscape already sports a canvas ! So does the Inkscape canvas could also be used for a custom GtkWidget ?&lt;/div&gt;</summary>
		<author><name>ToF</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=SpecSVGAnimation&amp;diff=24204</id>
		<title>SpecSVGAnimation</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=SpecSVGAnimation&amp;diff=24204"/>
		<updated>2008-03-12T16:02:32Z</updated>

		<summary type="html">&lt;p&gt;ToF: /* Discussion */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;specification for an initial implementation of SVG animation features.&lt;br /&gt;
&lt;br /&gt;
launchpad blueprint: &lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
&lt;br /&gt;
== Rationale ==&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Document Handling ===&lt;br /&gt;
&lt;br /&gt;
=== User Interface ===&lt;br /&gt;
&lt;br /&gt;
== Deliverables ==&lt;br /&gt;
&lt;br /&gt;
== Discussion ==&lt;br /&gt;
&lt;br /&gt;
* Is the Inkscape canvas fast enough for fast animation ?&lt;br /&gt;
* A complex UI like the timeline widget could benefit from a canvas API (e.g. goocanvas). But hey Inkscape already sports a canvas ! So does the Inkscape canvas could be also used for a custom GtkWidget ?&lt;/div&gt;</summary>
		<author><name>ToF</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=SpecSVGAnimation&amp;diff=24194</id>
		<title>SpecSVGAnimation</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=SpecSVGAnimation&amp;diff=24194"/>
		<updated>2008-03-12T12:29:08Z</updated>

		<summary type="html">&lt;p&gt;ToF: page creation&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;specification for an initial implementation of SVG animation features.&lt;br /&gt;
&lt;br /&gt;
launchpad blueprint: &lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
&lt;br /&gt;
== Rationale ==&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Document Handling ===&lt;br /&gt;
&lt;br /&gt;
=== User Interface ===&lt;br /&gt;
&lt;br /&gt;
== Deliverables ==&lt;br /&gt;
&lt;br /&gt;
== Discussion ==&lt;/div&gt;</summary>
		<author><name>ToF</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation_UI&amp;diff=23984</id>
		<title>SVG Animation UI</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation_UI&amp;diff=23984"/>
		<updated>2008-03-11T18:51:48Z</updated>

		<summary type="html">&lt;p&gt;ToF: /* User Interface ideas for SVG Animation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''work in progress''' - [[User:ToF|ToF]]&lt;br /&gt;
&lt;br /&gt;
== User Interface ideas for SVG Animation ==&lt;br /&gt;
&lt;br /&gt;
This page gathers some ideas to bind a decent UI to the [[SVG_Animation|SMIL animation features]] of SVG. The bias is toward '''time-based''' animation. I believe that '''frame-based''' animation can easily be layered on top of that, if one's considers a frame as a snapshot of the continuous animation at a particular point in time.&lt;br /&gt;
&lt;br /&gt;
[[Image:anim_ui_01.png]]&lt;/div&gt;</summary>
		<author><name>ToF</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=User:ToF&amp;diff=23974</id>
		<title>User:ToF</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=User:ToF&amp;diff=23974"/>
		<updated>2008-03-11T18:49:15Z</updated>

		<summary type="html">&lt;p&gt;ToF: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;My name is Christophe Dehais aka ToF.&lt;br /&gt;
&lt;br /&gt;
My POV is the one of the programmer and the user (without any artistic skill).&lt;/div&gt;</summary>
		<author><name>ToF</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation_UI&amp;diff=23964</id>
		<title>SVG Animation UI</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation_UI&amp;diff=23964"/>
		<updated>2008-03-11T18:45:03Z</updated>

		<summary type="html">&lt;p&gt;ToF: /* User Interface ideas for SVG Animation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''work in progress''' - [[User:ToF|ToF]]&lt;br /&gt;
&lt;br /&gt;
== User Interface ideas for SVG Animation ==&lt;br /&gt;
&lt;br /&gt;
This page gathers some ideas to bind a decent UI to the [[SVG_Animation|SMIL animation features]] of SVG. The bias is toward '''time-based''' animation. I believe that '''frame-based''' animation can easily be layered on top of that.&lt;br /&gt;
&lt;br /&gt;
[[Image:anim_ui_01.png]]&lt;/div&gt;</summary>
		<author><name>ToF</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=File:Anim_ui_01.png&amp;diff=23954</id>
		<title>File:Anim ui 01.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=File:Anim_ui_01.png&amp;diff=23954"/>
		<updated>2008-03-11T18:44:28Z</updated>

		<summary type="html">&lt;p&gt;ToF: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>ToF</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation&amp;diff=23944</id>
		<title>SVG Animation</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation&amp;diff=23944"/>
		<updated>2008-03-11T18:43:00Z</updated>

		<summary type="html">&lt;p&gt;ToF: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is a '''work in progress'''. [[User:ToF|ToF]]&lt;br /&gt;
&lt;br /&gt;
See also the [[SVG_Animation_UI|UI ideas page]] (specific to SMIL animation).&lt;br /&gt;
&lt;br /&gt;
== SVG Animation ==&lt;br /&gt;
&lt;br /&gt;
Animation in SVG is defined in the Animation Module of the [http://www.w3.org/TR/SVG11/animate.html SVG specification]. Animation in SVG conforms to the [http://www.w3.org/TR/2001/REC-smil-animation-20010904/ SMIL specification] (Synchronized Multimedia Integration Language) and extends it (SVG is said to be a ''host'' language of SMIL).&lt;br /&gt;
&lt;br /&gt;
Here I only focus on procedural animation and not programmatic animation (using a scripting language manipulating the DOM). &lt;br /&gt;
&lt;br /&gt;
In SMIL an animation is an object which defines the evolution of a given attribute of a given object (here an SVG element - path, rect, group...) over time. Multiple animations can control the evolution of particular attribute: for example, one will tell the object to turn for 1 second starting at t=0 second and another to move across the document for 2 seconds starting at a later time. So we have this relation:&lt;br /&gt;
             1:n&lt;br /&gt;
  Element &amp;lt;-------&amp;gt; Animation&lt;br /&gt;
&lt;br /&gt;
For a given animation the element which is controlled is called the '''target''' element of the animation. The specific attribute/property which is controlled is called the '''target''' attribute/property.&lt;br /&gt;
&lt;br /&gt;
In fact, it's completely legal to have two animations that control the same attribute of the same element, and they can overlap in time: at any particular time there exists a ''stack'' of animations applying to a particular attribute, and SMIL defines the order in which each animation is applied.&lt;br /&gt;
&lt;br /&gt;
== Animation elements ==&lt;br /&gt;
&lt;br /&gt;
SVG defines 5 animation elements:&lt;br /&gt;
* '''animate'''&lt;br /&gt;
This element is used to animate any scalar attribute or property, such as the &amp;lt;code&amp;gt;width&amp;lt;/code&amp;gt; attribute of an svg:rect element or the CCS property &amp;lt;code&amp;gt;opacity&amp;lt;/code&amp;gt;&lt;br /&gt;
* '''animateMotion'''&lt;br /&gt;
This elements only controls the position of a SVG element, by telling it to follow a given path&lt;br /&gt;
* '''animateColor'''&lt;br /&gt;
This element controls the animation of color valued attributes and properties.&lt;br /&gt;
* '''animateTransform'''&lt;br /&gt;
This element controls the transformation which applies to the target element. It replaces or adds up to the &amp;lt;code&amp;gt;transform&amp;lt;/code&amp;gt; attribute of the element.&lt;br /&gt;
* '''set'''&lt;br /&gt;
This element is used to set a particular value for the target attribute during a specified time interval. It is mainly used for animating attributes which do not span a continuous domain, such as boolean values like the &amp;lt;code&amp;gt;visibility&amp;lt;/code&amp;gt; property.&lt;br /&gt;
&lt;br /&gt;
== Specifying the target element and property ==&lt;br /&gt;
&lt;br /&gt;
There are 2 ways to tell which element a given animation will target. The first one is to embed the [[#Animation elements|animation element]] as a child tag of the element to animate. Here is an example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;circle cx=&amp;quot;100px&amp;quot; cy=&amp;quot;100px&amp;quot; r=&amp;quot;20px&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;animate attributeName=&amp;quot;r&amp;quot; attributeType=&amp;quot;XML&amp;quot; begin=&amp;quot;1s&amp;quot; dur=&amp;quot;2s&amp;quot; from=&amp;quot;20px&amp;quot; to=&amp;quot;50px&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/circle&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;animate&amp;lt;/code&amp;gt; element targets the radius (&amp;lt;code&amp;gt;r&amp;lt;/code&amp;gt;) property of the parent &amp;lt;code&amp;gt;circle&amp;lt;/code&amp;gt; element. Starting 1 second after the document start, the radius will grow for 2 seconds from 20 pixels to 50 pixels. When nothing else is specified, the animation only applies in its interval of time, here [1-3] seconds; from 0 to 1 second and then from 3 second and after, the circle's radius is set back to its ''static'' attribute value, here 20 pixels.&lt;br /&gt;
&lt;br /&gt;
The other way to specify the target element is to reference it in via an &amp;lt;code&amp;gt;xlink:href&amp;lt;/code&amp;gt; attribute of the animation element. the previous animation could be written this way:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;circle id=&amp;quot;balloon&amp;quot; cx=&amp;quot;100px&amp;quot; cy=&amp;quot;100px&amp;quot; r=&amp;quot;20px&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;animate xlink:href=&amp;quot;#balloon&amp;quot; attributeName=&amp;quot;r&amp;quot; attributeType=&amp;quot;XML&amp;quot; begin=&amp;quot;1s&amp;quot; dur=&amp;quot;2s&amp;quot; from=&amp;quot;20px&amp;quot; to=&amp;quot;50px&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To specify which property or attribute of the target element is controlled, we use the two attributes &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;attributeType&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; explains itself, it's the name of the controlled attribute. &amp;lt;code&amp;gt;attributeType&amp;lt;/code&amp;gt; tells whether &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; is searched among the SVG attributes of the element (&amp;lt;code&amp;gt;attributeType=&amp;quot;XML&amp;quot;&amp;lt;/code&amp;gt;) or among the CSS properties of the element (&amp;lt;code&amp;gt;attributeType=&amp;quot;CSS&amp;quot;&amp;lt;/code&amp;gt;). [http://www.w3.org/TR/SVG11/animate.html#TargetElement (SPEC)]&lt;br /&gt;
&lt;br /&gt;
== Timing an animation ==&lt;br /&gt;
&lt;br /&gt;
The first thing to stress is that SMIL (and therefore SVG) animation is '''time-based''', as opposed to '''frame-based'''. '''Frame-based''' animation is something traditional animators are used to, because they actually draw each image of the animation on a separate celluloid sheet, and the timing is related to the rate of images per second the camera will capture. When animation is done on a computer, the animator doesn't draw every image but only some ''key'' images (or ''keyframes'') and then the animation software creates all the necessary images for him (the so-called ''in-betweens''). That means the animator can focus back to a (real-)time based timing. Each keyframe is positioned on a timeline with real time values (instead of frame numbers). Of course at the end the animation is discrete and there is a fixed number of images computed inbetween two keyframes, but the neat property of specifying keyframes at time position is that the final animation frame rate is scalable and the animator doesn't have to care about it anymore. He just tells the software to produce 24 images each second if he targets a theatre film or say 10 images per second for low-bandwidth web animation. The animator doesn't need to reposition the keyframes.&lt;br /&gt;
&lt;br /&gt;
=== In-betweening by interpolation ===&lt;br /&gt;
&lt;br /&gt;
Creating the inbetween images on a computer is done by mean of '''interpolation'''. Interpolation is a mathematical tool that can reconstruct a the continuous evolution of a parameter given a set of discrete values of this parameter over time.&lt;br /&gt;
The following image illustrates that. We know that some attribute A must take value A0, A1, A2 and A3 at times t0, t1, t2 and t3. The red curves is one of the possible continuous function that be used to compute inbetween values of A in the interval [t0, t3].&lt;br /&gt;
&lt;br /&gt;
[[Image:interpolation.png]]&lt;br /&gt;
&lt;br /&gt;
* The animation's time interval&lt;br /&gt;
The first aspect that characterizes an animation is the interval of time on which it applies: when does it begin, when does it end or how long does it run.&lt;br /&gt;
Any of the above mentioned [[#Animation elements|animation elements] accept the attributes &amp;lt;code&amp;gt;begin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;dur&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
There are many ways to define a particular point in time and this is what makes SMIL a very rich animation framework (see below). The simplest is to specify a clock-value which syntax is quite intuitive [http://www.w3.org/TR/SVG11/animate.html#ClockValueSyntax (SPEC)]. Depending on the combination of those 3 attributes, the interval of time of the animation will be [begin, end], [begin, begin+dur], [end-dur, end], etc.&lt;br /&gt;
&lt;br /&gt;
* The attribute values&lt;br /&gt;
To specify the values taken by the attribute over the time interval, one need to tell the value that the parameter must have at the begin and at the end of the interval. here again those values are specified by combinations of three attributes: &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;by&amp;lt;/code&amp;gt;. The attribute &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt; correspond to the begin value, the attribute &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; correspond to the end value. The attribute &amp;lt;code&amp;gt;by&amp;lt;/code&amp;gt; let you define either the initial and final values relative to the other one, that is to = from + by or from = to - by. The following image illusttrate this setup for our hypothetical attribute A&lt;br /&gt;
&lt;br /&gt;
[[Image:time_interval.png]]&lt;br /&gt;
&lt;br /&gt;
The values of A are simply interpolated '''linearly''' in between begin and end. This is the more simple form of '''animation function''' that can defined: by the two extremal pairs of (time, attribute value): (begin, from) and (end, to).&lt;br /&gt;
&lt;br /&gt;
=== More complex timing ===&lt;br /&gt;
&lt;br /&gt;
It's possible to specify a whole set of (keytime, keyvalue) pairs to define the animation function. Each item of the pairs are actually given separately:&lt;br /&gt;
* the set of attribute values (keyvalues) are given by the &amp;lt;code&amp;gt;values&amp;lt;/code&amp;gt; attribute.&lt;br /&gt;
* the set of time values (keytimes) are given by the &amp;lt;code&amp;gt;keyTimes&amp;lt;/code&amp;gt; attribute.&lt;br /&gt;
&lt;br /&gt;
Each set as the form of a semicolon-separated list of values. The thing to notice is that the keytimes are actually '''normalized to [0,1]''', which means that 0 maps to begin and 1 maps to end, and those values must start and end the list of keytimes. The image below illustrates all this:&lt;br /&gt;
&lt;br /&gt;
[[Image:time_interval2.png]]&lt;br /&gt;
&lt;br /&gt;
The keyTimes list can actually be omitted, in which case the keytimes are evenly distributed in the interval [0,1] (or equivalently, evenly in the interval [begin, end])&lt;br /&gt;
&lt;br /&gt;
The (keytime, keyvalue) pairs are joined by straight lines in the above graph, which means that '''linear interpolation''' is used for computing the inbetween values. &lt;br /&gt;
&lt;br /&gt;
When applied to the position of an object, linear interpolation results in un-natural robot-like motions (which may be the effect wanted). SMIL allows smoother animations to be defined by using '''spline-based interpolation''' between two (keytime, keyvalue) pairs. For each interval (t0, A0) - (t1, A1) a spline can be defined by two control points defining the tangents of the spline at t0 and t1. Those control points are passed in the attribute &amp;lt;code&amp;gt;keySplines&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[Image:spline_interpolation.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Two other interpolation modes are possible:&lt;br /&gt;
* '''discrete''': this is a degenerate form of interpolation, because the resulting animation function is not continuous. For each interval (t0,A0) - (t1, A1), the attribute value is set to A0 for the whole interval. It ''jumps'' to A1 right when t1 is reached and so on.&lt;br /&gt;
* '''paced''': in this interpolation mode, the attribute is interpolated so that its evolution over time has '''constant speed'''. Because the animation function is defined implicitly, the attribute &amp;lt;code&amp;gt;keyTimes&amp;lt;/code&amp;gt; is not taken into account. This mode is mainly useful for the &amp;lt;code&amp;gt;animateMotion&amp;lt;/code&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
=== Other aspects of animation ===&lt;br /&gt;
* repeating&lt;br /&gt;
* chaining animations.&lt;br /&gt;
* event based synchronisation&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
Examples showcasing some of the effects that can be achieved using procedural animation in SVG.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1px&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 1 --&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces on the floor: there are 6 motions here: fall, squeeze, squeeze-offset and bounce unsqueeze and unsqueeze-offset that are the revert version of 3 first. A classic animation trick is to start squeezing the ball a little before it touches the floor, expressed here by the synchronization &amp;lt;code&amp;gt;begin=fall.end - 0.1s&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td rowspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;path&lt;br /&gt;
   ...&lt;br /&gt;
   transform=&amp;quot;translate(0,4.5456868)&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;animateTransform&lt;br /&gt;
         type=&amp;quot;translate&amp;quot;&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot;&lt;br /&gt;
         from=&amp;quot;0, 0&amp;quot;&lt;br /&gt;
         to=&amp;quot;0, 136&amp;quot;&lt;br /&gt;
         dur=&amp;quot;1s&amp;quot;&lt;br /&gt;
         begin=&amp;quot;0s&amp;quot;&lt;br /&gt;
         attributeType=&amp;quot;XML&amp;quot;&lt;br /&gt;
         attributeName=&amp;quot;transform&amp;quot;&lt;br /&gt;
         id=&amp;quot;fall&amp;quot;&lt;br /&gt;
         keySplines=&amp;quot;0.5 0  0.8 0.5 &amp;quot;&lt;br /&gt;
         calcMode=&amp;quot;spline&amp;quot; /&amp;gt;&lt;br /&gt;
      &amp;lt;animateTransform&lt;br /&gt;
         id=&amp;quot;squeeze&amp;quot;&lt;br /&gt;
         type=&amp;quot;scale&amp;quot;&lt;br /&gt;
         from=&amp;quot;1,1&amp;quot;&lt;br /&gt;
         to=&amp;quot;1.1,0.9&amp;quot;&lt;br /&gt;
         begin=&amp;quot;fall.end-0.1s&amp;quot;&lt;br /&gt;
         attributeName=&amp;quot;transform&amp;quot;&lt;br /&gt;
         attributeType=&amp;quot;XML&amp;quot;&lt;br /&gt;
         dur=&amp;quot;0.2s&amp;quot;&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot; /&amp;gt;&lt;br /&gt;
      &amp;lt;animateTransform&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot;&lt;br /&gt;
         dur=&amp;quot;0.2s&amp;quot;&lt;br /&gt;
         attributeType=&amp;quot;XML&amp;quot;&lt;br /&gt;
         attributeName=&amp;quot;transform&amp;quot;&lt;br /&gt;
         begin=&amp;quot;fall.end-0.1s&amp;quot;&lt;br /&gt;
         to=&amp;quot;-13,0&amp;quot;&lt;br /&gt;
         from=&amp;quot;0,0&amp;quot;&lt;br /&gt;
         type=&amp;quot;translate&amp;quot;&lt;br /&gt;
         id=&amp;quot;squeeze-offset&amp;quot;&lt;br /&gt;
         accumulate=&amp;quot;sum&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball1.png]]&lt;br /&gt;
[http://wiki.inkscape.org/wiki/images/Bouncing_ball1.svg SVG file] |&lt;br /&gt;
[http://www.cdehais.fr/~tof/svg/bouncing_ball1.ogg ogg video]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 2 --&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces between two wall, following a path.&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td rowspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;path&lt;br /&gt;
       ...&lt;br /&gt;
       sodipodi:type=&amp;quot;arc&amp;quot;&lt;br /&gt;
       id=&amp;quot;ball&amp;quot; &lt;br /&gt;
       ... &lt;br /&gt;
&amp;gt;&lt;br /&gt;
      &amp;lt;animateMotion&lt;br /&gt;
         keyTimes=&amp;quot;0; 0.20; 1&amp;quot;&lt;br /&gt;
         keyPoints=&amp;quot;0; 0.33; 1&amp;quot;&lt;br /&gt;
         repeatCount=&amp;quot;indefinite&amp;quot;&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot;&lt;br /&gt;
         rotate=&amp;quot;0&amp;quot;&lt;br /&gt;
         begin=&amp;quot;0s&amp;quot;&lt;br /&gt;
         dur=&amp;quot;2s&amp;quot;&lt;br /&gt;
         calcMode=&amp;quot;linear&amp;quot;&lt;br /&gt;
         id=&amp;quot;animateMotion2680&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;mpath&lt;br /&gt;
           xlink:href=&amp;quot;#motion_path&amp;quot;&lt;br /&gt;
           id=&amp;quot;mpath2682&amp;quot; /&amp;gt;&lt;br /&gt;
      &amp;lt;/animateMotion&amp;gt;&lt;br /&gt;
&amp;lt;/path&amp;gt;&lt;br /&gt;
&amp;lt;path&lt;br /&gt;
   d=&amp;quot;M 82.080559,103.82375 ...&amp;quot;&lt;br /&gt;
   id=&amp;quot;motion_path&amp;quot; ... /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball2.png]]&lt;br /&gt;
[http://wiki.inkscape.org/wiki/images/Bouncing_ball2.svg SVG file] |&lt;br /&gt;
[http://www.cdehais.fr/~tof/svg/bouncing_ball2.ogg ogg video]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 3 --&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces between 2 walls. The motion is defined as a combination a of vertical translation and a horizontal translation. This works because the second animation has an &amp;lt;code&amp;gt;additive=&amp;quot;sum&amp;quot;&amp;lt;/code&amp;gt; attribute, so the corresponding matrix is composited with the matrix defined by the underlying animations.&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td rowspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
&amp;lt;!-- two animation sharing the same path --&amp;gt;&lt;br /&gt;
  &amp;lt;animateMotion&lt;br /&gt;
     id=&amp;quot;animateMotion2302&amp;quot;&lt;br /&gt;
     xlink:href=&amp;quot;#arrow2&amp;quot;&lt;br /&gt;
     dur=&amp;quot;4s&amp;quot;&lt;br /&gt;
     keyTimes=&amp;quot;0; 0.5; 1&amp;quot;&lt;br /&gt;
     keyPoints=&amp;quot;0; 1; 0&amp;quot;&lt;br /&gt;
     calcMode=&amp;quot;linear&amp;quot;&lt;br /&gt;
     repeatCount=&amp;quot;indefinite&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;mpath&lt;br /&gt;
       id=&amp;quot;mpath2305&amp;quot;&lt;br /&gt;
       xlink:href=&amp;quot;#horiz-bounce&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/animateMotion&amp;gt;&lt;br /&gt;
  &amp;lt;animateMotion&lt;br /&gt;
     calcMode=&amp;quot;linear&amp;quot;&lt;br /&gt;
     keyPoints=&amp;quot;0; 1; 0&amp;quot;&lt;br /&gt;
     keyTimes=&amp;quot;0; 0.5; 1&amp;quot;&lt;br /&gt;
     dur=&amp;quot;4s&amp;quot;&lt;br /&gt;
     xlink:href=&amp;quot;#ball&amp;quot;&lt;br /&gt;
     id=&amp;quot;animateMotion2309&amp;quot;&lt;br /&gt;
     repeatCount=&amp;quot;indefinite&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;mpath&lt;br /&gt;
       xlink:href=&amp;quot;#horiz-bounce&amp;quot;&lt;br /&gt;
       id=&amp;quot;mpath2311&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/animateMotion&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
  &amp;lt;animateMotion&lt;br /&gt;
     keySplines=&amp;quot;0.5 0 0.75 0.75, 0 0.5 0.5 0.75&amp;quot;&lt;br /&gt;
     keyPoints=&amp;quot;0;  1; 0&amp;quot;&lt;br /&gt;
     calcMode=&amp;quot;spline&amp;quot;&lt;br /&gt;
     keyTimes=&amp;quot;0;  0.5; 1&amp;quot;&lt;br /&gt;
     id=&amp;quot;animateMotion2298&amp;quot;&lt;br /&gt;
     begin=&amp;quot;0s&amp;quot;&lt;br /&gt;
     dur=&amp;quot;2s&amp;quot;&lt;br /&gt;
     xlink:href=&amp;quot;#ball&amp;quot;&lt;br /&gt;
     additive=&amp;quot;sum&amp;quot;&lt;br /&gt;
     repeatCount=&amp;quot;indefinite&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;mpath&lt;br /&gt;
       id=&amp;quot;mpath2300&amp;quot;&lt;br /&gt;
       xlink:href=&amp;quot;#vert-bounce&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/animateMotion&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball3.png]]&lt;br /&gt;
[http://wiki.inkscape.org/wiki/images/Bouncing_ball3.svg SVG file] |&lt;br /&gt;
[http://www.cdehais.fr/~tof/svg/bouncing_ball3.ogg ogg video]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Useful tools ==&lt;br /&gt;
&lt;br /&gt;
* [http://xmlgraphics.apache.org/batik/tools/browser.html Squiggle ], as part of [http://xmlgraphics.apache.org/batik/ Batik 1.7] has a nearly complete support for SMIL Animation. The [[#Examples|examples]] were all rendered using Squiggle.&lt;br /&gt;
* Inkscape ! I used the xml editor to manually add the animation elements for my test. It's a bit more cumbersome than editing the svg file in a text editor, but doing that in Inkscape eases the computation of key positions (just move the object around and read the position values).&lt;br /&gt;
&lt;br /&gt;
== Various thoughts ==&lt;br /&gt;
&lt;br /&gt;
* There is no direct way to specify a &amp;lt;b&amp;gt;''ping-pong'' animation&amp;lt;/b&amp;gt; in SVG, that is to tell an animation to go back in time when it reaches it's end. To implement this, I see 2 solutions:&lt;br /&gt;
**double the duration d of the animation (&amp;lt;code&amp;gt;dur&amp;lt;/code&amp;gt; attribute) et apply a scale and a symetry around t=0.5 to the animation function. For example the simple linear interpolation defined by &amp;lt;code&amp;gt;keyTimes=&amp;quot;0; 1&amp;quot;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;keyPoints=&amp;quot;0;1&amp;quot;&amp;lt;/code&amp;gt; becomes &amp;lt;code&amp;gt;keyTimes=&amp;quot;0; 0.5; 1&amp;quot;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;keyPoints=&amp;quot;0;1;0&amp;quot;&amp;lt;/code&amp;gt;. This doesn't work for &amp;lt;code&amp;gt;paced&amp;lt;/code&amp;gt; animation though (which make use of an implicit, user-agent dependent animation function).&lt;br /&gt;
** copy the original animation (call it e.g. &amp;lt;code&amp;gt;motion_forward&amp;lt;/code&amp;gt;) and swap the &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; values in the copy. Then specify &amp;lt;code&amp;gt;begin=&amp;quot;motion_forward.end&amp;quot;&amp;lt;/code&amp;gt; to tell the backward animation to start right at the end of the forward animation. This should work for every animation type.&lt;br /&gt;
&lt;br /&gt;
The question is: what maps best to a UI ?&lt;/div&gt;</summary>
		<author><name>ToF</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation&amp;diff=23934</id>
		<title>SVG Animation</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation&amp;diff=23934"/>
		<updated>2008-03-11T18:42:35Z</updated>

		<summary type="html">&lt;p&gt;ToF: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is a '''work in progress'''. [[User:ToF|ToF]]&lt;br /&gt;
See also the [[SVG_Animation_UI|UI ideas page]] (specific to SMIL animation).&lt;br /&gt;
&lt;br /&gt;
== SVG Animation ==&lt;br /&gt;
&lt;br /&gt;
Animation in SVG is defined in the Animation Module of the [http://www.w3.org/TR/SVG11/animate.html SVG specification]. Animation in SVG conforms to the [http://www.w3.org/TR/2001/REC-smil-animation-20010904/ SMIL specification] (Synchronized Multimedia Integration Language) and extends it (SVG is said to be a ''host'' language of SMIL).&lt;br /&gt;
&lt;br /&gt;
Here I only focus on procedural animation and not programmatic animation (using a scripting language manipulating the DOM). &lt;br /&gt;
&lt;br /&gt;
In SMIL an animation is an object which defines the evolution of a given attribute of a given object (here an SVG element - path, rect, group...) over time. Multiple animations can control the evolution of particular attribute: for example, one will tell the object to turn for 1 second starting at t=0 second and another to move across the document for 2 seconds starting at a later time. So we have this relation:&lt;br /&gt;
             1:n&lt;br /&gt;
  Element &amp;lt;-------&amp;gt; Animation&lt;br /&gt;
&lt;br /&gt;
For a given animation the element which is controlled is called the '''target''' element of the animation. The specific attribute/property which is controlled is called the '''target''' attribute/property.&lt;br /&gt;
&lt;br /&gt;
In fact, it's completely legal to have two animations that control the same attribute of the same element, and they can overlap in time: at any particular time there exists a ''stack'' of animations applying to a particular attribute, and SMIL defines the order in which each animation is applied.&lt;br /&gt;
&lt;br /&gt;
== Animation elements ==&lt;br /&gt;
&lt;br /&gt;
SVG defines 5 animation elements:&lt;br /&gt;
* '''animate'''&lt;br /&gt;
This element is used to animate any scalar attribute or property, such as the &amp;lt;code&amp;gt;width&amp;lt;/code&amp;gt; attribute of an svg:rect element or the CCS property &amp;lt;code&amp;gt;opacity&amp;lt;/code&amp;gt;&lt;br /&gt;
* '''animateMotion'''&lt;br /&gt;
This elements only controls the position of a SVG element, by telling it to follow a given path&lt;br /&gt;
* '''animateColor'''&lt;br /&gt;
This element controls the animation of color valued attributes and properties.&lt;br /&gt;
* '''animateTransform'''&lt;br /&gt;
This element controls the transformation which applies to the target element. It replaces or adds up to the &amp;lt;code&amp;gt;transform&amp;lt;/code&amp;gt; attribute of the element.&lt;br /&gt;
* '''set'''&lt;br /&gt;
This element is used to set a particular value for the target attribute during a specified time interval. It is mainly used for animating attributes which do not span a continuous domain, such as boolean values like the &amp;lt;code&amp;gt;visibility&amp;lt;/code&amp;gt; property.&lt;br /&gt;
&lt;br /&gt;
== Specifying the target element and property ==&lt;br /&gt;
&lt;br /&gt;
There are 2 ways to tell which element a given animation will target. The first one is to embed the [[#Animation elements|animation element]] as a child tag of the element to animate. Here is an example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;circle cx=&amp;quot;100px&amp;quot; cy=&amp;quot;100px&amp;quot; r=&amp;quot;20px&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;animate attributeName=&amp;quot;r&amp;quot; attributeType=&amp;quot;XML&amp;quot; begin=&amp;quot;1s&amp;quot; dur=&amp;quot;2s&amp;quot; from=&amp;quot;20px&amp;quot; to=&amp;quot;50px&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/circle&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;animate&amp;lt;/code&amp;gt; element targets the radius (&amp;lt;code&amp;gt;r&amp;lt;/code&amp;gt;) property of the parent &amp;lt;code&amp;gt;circle&amp;lt;/code&amp;gt; element. Starting 1 second after the document start, the radius will grow for 2 seconds from 20 pixels to 50 pixels. When nothing else is specified, the animation only applies in its interval of time, here [1-3] seconds; from 0 to 1 second and then from 3 second and after, the circle's radius is set back to its ''static'' attribute value, here 20 pixels.&lt;br /&gt;
&lt;br /&gt;
The other way to specify the target element is to reference it in via an &amp;lt;code&amp;gt;xlink:href&amp;lt;/code&amp;gt; attribute of the animation element. the previous animation could be written this way:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;circle id=&amp;quot;balloon&amp;quot; cx=&amp;quot;100px&amp;quot; cy=&amp;quot;100px&amp;quot; r=&amp;quot;20px&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;animate xlink:href=&amp;quot;#balloon&amp;quot; attributeName=&amp;quot;r&amp;quot; attributeType=&amp;quot;XML&amp;quot; begin=&amp;quot;1s&amp;quot; dur=&amp;quot;2s&amp;quot; from=&amp;quot;20px&amp;quot; to=&amp;quot;50px&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To specify which property or attribute of the target element is controlled, we use the two attributes &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;attributeType&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; explains itself, it's the name of the controlled attribute. &amp;lt;code&amp;gt;attributeType&amp;lt;/code&amp;gt; tells whether &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; is searched among the SVG attributes of the element (&amp;lt;code&amp;gt;attributeType=&amp;quot;XML&amp;quot;&amp;lt;/code&amp;gt;) or among the CSS properties of the element (&amp;lt;code&amp;gt;attributeType=&amp;quot;CSS&amp;quot;&amp;lt;/code&amp;gt;). [http://www.w3.org/TR/SVG11/animate.html#TargetElement (SPEC)]&lt;br /&gt;
&lt;br /&gt;
== Timing an animation ==&lt;br /&gt;
&lt;br /&gt;
The first thing to stress is that SMIL (and therefore SVG) animation is '''time-based''', as opposed to '''frame-based'''. '''Frame-based''' animation is something traditional animators are used to, because they actually draw each image of the animation on a separate celluloid sheet, and the timing is related to the rate of images per second the camera will capture. When animation is done on a computer, the animator doesn't draw every image but only some ''key'' images (or ''keyframes'') and then the animation software creates all the necessary images for him (the so-called ''in-betweens''). That means the animator can focus back to a (real-)time based timing. Each keyframe is positioned on a timeline with real time values (instead of frame numbers). Of course at the end the animation is discrete and there is a fixed number of images computed inbetween two keyframes, but the neat property of specifying keyframes at time position is that the final animation frame rate is scalable and the animator doesn't have to care about it anymore. He just tells the software to produce 24 images each second if he targets a theatre film or say 10 images per second for low-bandwidth web animation. The animator doesn't need to reposition the keyframes.&lt;br /&gt;
&lt;br /&gt;
=== In-betweening by interpolation ===&lt;br /&gt;
&lt;br /&gt;
Creating the inbetween images on a computer is done by mean of '''interpolation'''. Interpolation is a mathematical tool that can reconstruct a the continuous evolution of a parameter given a set of discrete values of this parameter over time.&lt;br /&gt;
The following image illustrates that. We know that some attribute A must take value A0, A1, A2 and A3 at times t0, t1, t2 and t3. The red curves is one of the possible continuous function that be used to compute inbetween values of A in the interval [t0, t3].&lt;br /&gt;
&lt;br /&gt;
[[Image:interpolation.png]]&lt;br /&gt;
&lt;br /&gt;
* The animation's time interval&lt;br /&gt;
The first aspect that characterizes an animation is the interval of time on which it applies: when does it begin, when does it end or how long does it run.&lt;br /&gt;
Any of the above mentioned [[#Animation elements|animation elements] accept the attributes &amp;lt;code&amp;gt;begin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;dur&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
There are many ways to define a particular point in time and this is what makes SMIL a very rich animation framework (see below). The simplest is to specify a clock-value which syntax is quite intuitive [http://www.w3.org/TR/SVG11/animate.html#ClockValueSyntax (SPEC)]. Depending on the combination of those 3 attributes, the interval of time of the animation will be [begin, end], [begin, begin+dur], [end-dur, end], etc.&lt;br /&gt;
&lt;br /&gt;
* The attribute values&lt;br /&gt;
To specify the values taken by the attribute over the time interval, one need to tell the value that the parameter must have at the begin and at the end of the interval. here again those values are specified by combinations of three attributes: &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;by&amp;lt;/code&amp;gt;. The attribute &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt; correspond to the begin value, the attribute &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; correspond to the end value. The attribute &amp;lt;code&amp;gt;by&amp;lt;/code&amp;gt; let you define either the initial and final values relative to the other one, that is to = from + by or from = to - by. The following image illusttrate this setup for our hypothetical attribute A&lt;br /&gt;
&lt;br /&gt;
[[Image:time_interval.png]]&lt;br /&gt;
&lt;br /&gt;
The values of A are simply interpolated '''linearly''' in between begin and end. This is the more simple form of '''animation function''' that can defined: by the two extremal pairs of (time, attribute value): (begin, from) and (end, to).&lt;br /&gt;
&lt;br /&gt;
=== More complex timing ===&lt;br /&gt;
&lt;br /&gt;
It's possible to specify a whole set of (keytime, keyvalue) pairs to define the animation function. Each item of the pairs are actually given separately:&lt;br /&gt;
* the set of attribute values (keyvalues) are given by the &amp;lt;code&amp;gt;values&amp;lt;/code&amp;gt; attribute.&lt;br /&gt;
* the set of time values (keytimes) are given by the &amp;lt;code&amp;gt;keyTimes&amp;lt;/code&amp;gt; attribute.&lt;br /&gt;
&lt;br /&gt;
Each set as the form of a semicolon-separated list of values. The thing to notice is that the keytimes are actually '''normalized to [0,1]''', which means that 0 maps to begin and 1 maps to end, and those values must start and end the list of keytimes. The image below illustrates all this:&lt;br /&gt;
&lt;br /&gt;
[[Image:time_interval2.png]]&lt;br /&gt;
&lt;br /&gt;
The keyTimes list can actually be omitted, in which case the keytimes are evenly distributed in the interval [0,1] (or equivalently, evenly in the interval [begin, end])&lt;br /&gt;
&lt;br /&gt;
The (keytime, keyvalue) pairs are joined by straight lines in the above graph, which means that '''linear interpolation''' is used for computing the inbetween values. &lt;br /&gt;
&lt;br /&gt;
When applied to the position of an object, linear interpolation results in un-natural robot-like motions (which may be the effect wanted). SMIL allows smoother animations to be defined by using '''spline-based interpolation''' between two (keytime, keyvalue) pairs. For each interval (t0, A0) - (t1, A1) a spline can be defined by two control points defining the tangents of the spline at t0 and t1. Those control points are passed in the attribute &amp;lt;code&amp;gt;keySplines&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[Image:spline_interpolation.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Two other interpolation modes are possible:&lt;br /&gt;
* '''discrete''': this is a degenerate form of interpolation, because the resulting animation function is not continuous. For each interval (t0,A0) - (t1, A1), the attribute value is set to A0 for the whole interval. It ''jumps'' to A1 right when t1 is reached and so on.&lt;br /&gt;
* '''paced''': in this interpolation mode, the attribute is interpolated so that its evolution over time has '''constant speed'''. Because the animation function is defined implicitly, the attribute &amp;lt;code&amp;gt;keyTimes&amp;lt;/code&amp;gt; is not taken into account. This mode is mainly useful for the &amp;lt;code&amp;gt;animateMotion&amp;lt;/code&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
=== Other aspects of animation ===&lt;br /&gt;
* repeating&lt;br /&gt;
* chaining animations.&lt;br /&gt;
* event based synchronisation&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
Examples showcasing some of the effects that can be achieved using procedural animation in SVG.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1px&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 1 --&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces on the floor: there are 6 motions here: fall, squeeze, squeeze-offset and bounce unsqueeze and unsqueeze-offset that are the revert version of 3 first. A classic animation trick is to start squeezing the ball a little before it touches the floor, expressed here by the synchronization &amp;lt;code&amp;gt;begin=fall.end - 0.1s&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td rowspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;path&lt;br /&gt;
   ...&lt;br /&gt;
   transform=&amp;quot;translate(0,4.5456868)&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;animateTransform&lt;br /&gt;
         type=&amp;quot;translate&amp;quot;&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot;&lt;br /&gt;
         from=&amp;quot;0, 0&amp;quot;&lt;br /&gt;
         to=&amp;quot;0, 136&amp;quot;&lt;br /&gt;
         dur=&amp;quot;1s&amp;quot;&lt;br /&gt;
         begin=&amp;quot;0s&amp;quot;&lt;br /&gt;
         attributeType=&amp;quot;XML&amp;quot;&lt;br /&gt;
         attributeName=&amp;quot;transform&amp;quot;&lt;br /&gt;
         id=&amp;quot;fall&amp;quot;&lt;br /&gt;
         keySplines=&amp;quot;0.5 0  0.8 0.5 &amp;quot;&lt;br /&gt;
         calcMode=&amp;quot;spline&amp;quot; /&amp;gt;&lt;br /&gt;
      &amp;lt;animateTransform&lt;br /&gt;
         id=&amp;quot;squeeze&amp;quot;&lt;br /&gt;
         type=&amp;quot;scale&amp;quot;&lt;br /&gt;
         from=&amp;quot;1,1&amp;quot;&lt;br /&gt;
         to=&amp;quot;1.1,0.9&amp;quot;&lt;br /&gt;
         begin=&amp;quot;fall.end-0.1s&amp;quot;&lt;br /&gt;
         attributeName=&amp;quot;transform&amp;quot;&lt;br /&gt;
         attributeType=&amp;quot;XML&amp;quot;&lt;br /&gt;
         dur=&amp;quot;0.2s&amp;quot;&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot; /&amp;gt;&lt;br /&gt;
      &amp;lt;animateTransform&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot;&lt;br /&gt;
         dur=&amp;quot;0.2s&amp;quot;&lt;br /&gt;
         attributeType=&amp;quot;XML&amp;quot;&lt;br /&gt;
         attributeName=&amp;quot;transform&amp;quot;&lt;br /&gt;
         begin=&amp;quot;fall.end-0.1s&amp;quot;&lt;br /&gt;
         to=&amp;quot;-13,0&amp;quot;&lt;br /&gt;
         from=&amp;quot;0,0&amp;quot;&lt;br /&gt;
         type=&amp;quot;translate&amp;quot;&lt;br /&gt;
         id=&amp;quot;squeeze-offset&amp;quot;&lt;br /&gt;
         accumulate=&amp;quot;sum&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball1.png]]&lt;br /&gt;
[http://wiki.inkscape.org/wiki/images/Bouncing_ball1.svg SVG file] |&lt;br /&gt;
[http://www.cdehais.fr/~tof/svg/bouncing_ball1.ogg ogg video]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 2 --&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces between two wall, following a path.&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td rowspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;path&lt;br /&gt;
       ...&lt;br /&gt;
       sodipodi:type=&amp;quot;arc&amp;quot;&lt;br /&gt;
       id=&amp;quot;ball&amp;quot; &lt;br /&gt;
       ... &lt;br /&gt;
&amp;gt;&lt;br /&gt;
      &amp;lt;animateMotion&lt;br /&gt;
         keyTimes=&amp;quot;0; 0.20; 1&amp;quot;&lt;br /&gt;
         keyPoints=&amp;quot;0; 0.33; 1&amp;quot;&lt;br /&gt;
         repeatCount=&amp;quot;indefinite&amp;quot;&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot;&lt;br /&gt;
         rotate=&amp;quot;0&amp;quot;&lt;br /&gt;
         begin=&amp;quot;0s&amp;quot;&lt;br /&gt;
         dur=&amp;quot;2s&amp;quot;&lt;br /&gt;
         calcMode=&amp;quot;linear&amp;quot;&lt;br /&gt;
         id=&amp;quot;animateMotion2680&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;mpath&lt;br /&gt;
           xlink:href=&amp;quot;#motion_path&amp;quot;&lt;br /&gt;
           id=&amp;quot;mpath2682&amp;quot; /&amp;gt;&lt;br /&gt;
      &amp;lt;/animateMotion&amp;gt;&lt;br /&gt;
&amp;lt;/path&amp;gt;&lt;br /&gt;
&amp;lt;path&lt;br /&gt;
   d=&amp;quot;M 82.080559,103.82375 ...&amp;quot;&lt;br /&gt;
   id=&amp;quot;motion_path&amp;quot; ... /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball2.png]]&lt;br /&gt;
[http://wiki.inkscape.org/wiki/images/Bouncing_ball2.svg SVG file] |&lt;br /&gt;
[http://www.cdehais.fr/~tof/svg/bouncing_ball2.ogg ogg video]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 3 --&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces between 2 walls. The motion is defined as a combination a of vertical translation and a horizontal translation. This works because the second animation has an &amp;lt;code&amp;gt;additive=&amp;quot;sum&amp;quot;&amp;lt;/code&amp;gt; attribute, so the corresponding matrix is composited with the matrix defined by the underlying animations.&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td rowspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
&amp;lt;!-- two animation sharing the same path --&amp;gt;&lt;br /&gt;
  &amp;lt;animateMotion&lt;br /&gt;
     id=&amp;quot;animateMotion2302&amp;quot;&lt;br /&gt;
     xlink:href=&amp;quot;#arrow2&amp;quot;&lt;br /&gt;
     dur=&amp;quot;4s&amp;quot;&lt;br /&gt;
     keyTimes=&amp;quot;0; 0.5; 1&amp;quot;&lt;br /&gt;
     keyPoints=&amp;quot;0; 1; 0&amp;quot;&lt;br /&gt;
     calcMode=&amp;quot;linear&amp;quot;&lt;br /&gt;
     repeatCount=&amp;quot;indefinite&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;mpath&lt;br /&gt;
       id=&amp;quot;mpath2305&amp;quot;&lt;br /&gt;
       xlink:href=&amp;quot;#horiz-bounce&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/animateMotion&amp;gt;&lt;br /&gt;
  &amp;lt;animateMotion&lt;br /&gt;
     calcMode=&amp;quot;linear&amp;quot;&lt;br /&gt;
     keyPoints=&amp;quot;0; 1; 0&amp;quot;&lt;br /&gt;
     keyTimes=&amp;quot;0; 0.5; 1&amp;quot;&lt;br /&gt;
     dur=&amp;quot;4s&amp;quot;&lt;br /&gt;
     xlink:href=&amp;quot;#ball&amp;quot;&lt;br /&gt;
     id=&amp;quot;animateMotion2309&amp;quot;&lt;br /&gt;
     repeatCount=&amp;quot;indefinite&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;mpath&lt;br /&gt;
       xlink:href=&amp;quot;#horiz-bounce&amp;quot;&lt;br /&gt;
       id=&amp;quot;mpath2311&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/animateMotion&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
  &amp;lt;animateMotion&lt;br /&gt;
     keySplines=&amp;quot;0.5 0 0.75 0.75, 0 0.5 0.5 0.75&amp;quot;&lt;br /&gt;
     keyPoints=&amp;quot;0;  1; 0&amp;quot;&lt;br /&gt;
     calcMode=&amp;quot;spline&amp;quot;&lt;br /&gt;
     keyTimes=&amp;quot;0;  0.5; 1&amp;quot;&lt;br /&gt;
     id=&amp;quot;animateMotion2298&amp;quot;&lt;br /&gt;
     begin=&amp;quot;0s&amp;quot;&lt;br /&gt;
     dur=&amp;quot;2s&amp;quot;&lt;br /&gt;
     xlink:href=&amp;quot;#ball&amp;quot;&lt;br /&gt;
     additive=&amp;quot;sum&amp;quot;&lt;br /&gt;
     repeatCount=&amp;quot;indefinite&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;mpath&lt;br /&gt;
       id=&amp;quot;mpath2300&amp;quot;&lt;br /&gt;
       xlink:href=&amp;quot;#vert-bounce&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/animateMotion&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball3.png]]&lt;br /&gt;
[http://wiki.inkscape.org/wiki/images/Bouncing_ball3.svg SVG file] |&lt;br /&gt;
[http://www.cdehais.fr/~tof/svg/bouncing_ball3.ogg ogg video]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Useful tools ==&lt;br /&gt;
&lt;br /&gt;
* [http://xmlgraphics.apache.org/batik/tools/browser.html Squiggle ], as part of [http://xmlgraphics.apache.org/batik/ Batik 1.7] has a nearly complete support for SMIL Animation. The [[#Examples|examples]] were all rendered using Squiggle.&lt;br /&gt;
* Inkscape ! I used the xml editor to manually add the animation elements for my test. It's a bit more cumbersome than editing the svg file in a text editor, but doing that in Inkscape eases the computation of key positions (just move the object around and read the position values).&lt;br /&gt;
&lt;br /&gt;
== Various thoughts ==&lt;br /&gt;
&lt;br /&gt;
* There is no direct way to specify a &amp;lt;b&amp;gt;''ping-pong'' animation&amp;lt;/b&amp;gt; in SVG, that is to tell an animation to go back in time when it reaches it's end. To implement this, I see 2 solutions:&lt;br /&gt;
**double the duration d of the animation (&amp;lt;code&amp;gt;dur&amp;lt;/code&amp;gt; attribute) et apply a scale and a symetry around t=0.5 to the animation function. For example the simple linear interpolation defined by &amp;lt;code&amp;gt;keyTimes=&amp;quot;0; 1&amp;quot;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;keyPoints=&amp;quot;0;1&amp;quot;&amp;lt;/code&amp;gt; becomes &amp;lt;code&amp;gt;keyTimes=&amp;quot;0; 0.5; 1&amp;quot;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;keyPoints=&amp;quot;0;1;0&amp;quot;&amp;lt;/code&amp;gt;. This doesn't work for &amp;lt;code&amp;gt;paced&amp;lt;/code&amp;gt; animation though (which make use of an implicit, user-agent dependent animation function).&lt;br /&gt;
** copy the original animation (call it e.g. &amp;lt;code&amp;gt;motion_forward&amp;lt;/code&amp;gt;) and swap the &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; values in the copy. Then specify &amp;lt;code&amp;gt;begin=&amp;quot;motion_forward.end&amp;quot;&amp;lt;/code&amp;gt; to tell the backward animation to start right at the end of the forward animation. This should work for every animation type.&lt;br /&gt;
&lt;br /&gt;
The question is: what maps best to a UI ?&lt;/div&gt;</summary>
		<author><name>ToF</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation_UI&amp;diff=23924</id>
		<title>SVG Animation UI</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation_UI&amp;diff=23924"/>
		<updated>2008-03-11T18:42:14Z</updated>

		<summary type="html">&lt;p&gt;ToF: /* User Interface ideas for SVG Animation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''work in progress''' - [[User:ToF|ToF]]&lt;br /&gt;
&lt;br /&gt;
== User Interface ideas for SVG Animation ==&lt;br /&gt;
&lt;br /&gt;
This page gathers some ideas to bind a decent UI to the [[SVG_Animation|SMIL animation features]] of SVG. The bias is toward '''time-based''' animation. I believe that '''frame-based''' animation can easily be layered on top of that.&lt;/div&gt;</summary>
		<author><name>ToF</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation_UI&amp;diff=23914</id>
		<title>SVG Animation UI</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation_UI&amp;diff=23914"/>
		<updated>2008-03-11T18:41:32Z</updated>

		<summary type="html">&lt;p&gt;ToF: page creation&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
'''work in progress''' - [[User:ToF|ToF]]&lt;br /&gt;
&lt;br /&gt;
== User Interface ideas for SVG Animation ==&lt;br /&gt;
&lt;br /&gt;
This page gathers some ideas to bind a decent UI to the [[SVG_Animation|SMIL] animation features of SVG. The bias is toward '''time-based''' animation. I believe that '''frame-based''' animation can easily be layered on top of that.&lt;/div&gt;</summary>
		<author><name>ToF</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation&amp;diff=23904</id>
		<title>SVG Animation</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation&amp;diff=23904"/>
		<updated>2008-03-11T18:33:38Z</updated>

		<summary type="html">&lt;p&gt;ToF: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is a '''work in progress'''. [[User:ToF|ToF]]&lt;br /&gt;
See also the SVGAnimationUI page.&lt;br /&gt;
&lt;br /&gt;
== SVG Animation ==&lt;br /&gt;
&lt;br /&gt;
Animation in SVG is defined in the Animation Module of the [http://www.w3.org/TR/SVG11/animate.html SVG specification]. Animation in SVG conforms to the [http://www.w3.org/TR/2001/REC-smil-animation-20010904/ SMIL specification] (Synchronized Multimedia Integration Language) and extends it (SVG is said to be a ''host'' language of SMIL).&lt;br /&gt;
&lt;br /&gt;
Here I only focus on procedural animation and not programmatic animation (using a scripting language manipulating the DOM). &lt;br /&gt;
&lt;br /&gt;
In SMIL an animation is an object which defines the evolution of a given attribute of a given object (here an SVG element - path, rect, group...) over time. Multiple animations can control the evolution of particular attribute: for example, one will tell the object to turn for 1 second starting at t=0 second and another to move across the document for 2 seconds starting at a later time. So we have this relation:&lt;br /&gt;
             1:n&lt;br /&gt;
  Element &amp;lt;-------&amp;gt; Animation&lt;br /&gt;
&lt;br /&gt;
For a given animation the element which is controlled is called the '''target''' element of the animation. The specific attribute/property which is controlled is called the '''target''' attribute/property.&lt;br /&gt;
&lt;br /&gt;
In fact, it's completely legal to have two animations that control the same attribute of the same element, and they can overlap in time: at any particular time there exists a ''stack'' of animations applying to a particular attribute, and SMIL defines the order in which each animation is applied.&lt;br /&gt;
&lt;br /&gt;
== Animation elements ==&lt;br /&gt;
&lt;br /&gt;
SVG defines 5 animation elements:&lt;br /&gt;
* '''animate'''&lt;br /&gt;
This element is used to animate any scalar attribute or property, such as the &amp;lt;code&amp;gt;width&amp;lt;/code&amp;gt; attribute of an svg:rect element or the CCS property &amp;lt;code&amp;gt;opacity&amp;lt;/code&amp;gt;&lt;br /&gt;
* '''animateMotion'''&lt;br /&gt;
This elements only controls the position of a SVG element, by telling it to follow a given path&lt;br /&gt;
* '''animateColor'''&lt;br /&gt;
This element controls the animation of color valued attributes and properties.&lt;br /&gt;
* '''animateTransform'''&lt;br /&gt;
This element controls the transformation which applies to the target element. It replaces or adds up to the &amp;lt;code&amp;gt;transform&amp;lt;/code&amp;gt; attribute of the element.&lt;br /&gt;
* '''set'''&lt;br /&gt;
This element is used to set a particular value for the target attribute during a specified time interval. It is mainly used for animating attributes which do not span a continuous domain, such as boolean values like the &amp;lt;code&amp;gt;visibility&amp;lt;/code&amp;gt; property.&lt;br /&gt;
&lt;br /&gt;
== Specifying the target element and property ==&lt;br /&gt;
&lt;br /&gt;
There are 2 ways to tell which element a given animation will target. The first one is to embed the [[#Animation elements|animation element]] as a child tag of the element to animate. Here is an example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;circle cx=&amp;quot;100px&amp;quot; cy=&amp;quot;100px&amp;quot; r=&amp;quot;20px&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;animate attributeName=&amp;quot;r&amp;quot; attributeType=&amp;quot;XML&amp;quot; begin=&amp;quot;1s&amp;quot; dur=&amp;quot;2s&amp;quot; from=&amp;quot;20px&amp;quot; to=&amp;quot;50px&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/circle&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;animate&amp;lt;/code&amp;gt; element targets the radius (&amp;lt;code&amp;gt;r&amp;lt;/code&amp;gt;) property of the parent &amp;lt;code&amp;gt;circle&amp;lt;/code&amp;gt; element. Starting 1 second after the document start, the radius will grow for 2 seconds from 20 pixels to 50 pixels. When nothing else is specified, the animation only applies in its interval of time, here [1-3] seconds; from 0 to 1 second and then from 3 second and after, the circle's radius is set back to its ''static'' attribute value, here 20 pixels.&lt;br /&gt;
&lt;br /&gt;
The other way to specify the target element is to reference it in via an &amp;lt;code&amp;gt;xlink:href&amp;lt;/code&amp;gt; attribute of the animation element. the previous animation could be written this way:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;circle id=&amp;quot;balloon&amp;quot; cx=&amp;quot;100px&amp;quot; cy=&amp;quot;100px&amp;quot; r=&amp;quot;20px&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;animate xlink:href=&amp;quot;#balloon&amp;quot; attributeName=&amp;quot;r&amp;quot; attributeType=&amp;quot;XML&amp;quot; begin=&amp;quot;1s&amp;quot; dur=&amp;quot;2s&amp;quot; from=&amp;quot;20px&amp;quot; to=&amp;quot;50px&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To specify which property or attribute of the target element is controlled, we use the two attributes &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;attributeType&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; explains itself, it's the name of the controlled attribute. &amp;lt;code&amp;gt;attributeType&amp;lt;/code&amp;gt; tells whether &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; is searched among the SVG attributes of the element (&amp;lt;code&amp;gt;attributeType=&amp;quot;XML&amp;quot;&amp;lt;/code&amp;gt;) or among the CSS properties of the element (&amp;lt;code&amp;gt;attributeType=&amp;quot;CSS&amp;quot;&amp;lt;/code&amp;gt;). [http://www.w3.org/TR/SVG11/animate.html#TargetElement (SPEC)]&lt;br /&gt;
&lt;br /&gt;
== Timing an animation ==&lt;br /&gt;
&lt;br /&gt;
The first thing to stress is that SMIL (and therefore SVG) animation is '''time-based''', as opposed to '''frame-based'''. '''Frame-based''' animation is something traditional animators are used to, because they actually draw each image of the animation on a separate celluloid sheet, and the timing is related to the rate of images per second the camera will capture. When animation is done on a computer, the animator doesn't draw every image but only some ''key'' images (or ''keyframes'') and then the animation software creates all the necessary images for him (the so-called ''in-betweens''). That means the animator can focus back to a (real-)time based timing. Each keyframe is positioned on a timeline with real time values (instead of frame numbers). Of course at the end the animation is discrete and there is a fixed number of images computed inbetween two keyframes, but the neat property of specifying keyframes at time position is that the final animation frame rate is scalable and the animator doesn't have to care about it anymore. He just tells the software to produce 24 images each second if he targets a theatre film or say 10 images per second for low-bandwidth web animation. The animator doesn't need to reposition the keyframes.&lt;br /&gt;
&lt;br /&gt;
=== In-betweening by interpolation ===&lt;br /&gt;
&lt;br /&gt;
Creating the inbetween images on a computer is done by mean of '''interpolation'''. Interpolation is a mathematical tool that can reconstruct a the continuous evolution of a parameter given a set of discrete values of this parameter over time.&lt;br /&gt;
The following image illustrates that. We know that some attribute A must take value A0, A1, A2 and A3 at times t0, t1, t2 and t3. The red curves is one of the possible continuous function that be used to compute inbetween values of A in the interval [t0, t3].&lt;br /&gt;
&lt;br /&gt;
[[Image:interpolation.png]]&lt;br /&gt;
&lt;br /&gt;
* The animation's time interval&lt;br /&gt;
The first aspect that characterizes an animation is the interval of time on which it applies: when does it begin, when does it end or how long does it run.&lt;br /&gt;
Any of the above mentioned [[#Animation elements|animation elements] accept the attributes &amp;lt;code&amp;gt;begin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;dur&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
There are many ways to define a particular point in time and this is what makes SMIL a very rich animation framework (see below). The simplest is to specify a clock-value which syntax is quite intuitive [http://www.w3.org/TR/SVG11/animate.html#ClockValueSyntax (SPEC)]. Depending on the combination of those 3 attributes, the interval of time of the animation will be [begin, end], [begin, begin+dur], [end-dur, end], etc.&lt;br /&gt;
&lt;br /&gt;
* The attribute values&lt;br /&gt;
To specify the values taken by the attribute over the time interval, one need to tell the value that the parameter must have at the begin and at the end of the interval. here again those values are specified by combinations of three attributes: &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;by&amp;lt;/code&amp;gt;. The attribute &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt; correspond to the begin value, the attribute &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; correspond to the end value. The attribute &amp;lt;code&amp;gt;by&amp;lt;/code&amp;gt; let you define either the initial and final values relative to the other one, that is to = from + by or from = to - by. The following image illusttrate this setup for our hypothetical attribute A&lt;br /&gt;
&lt;br /&gt;
[[Image:time_interval.png]]&lt;br /&gt;
&lt;br /&gt;
The values of A are simply interpolated '''linearly''' in between begin and end. This is the more simple form of '''animation function''' that can defined: by the two extremal pairs of (time, attribute value): (begin, from) and (end, to).&lt;br /&gt;
&lt;br /&gt;
=== More complex timing ===&lt;br /&gt;
&lt;br /&gt;
It's possible to specify a whole set of (keytime, keyvalue) pairs to define the animation function. Each item of the pairs are actually given separately:&lt;br /&gt;
* the set of attribute values (keyvalues) are given by the &amp;lt;code&amp;gt;values&amp;lt;/code&amp;gt; attribute.&lt;br /&gt;
* the set of time values (keytimes) are given by the &amp;lt;code&amp;gt;keyTimes&amp;lt;/code&amp;gt; attribute.&lt;br /&gt;
&lt;br /&gt;
Each set as the form of a semicolon-separated list of values. The thing to notice is that the keytimes are actually '''normalized to [0,1]''', which means that 0 maps to begin and 1 maps to end, and those values must start and end the list of keytimes. The image below illustrates all this:&lt;br /&gt;
&lt;br /&gt;
[[Image:time_interval2.png]]&lt;br /&gt;
&lt;br /&gt;
The keyTimes list can actually be omitted, in which case the keytimes are evenly distributed in the interval [0,1] (or equivalently, evenly in the interval [begin, end])&lt;br /&gt;
&lt;br /&gt;
The (keytime, keyvalue) pairs are joined by straight lines in the above graph, which means that '''linear interpolation''' is used for computing the inbetween values. &lt;br /&gt;
&lt;br /&gt;
When applied to the position of an object, linear interpolation results in un-natural robot-like motions (which may be the effect wanted). SMIL allows smoother animations to be defined by using '''spline-based interpolation''' between two (keytime, keyvalue) pairs. For each interval (t0, A0) - (t1, A1) a spline can be defined by two control points defining the tangents of the spline at t0 and t1. Those control points are passed in the attribute &amp;lt;code&amp;gt;keySplines&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[Image:spline_interpolation.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Two other interpolation modes are possible:&lt;br /&gt;
* '''discrete''': this is a degenerate form of interpolation, because the resulting animation function is not continuous. For each interval (t0,A0) - (t1, A1), the attribute value is set to A0 for the whole interval. It ''jumps'' to A1 right when t1 is reached and so on.&lt;br /&gt;
* '''paced''': in this interpolation mode, the attribute is interpolated so that its evolution over time has '''constant speed'''. Because the animation function is defined implicitly, the attribute &amp;lt;code&amp;gt;keyTimes&amp;lt;/code&amp;gt; is not taken into account. This mode is mainly useful for the &amp;lt;code&amp;gt;animateMotion&amp;lt;/code&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
=== Other aspects of animation ===&lt;br /&gt;
* repeating&lt;br /&gt;
* chaining animations.&lt;br /&gt;
* event based synchronisation&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
Examples showcasing some of the effects that can be achieved using procedural animation in SVG.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1px&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 1 --&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces on the floor: there are 6 motions here: fall, squeeze, squeeze-offset and bounce unsqueeze and unsqueeze-offset that are the revert version of 3 first. A classic animation trick is to start squeezing the ball a little before it touches the floor, expressed here by the synchronization &amp;lt;code&amp;gt;begin=fall.end - 0.1s&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td rowspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;path&lt;br /&gt;
   ...&lt;br /&gt;
   transform=&amp;quot;translate(0,4.5456868)&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;animateTransform&lt;br /&gt;
         type=&amp;quot;translate&amp;quot;&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot;&lt;br /&gt;
         from=&amp;quot;0, 0&amp;quot;&lt;br /&gt;
         to=&amp;quot;0, 136&amp;quot;&lt;br /&gt;
         dur=&amp;quot;1s&amp;quot;&lt;br /&gt;
         begin=&amp;quot;0s&amp;quot;&lt;br /&gt;
         attributeType=&amp;quot;XML&amp;quot;&lt;br /&gt;
         attributeName=&amp;quot;transform&amp;quot;&lt;br /&gt;
         id=&amp;quot;fall&amp;quot;&lt;br /&gt;
         keySplines=&amp;quot;0.5 0  0.8 0.5 &amp;quot;&lt;br /&gt;
         calcMode=&amp;quot;spline&amp;quot; /&amp;gt;&lt;br /&gt;
      &amp;lt;animateTransform&lt;br /&gt;
         id=&amp;quot;squeeze&amp;quot;&lt;br /&gt;
         type=&amp;quot;scale&amp;quot;&lt;br /&gt;
         from=&amp;quot;1,1&amp;quot;&lt;br /&gt;
         to=&amp;quot;1.1,0.9&amp;quot;&lt;br /&gt;
         begin=&amp;quot;fall.end-0.1s&amp;quot;&lt;br /&gt;
         attributeName=&amp;quot;transform&amp;quot;&lt;br /&gt;
         attributeType=&amp;quot;XML&amp;quot;&lt;br /&gt;
         dur=&amp;quot;0.2s&amp;quot;&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot; /&amp;gt;&lt;br /&gt;
      &amp;lt;animateTransform&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot;&lt;br /&gt;
         dur=&amp;quot;0.2s&amp;quot;&lt;br /&gt;
         attributeType=&amp;quot;XML&amp;quot;&lt;br /&gt;
         attributeName=&amp;quot;transform&amp;quot;&lt;br /&gt;
         begin=&amp;quot;fall.end-0.1s&amp;quot;&lt;br /&gt;
         to=&amp;quot;-13,0&amp;quot;&lt;br /&gt;
         from=&amp;quot;0,0&amp;quot;&lt;br /&gt;
         type=&amp;quot;translate&amp;quot;&lt;br /&gt;
         id=&amp;quot;squeeze-offset&amp;quot;&lt;br /&gt;
         accumulate=&amp;quot;sum&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball1.png]]&lt;br /&gt;
[http://wiki.inkscape.org/wiki/images/Bouncing_ball1.svg SVG file] |&lt;br /&gt;
[http://www.cdehais.fr/~tof/svg/bouncing_ball1.ogg ogg video]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 2 --&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces between two wall, following a path.&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td rowspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;path&lt;br /&gt;
       ...&lt;br /&gt;
       sodipodi:type=&amp;quot;arc&amp;quot;&lt;br /&gt;
       id=&amp;quot;ball&amp;quot; &lt;br /&gt;
       ... &lt;br /&gt;
&amp;gt;&lt;br /&gt;
      &amp;lt;animateMotion&lt;br /&gt;
         keyTimes=&amp;quot;0; 0.20; 1&amp;quot;&lt;br /&gt;
         keyPoints=&amp;quot;0; 0.33; 1&amp;quot;&lt;br /&gt;
         repeatCount=&amp;quot;indefinite&amp;quot;&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot;&lt;br /&gt;
         rotate=&amp;quot;0&amp;quot;&lt;br /&gt;
         begin=&amp;quot;0s&amp;quot;&lt;br /&gt;
         dur=&amp;quot;2s&amp;quot;&lt;br /&gt;
         calcMode=&amp;quot;linear&amp;quot;&lt;br /&gt;
         id=&amp;quot;animateMotion2680&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;mpath&lt;br /&gt;
           xlink:href=&amp;quot;#motion_path&amp;quot;&lt;br /&gt;
           id=&amp;quot;mpath2682&amp;quot; /&amp;gt;&lt;br /&gt;
      &amp;lt;/animateMotion&amp;gt;&lt;br /&gt;
&amp;lt;/path&amp;gt;&lt;br /&gt;
&amp;lt;path&lt;br /&gt;
   d=&amp;quot;M 82.080559,103.82375 ...&amp;quot;&lt;br /&gt;
   id=&amp;quot;motion_path&amp;quot; ... /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball2.png]]&lt;br /&gt;
[http://wiki.inkscape.org/wiki/images/Bouncing_ball2.svg SVG file] |&lt;br /&gt;
[http://www.cdehais.fr/~tof/svg/bouncing_ball2.ogg ogg video]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 3 --&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces between 2 walls. The motion is defined as a combination a of vertical translation and a horizontal translation. This works because the second animation has an &amp;lt;code&amp;gt;additive=&amp;quot;sum&amp;quot;&amp;lt;/code&amp;gt; attribute, so the corresponding matrix is composited with the matrix defined by the underlying animations.&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td rowspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
&amp;lt;!-- two animation sharing the same path --&amp;gt;&lt;br /&gt;
  &amp;lt;animateMotion&lt;br /&gt;
     id=&amp;quot;animateMotion2302&amp;quot;&lt;br /&gt;
     xlink:href=&amp;quot;#arrow2&amp;quot;&lt;br /&gt;
     dur=&amp;quot;4s&amp;quot;&lt;br /&gt;
     keyTimes=&amp;quot;0; 0.5; 1&amp;quot;&lt;br /&gt;
     keyPoints=&amp;quot;0; 1; 0&amp;quot;&lt;br /&gt;
     calcMode=&amp;quot;linear&amp;quot;&lt;br /&gt;
     repeatCount=&amp;quot;indefinite&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;mpath&lt;br /&gt;
       id=&amp;quot;mpath2305&amp;quot;&lt;br /&gt;
       xlink:href=&amp;quot;#horiz-bounce&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/animateMotion&amp;gt;&lt;br /&gt;
  &amp;lt;animateMotion&lt;br /&gt;
     calcMode=&amp;quot;linear&amp;quot;&lt;br /&gt;
     keyPoints=&amp;quot;0; 1; 0&amp;quot;&lt;br /&gt;
     keyTimes=&amp;quot;0; 0.5; 1&amp;quot;&lt;br /&gt;
     dur=&amp;quot;4s&amp;quot;&lt;br /&gt;
     xlink:href=&amp;quot;#ball&amp;quot;&lt;br /&gt;
     id=&amp;quot;animateMotion2309&amp;quot;&lt;br /&gt;
     repeatCount=&amp;quot;indefinite&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;mpath&lt;br /&gt;
       xlink:href=&amp;quot;#horiz-bounce&amp;quot;&lt;br /&gt;
       id=&amp;quot;mpath2311&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/animateMotion&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
  &amp;lt;animateMotion&lt;br /&gt;
     keySplines=&amp;quot;0.5 0 0.75 0.75, 0 0.5 0.5 0.75&amp;quot;&lt;br /&gt;
     keyPoints=&amp;quot;0;  1; 0&amp;quot;&lt;br /&gt;
     calcMode=&amp;quot;spline&amp;quot;&lt;br /&gt;
     keyTimes=&amp;quot;0;  0.5; 1&amp;quot;&lt;br /&gt;
     id=&amp;quot;animateMotion2298&amp;quot;&lt;br /&gt;
     begin=&amp;quot;0s&amp;quot;&lt;br /&gt;
     dur=&amp;quot;2s&amp;quot;&lt;br /&gt;
     xlink:href=&amp;quot;#ball&amp;quot;&lt;br /&gt;
     additive=&amp;quot;sum&amp;quot;&lt;br /&gt;
     repeatCount=&amp;quot;indefinite&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;mpath&lt;br /&gt;
       id=&amp;quot;mpath2300&amp;quot;&lt;br /&gt;
       xlink:href=&amp;quot;#vert-bounce&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/animateMotion&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball3.png]]&lt;br /&gt;
[http://wiki.inkscape.org/wiki/images/Bouncing_ball3.svg SVG file] |&lt;br /&gt;
[http://www.cdehais.fr/~tof/svg/bouncing_ball3.ogg ogg video]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Useful tools ==&lt;br /&gt;
&lt;br /&gt;
* [http://xmlgraphics.apache.org/batik/tools/browser.html Squiggle ], as part of [http://xmlgraphics.apache.org/batik/ Batik 1.7] has a nearly complete support for SMIL Animation. The [[#Examples|examples]] were all rendered using Squiggle.&lt;br /&gt;
* Inkscape ! I used the xml editor to manually add the animation elements for my test. It's a bit more cumbersome than editing the svg file in a text editor, but doing that in Inkscape eases the computation of key positions (just move the object around and read the position values).&lt;br /&gt;
&lt;br /&gt;
== Various thoughts ==&lt;br /&gt;
&lt;br /&gt;
* There is no direct way to specify a &amp;lt;b&amp;gt;''ping-pong'' animation&amp;lt;/b&amp;gt; in SVG, that is to tell an animation to go back in time when it reaches it's end. To implement this, I see 2 solutions:&lt;br /&gt;
**double the duration d of the animation (&amp;lt;code&amp;gt;dur&amp;lt;/code&amp;gt; attribute) et apply a scale and a symetry around t=0.5 to the animation function. For example the simple linear interpolation defined by &amp;lt;code&amp;gt;keyTimes=&amp;quot;0; 1&amp;quot;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;keyPoints=&amp;quot;0;1&amp;quot;&amp;lt;/code&amp;gt; becomes &amp;lt;code&amp;gt;keyTimes=&amp;quot;0; 0.5; 1&amp;quot;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;keyPoints=&amp;quot;0;1;0&amp;quot;&amp;lt;/code&amp;gt;. This doesn't work for &amp;lt;code&amp;gt;paced&amp;lt;/code&amp;gt; animation though (which make use of an implicit, user-agent dependent animation function).&lt;br /&gt;
** copy the original animation (call it e.g. &amp;lt;code&amp;gt;motion_forward&amp;lt;/code&amp;gt;) and swap the &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; values in the copy. Then specify &amp;lt;code&amp;gt;begin=&amp;quot;motion_forward.end&amp;quot;&amp;lt;/code&amp;gt; to tell the backward animation to start right at the end of the forward animation. This should work for every animation type.&lt;br /&gt;
&lt;br /&gt;
The question is: what maps best to a UI ?&lt;/div&gt;</summary>
		<author><name>ToF</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation&amp;diff=23694</id>
		<title>SVG Animation</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation&amp;diff=23694"/>
		<updated>2008-03-10T11:29:44Z</updated>

		<summary type="html">&lt;p&gt;ToF: /* More complex timing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is a '''work in progress'''. [[User:ToF|ToF]]&lt;br /&gt;
&lt;br /&gt;
== SVG Animation ==&lt;br /&gt;
&lt;br /&gt;
Animation in SVG is defined in the Animation Module of the [http://www.w3.org/TR/SVG11/animate.html SVG specification]. Animation in SVG conforms to the [http://www.w3.org/TR/2001/REC-smil-animation-20010904/ SMIL specification] (Synchronized Multimedia Integration Language) and extends it (SVG is said to be a ''host'' language of SMIL).&lt;br /&gt;
&lt;br /&gt;
Here I only focus on procedural animation and not programmatic animation (using a scripting language manipulating the DOM). &lt;br /&gt;
&lt;br /&gt;
In SMIL an animation is an object which defines the evolution of a given attribute of a given object (here an SVG element - path, rect, group...) over time. Multiple animations can control the evolution of particular attribute: for example, one will tell the object to turn for 1 second starting at t=0 second and another to move across the document for 2 seconds starting at a later time. So we have this relation:&lt;br /&gt;
             1:n&lt;br /&gt;
  Element &amp;lt;-------&amp;gt; Animation&lt;br /&gt;
&lt;br /&gt;
For a given animation the element which is controlled is called the '''target''' element of the animation. The specific attribute/property which is controlled is called the '''target''' attribute/property.&lt;br /&gt;
&lt;br /&gt;
In fact, it's completely legal to have two animations that control the same attribute of the same element, and they can overlap in time: at any particular time there exists a ''stack'' of animations applying to a particular attribute, and SMIL defines the order in which each animation is applied.&lt;br /&gt;
&lt;br /&gt;
== Animation elements ==&lt;br /&gt;
&lt;br /&gt;
SVG defines 5 animation elements:&lt;br /&gt;
* '''animate'''&lt;br /&gt;
This element is used to animate any scalar attribute or property, such as the &amp;lt;code&amp;gt;width&amp;lt;/code&amp;gt; attribute of an svg:rect element or the CCS property &amp;lt;code&amp;gt;opacity&amp;lt;/code&amp;gt;&lt;br /&gt;
* '''animateMotion'''&lt;br /&gt;
This elements only controls the position of a SVG element, by telling it to follow a given path&lt;br /&gt;
* '''animateColor'''&lt;br /&gt;
This element controls the animation of color valued attributes and properties.&lt;br /&gt;
* '''animateTransform'''&lt;br /&gt;
This element controls the transformation which applies to the target element. It replaces or adds up to the &amp;lt;code&amp;gt;transform&amp;lt;/code&amp;gt; attribute of the element.&lt;br /&gt;
* '''set'''&lt;br /&gt;
This element is used to set a particular value for the target attribute during a specified time interval. It is mainly used for animating attributes which do not span a continuous domain, such as boolean values like the &amp;lt;code&amp;gt;visibility&amp;lt;/code&amp;gt; property.&lt;br /&gt;
&lt;br /&gt;
== Specifying the target element and property ==&lt;br /&gt;
&lt;br /&gt;
There are 2 ways to tell which element a given animation will target. The first one is to embed the [[#Animation elements|animation element]] as a child tag of the element to animate. Here is an example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;circle cx=&amp;quot;100px&amp;quot; cy=&amp;quot;100px&amp;quot; r=&amp;quot;20px&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;animate attributeName=&amp;quot;r&amp;quot; attributeType=&amp;quot;XML&amp;quot; begin=&amp;quot;1s&amp;quot; dur=&amp;quot;2s&amp;quot; from=&amp;quot;20px&amp;quot; to=&amp;quot;50px&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/circle&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;animate&amp;lt;/code&amp;gt; element targets the radius (&amp;lt;code&amp;gt;r&amp;lt;/code&amp;gt;) property of the parent &amp;lt;code&amp;gt;circle&amp;lt;/code&amp;gt; element. Starting 1 second after the document start, the radius will grow for 2 seconds from 20 pixels to 50 pixels. When nothing else is specified, the animation only applies in its interval of time, here [1-3] seconds; from 0 to 1 second and then from 3 second and after, the circle's radius is set back to its ''static'' attribute value, here 20 pixels.&lt;br /&gt;
&lt;br /&gt;
The other way to specify the target element is to reference it in via an &amp;lt;code&amp;gt;xlink:href&amp;lt;/code&amp;gt; attribute of the animation element. the previous animation could be written this way:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;circle id=&amp;quot;balloon&amp;quot; cx=&amp;quot;100px&amp;quot; cy=&amp;quot;100px&amp;quot; r=&amp;quot;20px&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;animate xlink:href=&amp;quot;#balloon&amp;quot; attributeName=&amp;quot;r&amp;quot; attributeType=&amp;quot;XML&amp;quot; begin=&amp;quot;1s&amp;quot; dur=&amp;quot;2s&amp;quot; from=&amp;quot;20px&amp;quot; to=&amp;quot;50px&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To specify which property or attribute of the target element is controlled, we use the two attributes &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;attributeType&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; explains itself, it's the name of the controlled attribute. &amp;lt;code&amp;gt;attributeType&amp;lt;/code&amp;gt; tells whether &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; is searched among the SVG attributes of the element (&amp;lt;code&amp;gt;attributeType=&amp;quot;XML&amp;quot;&amp;lt;/code&amp;gt;) or among the CSS properties of the element (&amp;lt;code&amp;gt;attributeType=&amp;quot;CSS&amp;quot;&amp;lt;/code&amp;gt;). [http://www.w3.org/TR/SVG11/animate.html#TargetElement (SPEC)]&lt;br /&gt;
&lt;br /&gt;
== Timing an animation ==&lt;br /&gt;
&lt;br /&gt;
The first thing to stress is that SMIL (and therefore SVG) animation is '''time-based''', as opposed to '''frame-based'''. '''Frame-based''' animation is something traditional animators are used to, because they actually draw each image of the animation on a separate celluloid sheet, and the timing is related to the rate of images per second the camera will capture. When animation is done on a computer, the animator doesn't draw every image but only some ''key'' images (or ''keyframes'') and then the animation software creates all the necessary images for him (the so-called ''in-betweens''). That means the animator can focus back to a (real-)time based timing. Each keyframe is positioned on a timeline with real time values (instead of frame numbers). Of course at the end the animation is discrete and there is a fixed number of images computed inbetween two keyframes, but the neat property of specifying keyframes at time position is that the final animation frame rate is scalable and the animator doesn't have to care about it anymore. He just tells the software to produce 24 images each second if he targets a theatre film or say 10 images per second for low-bandwidth web animation. The animator doesn't need to reposition the keyframes.&lt;br /&gt;
&lt;br /&gt;
=== In-betweening by interpolation ===&lt;br /&gt;
&lt;br /&gt;
Creating the inbetween images on a computer is done by mean of '''interpolation'''. Interpolation is a mathematical tool that can reconstruct a the continuous evolution of a parameter given a set of discrete values of this parameter over time.&lt;br /&gt;
The following image illustrates that. We know that some attribute A must take value A0, A1, A2 and A3 at times t0, t1, t2 and t3. The red curves is one of the possible continuous function that be used to compute inbetween values of A in the interval [t0, t3].&lt;br /&gt;
&lt;br /&gt;
[[Image:interpolation.png]]&lt;br /&gt;
&lt;br /&gt;
* The animation's time interval&lt;br /&gt;
The first aspect that characterizes an animation is the interval of time on which it applies: when does it begin, when does it end or how long does it run.&lt;br /&gt;
Any of the above mentioned [[#Animation elements|animation elements] accept the attributes &amp;lt;code&amp;gt;begin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;dur&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
There are many ways to define a particular point in time and this is what makes SMIL a very rich animation framework (see below). The simplest is to specify a clock-value which syntax is quite intuitive [http://www.w3.org/TR/SVG11/animate.html#ClockValueSyntax (SPEC)]. Depending on the combination of those 3 attributes, the interval of time of the animation will be [begin, end], [begin, begin+dur], [end-dur, end], etc.&lt;br /&gt;
&lt;br /&gt;
* The attribute values&lt;br /&gt;
To specify the values taken by the attribute over the time interval, one need to tell the value that the parameter must have at the begin and at the end of the interval. here again those values are specified by combinations of three attributes: &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;by&amp;lt;/code&amp;gt;. The attribute &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt; correspond to the begin value, the attribute &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; correspond to the end value. The attribute &amp;lt;code&amp;gt;by&amp;lt;/code&amp;gt; let you define either the initial and final values relative to the other one, that is to = from + by or from = to - by. The following image illusttrate this setup for our hypothetical attribute A&lt;br /&gt;
&lt;br /&gt;
[[Image:time_interval.png]]&lt;br /&gt;
&lt;br /&gt;
The values of A are simply interpolated '''linearly''' in between begin and end. This is the more simple form of '''animation function''' that can defined: by the two extremal pairs of (time, attribute value): (begin, from) and (end, to).&lt;br /&gt;
&lt;br /&gt;
=== More complex timing ===&lt;br /&gt;
&lt;br /&gt;
It's possible to specify a whole set of (keytime, keyvalue) pairs to define the animation function. Each item of the pairs are actually given separately:&lt;br /&gt;
* the set of attribute values (keyvalues) are given by the &amp;lt;code&amp;gt;values&amp;lt;/code&amp;gt; attribute.&lt;br /&gt;
* the set of time values (keytimes) are given by the &amp;lt;code&amp;gt;keyTimes&amp;lt;/code&amp;gt; attribute.&lt;br /&gt;
&lt;br /&gt;
Each set as the form of a semicolon-separated list of values. The thing to notice is that the keytimes are actually '''normalized to [0,1]''', which means that 0 maps to begin and 1 maps to end, and those values must start and end the list of keytimes. The image below illustrates all this:&lt;br /&gt;
&lt;br /&gt;
[[Image:time_interval2.png]]&lt;br /&gt;
&lt;br /&gt;
The keyTimes list can actually be omitted, in which case the keytimes are evenly distributed in the interval [0,1] (or equivalently, evenly in the interval [begin, end])&lt;br /&gt;
&lt;br /&gt;
The (keytime, keyvalue) pairs are joined by straight lines in the above graph, which means that '''linear interpolation''' is used for computing the inbetween values. &lt;br /&gt;
&lt;br /&gt;
When applied to the position of an object, linear interpolation results in un-natural robot-like motions (which may be the effect wanted). SMIL allows smoother animations to be defined by using '''spline-based interpolation''' between two (keytime, keyvalue) pairs. For each interval (t0, A0) - (t1, A1) a spline can be defined by two control points defining the tangents of the spline at t0 and t1. Those control points are passed in the attribute &amp;lt;code&amp;gt;keySplines&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[Image:spline_interpolation.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Two other interpolation modes are possible:&lt;br /&gt;
* '''discrete''': this is a degenerate form of interpolation, because the resulting animation function is not continuous. For each interval (t0,A0) - (t1, A1), the attribute value is set to A0 for the whole interval. It ''jumps'' to A1 right when t1 is reached and so on.&lt;br /&gt;
* '''paced''': in this interpolation mode, the attribute is interpolated so that its evolution over time has '''constant speed'''. Because the animation function is defined implicitly, the attribute &amp;lt;code&amp;gt;keyTimes&amp;lt;/code&amp;gt; is not taken into account. This mode is mainly useful for the &amp;lt;code&amp;gt;animateMotion&amp;lt;/code&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
=== Other aspects of animation ===&lt;br /&gt;
* repeating&lt;br /&gt;
* chaining animations.&lt;br /&gt;
* event based synchronisation&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
Examples showcasing some of the effects that can be achieved using procedural animation in SVG.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1px&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 1 --&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces on the floor: there are 6 motions here: fall, squeeze, squeeze-offset and bounce unsqueeze and unsqueeze-offset that are the revert version of 3 first. A classic animation trick is to start squeezing the ball a little before it touches the floor, expressed here by the synchronization &amp;lt;code&amp;gt;begin=fall.end - 0.1s&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td rowspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;path&lt;br /&gt;
   ...&lt;br /&gt;
   transform=&amp;quot;translate(0,4.5456868)&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;animateTransform&lt;br /&gt;
         type=&amp;quot;translate&amp;quot;&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot;&lt;br /&gt;
         from=&amp;quot;0, 0&amp;quot;&lt;br /&gt;
         to=&amp;quot;0, 136&amp;quot;&lt;br /&gt;
         dur=&amp;quot;1s&amp;quot;&lt;br /&gt;
         begin=&amp;quot;0s&amp;quot;&lt;br /&gt;
         attributeType=&amp;quot;XML&amp;quot;&lt;br /&gt;
         attributeName=&amp;quot;transform&amp;quot;&lt;br /&gt;
         id=&amp;quot;fall&amp;quot;&lt;br /&gt;
         keySplines=&amp;quot;0.5 0  0.8 0.5 &amp;quot;&lt;br /&gt;
         calcMode=&amp;quot;spline&amp;quot; /&amp;gt;&lt;br /&gt;
      &amp;lt;animateTransform&lt;br /&gt;
         id=&amp;quot;squeeze&amp;quot;&lt;br /&gt;
         type=&amp;quot;scale&amp;quot;&lt;br /&gt;
         from=&amp;quot;1,1&amp;quot;&lt;br /&gt;
         to=&amp;quot;1.1,0.9&amp;quot;&lt;br /&gt;
         begin=&amp;quot;fall.end-0.1s&amp;quot;&lt;br /&gt;
         attributeName=&amp;quot;transform&amp;quot;&lt;br /&gt;
         attributeType=&amp;quot;XML&amp;quot;&lt;br /&gt;
         dur=&amp;quot;0.2s&amp;quot;&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot; /&amp;gt;&lt;br /&gt;
      &amp;lt;animateTransform&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot;&lt;br /&gt;
         dur=&amp;quot;0.2s&amp;quot;&lt;br /&gt;
         attributeType=&amp;quot;XML&amp;quot;&lt;br /&gt;
         attributeName=&amp;quot;transform&amp;quot;&lt;br /&gt;
         begin=&amp;quot;fall.end-0.1s&amp;quot;&lt;br /&gt;
         to=&amp;quot;-13,0&amp;quot;&lt;br /&gt;
         from=&amp;quot;0,0&amp;quot;&lt;br /&gt;
         type=&amp;quot;translate&amp;quot;&lt;br /&gt;
         id=&amp;quot;squeeze-offset&amp;quot;&lt;br /&gt;
         accumulate=&amp;quot;sum&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball1.png]]&lt;br /&gt;
[http://wiki.inkscape.org/wiki/images/Bouncing_ball1.svg SVG file] |&lt;br /&gt;
[http://www.cdehais.fr/~tof/svg/bouncing_ball1.ogg ogg video]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 2 --&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces between two wall, following a path.&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td rowspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;path&lt;br /&gt;
       ...&lt;br /&gt;
       sodipodi:type=&amp;quot;arc&amp;quot;&lt;br /&gt;
       id=&amp;quot;ball&amp;quot; &lt;br /&gt;
       ... &lt;br /&gt;
&amp;gt;&lt;br /&gt;
      &amp;lt;animateMotion&lt;br /&gt;
         keyTimes=&amp;quot;0; 0.20; 1&amp;quot;&lt;br /&gt;
         keyPoints=&amp;quot;0; 0.33; 1&amp;quot;&lt;br /&gt;
         repeatCount=&amp;quot;indefinite&amp;quot;&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot;&lt;br /&gt;
         rotate=&amp;quot;0&amp;quot;&lt;br /&gt;
         begin=&amp;quot;0s&amp;quot;&lt;br /&gt;
         dur=&amp;quot;2s&amp;quot;&lt;br /&gt;
         calcMode=&amp;quot;linear&amp;quot;&lt;br /&gt;
         id=&amp;quot;animateMotion2680&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;mpath&lt;br /&gt;
           xlink:href=&amp;quot;#motion_path&amp;quot;&lt;br /&gt;
           id=&amp;quot;mpath2682&amp;quot; /&amp;gt;&lt;br /&gt;
      &amp;lt;/animateMotion&amp;gt;&lt;br /&gt;
&amp;lt;/path&amp;gt;&lt;br /&gt;
&amp;lt;path&lt;br /&gt;
   d=&amp;quot;M 82.080559,103.82375 ...&amp;quot;&lt;br /&gt;
   id=&amp;quot;motion_path&amp;quot; ... /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball2.png]]&lt;br /&gt;
[http://wiki.inkscape.org/wiki/images/Bouncing_ball2.svg SVG file] |&lt;br /&gt;
[http://www.cdehais.fr/~tof/svg/bouncing_ball2.ogg ogg video]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 3 --&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces between 2 walls. The motion is defined as a combination a of vertical translation and a horizontal translation. This works because the second animation has an &amp;lt;code&amp;gt;additive=&amp;quot;sum&amp;quot;&amp;lt;/code&amp;gt; attribute, so the corresponding matrix is composited with the matrix defined by the underlying animations.&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td rowspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
&amp;lt;!-- two animation sharing the same path --&amp;gt;&lt;br /&gt;
  &amp;lt;animateMotion&lt;br /&gt;
     id=&amp;quot;animateMotion2302&amp;quot;&lt;br /&gt;
     xlink:href=&amp;quot;#arrow2&amp;quot;&lt;br /&gt;
     dur=&amp;quot;4s&amp;quot;&lt;br /&gt;
     keyTimes=&amp;quot;0; 0.5; 1&amp;quot;&lt;br /&gt;
     keyPoints=&amp;quot;0; 1; 0&amp;quot;&lt;br /&gt;
     calcMode=&amp;quot;linear&amp;quot;&lt;br /&gt;
     repeatCount=&amp;quot;indefinite&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;mpath&lt;br /&gt;
       id=&amp;quot;mpath2305&amp;quot;&lt;br /&gt;
       xlink:href=&amp;quot;#horiz-bounce&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/animateMotion&amp;gt;&lt;br /&gt;
  &amp;lt;animateMotion&lt;br /&gt;
     calcMode=&amp;quot;linear&amp;quot;&lt;br /&gt;
     keyPoints=&amp;quot;0; 1; 0&amp;quot;&lt;br /&gt;
     keyTimes=&amp;quot;0; 0.5; 1&amp;quot;&lt;br /&gt;
     dur=&amp;quot;4s&amp;quot;&lt;br /&gt;
     xlink:href=&amp;quot;#ball&amp;quot;&lt;br /&gt;
     id=&amp;quot;animateMotion2309&amp;quot;&lt;br /&gt;
     repeatCount=&amp;quot;indefinite&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;mpath&lt;br /&gt;
       xlink:href=&amp;quot;#horiz-bounce&amp;quot;&lt;br /&gt;
       id=&amp;quot;mpath2311&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/animateMotion&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
  &amp;lt;animateMotion&lt;br /&gt;
     keySplines=&amp;quot;0.5 0 0.75 0.75, 0 0.5 0.5 0.75&amp;quot;&lt;br /&gt;
     keyPoints=&amp;quot;0;  1; 0&amp;quot;&lt;br /&gt;
     calcMode=&amp;quot;spline&amp;quot;&lt;br /&gt;
     keyTimes=&amp;quot;0;  0.5; 1&amp;quot;&lt;br /&gt;
     id=&amp;quot;animateMotion2298&amp;quot;&lt;br /&gt;
     begin=&amp;quot;0s&amp;quot;&lt;br /&gt;
     dur=&amp;quot;2s&amp;quot;&lt;br /&gt;
     xlink:href=&amp;quot;#ball&amp;quot;&lt;br /&gt;
     additive=&amp;quot;sum&amp;quot;&lt;br /&gt;
     repeatCount=&amp;quot;indefinite&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;mpath&lt;br /&gt;
       id=&amp;quot;mpath2300&amp;quot;&lt;br /&gt;
       xlink:href=&amp;quot;#vert-bounce&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/animateMotion&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball3.png]]&lt;br /&gt;
[http://wiki.inkscape.org/wiki/images/Bouncing_ball3.svg SVG file] |&lt;br /&gt;
[http://www.cdehais.fr/~tof/svg/bouncing_ball3.ogg ogg video]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Useful tools ==&lt;br /&gt;
&lt;br /&gt;
* [http://xmlgraphics.apache.org/batik/tools/browser.html Squiggle ], as part of [http://xmlgraphics.apache.org/batik/ Batik 1.7] has a nearly complete support for SMIL Animation. The [[#Examples|examples]] were all rendered using Squiggle.&lt;br /&gt;
* Inkscape ! I used the xml editor to manually add the animation elements for my test. It's a bit more cumbersome than editing the svg file in a text editor, but doing that in Inkscape eases the computation of key positions (just move the object around and read the position values).&lt;br /&gt;
&lt;br /&gt;
== Various thoughts ==&lt;br /&gt;
&lt;br /&gt;
* There is no direct way to specify a &amp;lt;b&amp;gt;''ping-pong'' animation&amp;lt;/b&amp;gt; in SVG, that is to tell an animation to go back in time when it reaches it's end. To implement this, I see 2 solutions:&lt;br /&gt;
**double the duration d of the animation (&amp;lt;code&amp;gt;dur&amp;lt;/code&amp;gt; attribute) et apply a scale and a symetry around t=0.5 to the animation function. For example the simple linear interpolation defined by &amp;lt;code&amp;gt;keyTimes=&amp;quot;0; 1&amp;quot;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;keyPoints=&amp;quot;0;1&amp;quot;&amp;lt;/code&amp;gt; becomes &amp;lt;code&amp;gt;keyTimes=&amp;quot;0; 0.5; 1&amp;quot;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;keyPoints=&amp;quot;0;1;0&amp;quot;&amp;lt;/code&amp;gt;. This doesn't work for &amp;lt;code&amp;gt;paced&amp;lt;/code&amp;gt; animation though (which make use of an implicit, user-agent dependent animation function).&lt;br /&gt;
** copy the original animation (call it e.g. &amp;lt;code&amp;gt;motion_forward&amp;lt;/code&amp;gt;) and swap the &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; values in the copy. Then specify &amp;lt;code&amp;gt;begin=&amp;quot;motion_forward.end&amp;quot;&amp;lt;/code&amp;gt; to tell the backward animation to start right at the end of the forward animation. This should work for every animation type.&lt;br /&gt;
&lt;br /&gt;
The question is: what maps best to a UI ?&lt;/div&gt;</summary>
		<author><name>ToF</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation&amp;diff=23684</id>
		<title>SVG Animation</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation&amp;diff=23684"/>
		<updated>2008-03-10T11:29:09Z</updated>

		<summary type="html">&lt;p&gt;ToF: /* More complex timing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is a '''work in progress'''. [[User:ToF|ToF]]&lt;br /&gt;
&lt;br /&gt;
== SVG Animation ==&lt;br /&gt;
&lt;br /&gt;
Animation in SVG is defined in the Animation Module of the [http://www.w3.org/TR/SVG11/animate.html SVG specification]. Animation in SVG conforms to the [http://www.w3.org/TR/2001/REC-smil-animation-20010904/ SMIL specification] (Synchronized Multimedia Integration Language) and extends it (SVG is said to be a ''host'' language of SMIL).&lt;br /&gt;
&lt;br /&gt;
Here I only focus on procedural animation and not programmatic animation (using a scripting language manipulating the DOM). &lt;br /&gt;
&lt;br /&gt;
In SMIL an animation is an object which defines the evolution of a given attribute of a given object (here an SVG element - path, rect, group...) over time. Multiple animations can control the evolution of particular attribute: for example, one will tell the object to turn for 1 second starting at t=0 second and another to move across the document for 2 seconds starting at a later time. So we have this relation:&lt;br /&gt;
             1:n&lt;br /&gt;
  Element &amp;lt;-------&amp;gt; Animation&lt;br /&gt;
&lt;br /&gt;
For a given animation the element which is controlled is called the '''target''' element of the animation. The specific attribute/property which is controlled is called the '''target''' attribute/property.&lt;br /&gt;
&lt;br /&gt;
In fact, it's completely legal to have two animations that control the same attribute of the same element, and they can overlap in time: at any particular time there exists a ''stack'' of animations applying to a particular attribute, and SMIL defines the order in which each animation is applied.&lt;br /&gt;
&lt;br /&gt;
== Animation elements ==&lt;br /&gt;
&lt;br /&gt;
SVG defines 5 animation elements:&lt;br /&gt;
* '''animate'''&lt;br /&gt;
This element is used to animate any scalar attribute or property, such as the &amp;lt;code&amp;gt;width&amp;lt;/code&amp;gt; attribute of an svg:rect element or the CCS property &amp;lt;code&amp;gt;opacity&amp;lt;/code&amp;gt;&lt;br /&gt;
* '''animateMotion'''&lt;br /&gt;
This elements only controls the position of a SVG element, by telling it to follow a given path&lt;br /&gt;
* '''animateColor'''&lt;br /&gt;
This element controls the animation of color valued attributes and properties.&lt;br /&gt;
* '''animateTransform'''&lt;br /&gt;
This element controls the transformation which applies to the target element. It replaces or adds up to the &amp;lt;code&amp;gt;transform&amp;lt;/code&amp;gt; attribute of the element.&lt;br /&gt;
* '''set'''&lt;br /&gt;
This element is used to set a particular value for the target attribute during a specified time interval. It is mainly used for animating attributes which do not span a continuous domain, such as boolean values like the &amp;lt;code&amp;gt;visibility&amp;lt;/code&amp;gt; property.&lt;br /&gt;
&lt;br /&gt;
== Specifying the target element and property ==&lt;br /&gt;
&lt;br /&gt;
There are 2 ways to tell which element a given animation will target. The first one is to embed the [[#Animation elements|animation element]] as a child tag of the element to animate. Here is an example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;circle cx=&amp;quot;100px&amp;quot; cy=&amp;quot;100px&amp;quot; r=&amp;quot;20px&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;animate attributeName=&amp;quot;r&amp;quot; attributeType=&amp;quot;XML&amp;quot; begin=&amp;quot;1s&amp;quot; dur=&amp;quot;2s&amp;quot; from=&amp;quot;20px&amp;quot; to=&amp;quot;50px&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/circle&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;animate&amp;lt;/code&amp;gt; element targets the radius (&amp;lt;code&amp;gt;r&amp;lt;/code&amp;gt;) property of the parent &amp;lt;code&amp;gt;circle&amp;lt;/code&amp;gt; element. Starting 1 second after the document start, the radius will grow for 2 seconds from 20 pixels to 50 pixels. When nothing else is specified, the animation only applies in its interval of time, here [1-3] seconds; from 0 to 1 second and then from 3 second and after, the circle's radius is set back to its ''static'' attribute value, here 20 pixels.&lt;br /&gt;
&lt;br /&gt;
The other way to specify the target element is to reference it in via an &amp;lt;code&amp;gt;xlink:href&amp;lt;/code&amp;gt; attribute of the animation element. the previous animation could be written this way:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;circle id=&amp;quot;balloon&amp;quot; cx=&amp;quot;100px&amp;quot; cy=&amp;quot;100px&amp;quot; r=&amp;quot;20px&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;animate xlink:href=&amp;quot;#balloon&amp;quot; attributeName=&amp;quot;r&amp;quot; attributeType=&amp;quot;XML&amp;quot; begin=&amp;quot;1s&amp;quot; dur=&amp;quot;2s&amp;quot; from=&amp;quot;20px&amp;quot; to=&amp;quot;50px&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To specify which property or attribute of the target element is controlled, we use the two attributes &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;attributeType&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; explains itself, it's the name of the controlled attribute. &amp;lt;code&amp;gt;attributeType&amp;lt;/code&amp;gt; tells whether &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; is searched among the SVG attributes of the element (&amp;lt;code&amp;gt;attributeType=&amp;quot;XML&amp;quot;&amp;lt;/code&amp;gt;) or among the CSS properties of the element (&amp;lt;code&amp;gt;attributeType=&amp;quot;CSS&amp;quot;&amp;lt;/code&amp;gt;). [http://www.w3.org/TR/SVG11/animate.html#TargetElement (SPEC)]&lt;br /&gt;
&lt;br /&gt;
== Timing an animation ==&lt;br /&gt;
&lt;br /&gt;
The first thing to stress is that SMIL (and therefore SVG) animation is '''time-based''', as opposed to '''frame-based'''. '''Frame-based''' animation is something traditional animators are used to, because they actually draw each image of the animation on a separate celluloid sheet, and the timing is related to the rate of images per second the camera will capture. When animation is done on a computer, the animator doesn't draw every image but only some ''key'' images (or ''keyframes'') and then the animation software creates all the necessary images for him (the so-called ''in-betweens''). That means the animator can focus back to a (real-)time based timing. Each keyframe is positioned on a timeline with real time values (instead of frame numbers). Of course at the end the animation is discrete and there is a fixed number of images computed inbetween two keyframes, but the neat property of specifying keyframes at time position is that the final animation frame rate is scalable and the animator doesn't have to care about it anymore. He just tells the software to produce 24 images each second if he targets a theatre film or say 10 images per second for low-bandwidth web animation. The animator doesn't need to reposition the keyframes.&lt;br /&gt;
&lt;br /&gt;
=== In-betweening by interpolation ===&lt;br /&gt;
&lt;br /&gt;
Creating the inbetween images on a computer is done by mean of '''interpolation'''. Interpolation is a mathematical tool that can reconstruct a the continuous evolution of a parameter given a set of discrete values of this parameter over time.&lt;br /&gt;
The following image illustrates that. We know that some attribute A must take value A0, A1, A2 and A3 at times t0, t1, t2 and t3. The red curves is one of the possible continuous function that be used to compute inbetween values of A in the interval [t0, t3].&lt;br /&gt;
&lt;br /&gt;
[[Image:interpolation.png]]&lt;br /&gt;
&lt;br /&gt;
* The animation's time interval&lt;br /&gt;
The first aspect that characterizes an animation is the interval of time on which it applies: when does it begin, when does it end or how long does it run.&lt;br /&gt;
Any of the above mentioned [[#Animation elements|animation elements] accept the attributes &amp;lt;code&amp;gt;begin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;dur&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
There are many ways to define a particular point in time and this is what makes SMIL a very rich animation framework (see below). The simplest is to specify a clock-value which syntax is quite intuitive [http://www.w3.org/TR/SVG11/animate.html#ClockValueSyntax (SPEC)]. Depending on the combination of those 3 attributes, the interval of time of the animation will be [begin, end], [begin, begin+dur], [end-dur, end], etc.&lt;br /&gt;
&lt;br /&gt;
* The attribute values&lt;br /&gt;
To specify the values taken by the attribute over the time interval, one need to tell the value that the parameter must have at the begin and at the end of the interval. here again those values are specified by combinations of three attributes: &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;by&amp;lt;/code&amp;gt;. The attribute &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt; correspond to the begin value, the attribute &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; correspond to the end value. The attribute &amp;lt;code&amp;gt;by&amp;lt;/code&amp;gt; let you define either the initial and final values relative to the other one, that is to = from + by or from = to - by. The following image illusttrate this setup for our hypothetical attribute A&lt;br /&gt;
&lt;br /&gt;
[[Image:time_interval.png]]&lt;br /&gt;
&lt;br /&gt;
The values of A are simply interpolated '''linearly''' in between begin and end. This is the more simple form of '''animation function''' that can defined: by the two extremal pairs of (time, attribute value): (begin, from) and (end, to).&lt;br /&gt;
&lt;br /&gt;
=== More complex timing ===&lt;br /&gt;
&lt;br /&gt;
It's possible to specify a whole set of (keytime, keyvalue) pairs to define the animation function. Each item of the pairs are actually given separately:&lt;br /&gt;
* the set of attribute values (keyvalues) are given by the &amp;lt;code&amp;gt;values&amp;lt;/code&amp;gt; attribute.&lt;br /&gt;
* the set of time values (keytimes) are given by the &amp;lt;code&amp;gt;keyTimes&amp;lt;/code&amp;gt; attribute.&lt;br /&gt;
&lt;br /&gt;
Each set as the form of a semicolon-separated list of values. The thing to notice is that the keytimes are actually '''normalized to [0,1]''', which means that 0 maps to begin and 1 maps to end, and those values must start and end the list of keytimes. The image below illustrates all this:&lt;br /&gt;
&lt;br /&gt;
[[Image:time_interval2.png]]&lt;br /&gt;
&lt;br /&gt;
The keyTimes list can actually be omitted, in which case the keytimes are evenly distributed in the interval [0,1] (or equivalently, evenly in the interval [begin, end])&lt;br /&gt;
&lt;br /&gt;
The (keytime, keyvalue) pairs are joined by straight lines in the above graph, which means that '''linear interpolation''' is used for computing the inbetween values. &lt;br /&gt;
&lt;br /&gt;
When applied to the position of an object, linear interpolation results in un-natural robot-like motions (which may be the effect wanted). SMIL allows smoother animations to be defined by using '''spline-based interpolation''' between two (keytime, keyvalue) pairs. For each interval (t0, A0) - (t1, A1) a spline can be defined by two control points defining the tangents of the spline at t0 and t1. Those control points are passed in the attribute &amp;lt;code&amp;gt;keySplines&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[Image:spline_interpolation.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Two other interpolation modes are possible:&lt;br /&gt;
* '''discrete''': this is a degenerate form of interpolation, because the resulting animation function is not continuous. For each interval (t0,v0) - (t1, v1), the attribute value is set to v0 for the whole interval. It ''jumps'' to v1 right when t1 is reached and so on.&lt;br /&gt;
* '''paced''': in this interpolation mode, the attribute is interpolated so that its evolution over time has '''constant speed'''. Because the animation function is defined implicitly, the attribute &amp;lt;code&amp;gt;keyTimes&amp;lt;/code&amp;gt; is not taken into account. This mode is mainly useful for the &amp;lt;code&amp;gt;animateMotion&amp;lt;/code&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
=== Other aspects of animation ===&lt;br /&gt;
* repeating&lt;br /&gt;
* chaining animations.&lt;br /&gt;
* event based synchronisation&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
Examples showcasing some of the effects that can be achieved using procedural animation in SVG.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1px&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 1 --&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces on the floor: there are 6 motions here: fall, squeeze, squeeze-offset and bounce unsqueeze and unsqueeze-offset that are the revert version of 3 first. A classic animation trick is to start squeezing the ball a little before it touches the floor, expressed here by the synchronization &amp;lt;code&amp;gt;begin=fall.end - 0.1s&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td rowspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;path&lt;br /&gt;
   ...&lt;br /&gt;
   transform=&amp;quot;translate(0,4.5456868)&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;animateTransform&lt;br /&gt;
         type=&amp;quot;translate&amp;quot;&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot;&lt;br /&gt;
         from=&amp;quot;0, 0&amp;quot;&lt;br /&gt;
         to=&amp;quot;0, 136&amp;quot;&lt;br /&gt;
         dur=&amp;quot;1s&amp;quot;&lt;br /&gt;
         begin=&amp;quot;0s&amp;quot;&lt;br /&gt;
         attributeType=&amp;quot;XML&amp;quot;&lt;br /&gt;
         attributeName=&amp;quot;transform&amp;quot;&lt;br /&gt;
         id=&amp;quot;fall&amp;quot;&lt;br /&gt;
         keySplines=&amp;quot;0.5 0  0.8 0.5 &amp;quot;&lt;br /&gt;
         calcMode=&amp;quot;spline&amp;quot; /&amp;gt;&lt;br /&gt;
      &amp;lt;animateTransform&lt;br /&gt;
         id=&amp;quot;squeeze&amp;quot;&lt;br /&gt;
         type=&amp;quot;scale&amp;quot;&lt;br /&gt;
         from=&amp;quot;1,1&amp;quot;&lt;br /&gt;
         to=&amp;quot;1.1,0.9&amp;quot;&lt;br /&gt;
         begin=&amp;quot;fall.end-0.1s&amp;quot;&lt;br /&gt;
         attributeName=&amp;quot;transform&amp;quot;&lt;br /&gt;
         attributeType=&amp;quot;XML&amp;quot;&lt;br /&gt;
         dur=&amp;quot;0.2s&amp;quot;&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot; /&amp;gt;&lt;br /&gt;
      &amp;lt;animateTransform&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot;&lt;br /&gt;
         dur=&amp;quot;0.2s&amp;quot;&lt;br /&gt;
         attributeType=&amp;quot;XML&amp;quot;&lt;br /&gt;
         attributeName=&amp;quot;transform&amp;quot;&lt;br /&gt;
         begin=&amp;quot;fall.end-0.1s&amp;quot;&lt;br /&gt;
         to=&amp;quot;-13,0&amp;quot;&lt;br /&gt;
         from=&amp;quot;0,0&amp;quot;&lt;br /&gt;
         type=&amp;quot;translate&amp;quot;&lt;br /&gt;
         id=&amp;quot;squeeze-offset&amp;quot;&lt;br /&gt;
         accumulate=&amp;quot;sum&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball1.png]]&lt;br /&gt;
[http://wiki.inkscape.org/wiki/images/Bouncing_ball1.svg SVG file] |&lt;br /&gt;
[http://www.cdehais.fr/~tof/svg/bouncing_ball1.ogg ogg video]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 2 --&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces between two wall, following a path.&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td rowspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;path&lt;br /&gt;
       ...&lt;br /&gt;
       sodipodi:type=&amp;quot;arc&amp;quot;&lt;br /&gt;
       id=&amp;quot;ball&amp;quot; &lt;br /&gt;
       ... &lt;br /&gt;
&amp;gt;&lt;br /&gt;
      &amp;lt;animateMotion&lt;br /&gt;
         keyTimes=&amp;quot;0; 0.20; 1&amp;quot;&lt;br /&gt;
         keyPoints=&amp;quot;0; 0.33; 1&amp;quot;&lt;br /&gt;
         repeatCount=&amp;quot;indefinite&amp;quot;&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot;&lt;br /&gt;
         rotate=&amp;quot;0&amp;quot;&lt;br /&gt;
         begin=&amp;quot;0s&amp;quot;&lt;br /&gt;
         dur=&amp;quot;2s&amp;quot;&lt;br /&gt;
         calcMode=&amp;quot;linear&amp;quot;&lt;br /&gt;
         id=&amp;quot;animateMotion2680&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;mpath&lt;br /&gt;
           xlink:href=&amp;quot;#motion_path&amp;quot;&lt;br /&gt;
           id=&amp;quot;mpath2682&amp;quot; /&amp;gt;&lt;br /&gt;
      &amp;lt;/animateMotion&amp;gt;&lt;br /&gt;
&amp;lt;/path&amp;gt;&lt;br /&gt;
&amp;lt;path&lt;br /&gt;
   d=&amp;quot;M 82.080559,103.82375 ...&amp;quot;&lt;br /&gt;
   id=&amp;quot;motion_path&amp;quot; ... /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball2.png]]&lt;br /&gt;
[http://wiki.inkscape.org/wiki/images/Bouncing_ball2.svg SVG file] |&lt;br /&gt;
[http://www.cdehais.fr/~tof/svg/bouncing_ball2.ogg ogg video]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 3 --&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces between 2 walls. The motion is defined as a combination a of vertical translation and a horizontal translation. This works because the second animation has an &amp;lt;code&amp;gt;additive=&amp;quot;sum&amp;quot;&amp;lt;/code&amp;gt; attribute, so the corresponding matrix is composited with the matrix defined by the underlying animations.&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td rowspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
&amp;lt;!-- two animation sharing the same path --&amp;gt;&lt;br /&gt;
  &amp;lt;animateMotion&lt;br /&gt;
     id=&amp;quot;animateMotion2302&amp;quot;&lt;br /&gt;
     xlink:href=&amp;quot;#arrow2&amp;quot;&lt;br /&gt;
     dur=&amp;quot;4s&amp;quot;&lt;br /&gt;
     keyTimes=&amp;quot;0; 0.5; 1&amp;quot;&lt;br /&gt;
     keyPoints=&amp;quot;0; 1; 0&amp;quot;&lt;br /&gt;
     calcMode=&amp;quot;linear&amp;quot;&lt;br /&gt;
     repeatCount=&amp;quot;indefinite&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;mpath&lt;br /&gt;
       id=&amp;quot;mpath2305&amp;quot;&lt;br /&gt;
       xlink:href=&amp;quot;#horiz-bounce&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/animateMotion&amp;gt;&lt;br /&gt;
  &amp;lt;animateMotion&lt;br /&gt;
     calcMode=&amp;quot;linear&amp;quot;&lt;br /&gt;
     keyPoints=&amp;quot;0; 1; 0&amp;quot;&lt;br /&gt;
     keyTimes=&amp;quot;0; 0.5; 1&amp;quot;&lt;br /&gt;
     dur=&amp;quot;4s&amp;quot;&lt;br /&gt;
     xlink:href=&amp;quot;#ball&amp;quot;&lt;br /&gt;
     id=&amp;quot;animateMotion2309&amp;quot;&lt;br /&gt;
     repeatCount=&amp;quot;indefinite&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;mpath&lt;br /&gt;
       xlink:href=&amp;quot;#horiz-bounce&amp;quot;&lt;br /&gt;
       id=&amp;quot;mpath2311&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/animateMotion&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
  &amp;lt;animateMotion&lt;br /&gt;
     keySplines=&amp;quot;0.5 0 0.75 0.75, 0 0.5 0.5 0.75&amp;quot;&lt;br /&gt;
     keyPoints=&amp;quot;0;  1; 0&amp;quot;&lt;br /&gt;
     calcMode=&amp;quot;spline&amp;quot;&lt;br /&gt;
     keyTimes=&amp;quot;0;  0.5; 1&amp;quot;&lt;br /&gt;
     id=&amp;quot;animateMotion2298&amp;quot;&lt;br /&gt;
     begin=&amp;quot;0s&amp;quot;&lt;br /&gt;
     dur=&amp;quot;2s&amp;quot;&lt;br /&gt;
     xlink:href=&amp;quot;#ball&amp;quot;&lt;br /&gt;
     additive=&amp;quot;sum&amp;quot;&lt;br /&gt;
     repeatCount=&amp;quot;indefinite&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;mpath&lt;br /&gt;
       id=&amp;quot;mpath2300&amp;quot;&lt;br /&gt;
       xlink:href=&amp;quot;#vert-bounce&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/animateMotion&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball3.png]]&lt;br /&gt;
[http://wiki.inkscape.org/wiki/images/Bouncing_ball3.svg SVG file] |&lt;br /&gt;
[http://www.cdehais.fr/~tof/svg/bouncing_ball3.ogg ogg video]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Useful tools ==&lt;br /&gt;
&lt;br /&gt;
* [http://xmlgraphics.apache.org/batik/tools/browser.html Squiggle ], as part of [http://xmlgraphics.apache.org/batik/ Batik 1.7] has a nearly complete support for SMIL Animation. The [[#Examples|examples]] were all rendered using Squiggle.&lt;br /&gt;
* Inkscape ! I used the xml editor to manually add the animation elements for my test. It's a bit more cumbersome than editing the svg file in a text editor, but doing that in Inkscape eases the computation of key positions (just move the object around and read the position values).&lt;br /&gt;
&lt;br /&gt;
== Various thoughts ==&lt;br /&gt;
&lt;br /&gt;
* There is no direct way to specify a &amp;lt;b&amp;gt;''ping-pong'' animation&amp;lt;/b&amp;gt; in SVG, that is to tell an animation to go back in time when it reaches it's end. To implement this, I see 2 solutions:&lt;br /&gt;
**double the duration d of the animation (&amp;lt;code&amp;gt;dur&amp;lt;/code&amp;gt; attribute) et apply a scale and a symetry around t=0.5 to the animation function. For example the simple linear interpolation defined by &amp;lt;code&amp;gt;keyTimes=&amp;quot;0; 1&amp;quot;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;keyPoints=&amp;quot;0;1&amp;quot;&amp;lt;/code&amp;gt; becomes &amp;lt;code&amp;gt;keyTimes=&amp;quot;0; 0.5; 1&amp;quot;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;keyPoints=&amp;quot;0;1;0&amp;quot;&amp;lt;/code&amp;gt;. This doesn't work for &amp;lt;code&amp;gt;paced&amp;lt;/code&amp;gt; animation though (which make use of an implicit, user-agent dependent animation function).&lt;br /&gt;
** copy the original animation (call it e.g. &amp;lt;code&amp;gt;motion_forward&amp;lt;/code&amp;gt;) and swap the &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; values in the copy. Then specify &amp;lt;code&amp;gt;begin=&amp;quot;motion_forward.end&amp;quot;&amp;lt;/code&amp;gt; to tell the backward animation to start right at the end of the forward animation. This should work for every animation type.&lt;br /&gt;
&lt;br /&gt;
The question is: what maps best to a UI ?&lt;/div&gt;</summary>
		<author><name>ToF</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation&amp;diff=23654</id>
		<title>SVG Animation</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation&amp;diff=23654"/>
		<updated>2008-03-09T22:43:41Z</updated>

		<summary type="html">&lt;p&gt;ToF: /* More complex timing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is a '''work in progress'''. [[User:ToF|ToF]]&lt;br /&gt;
&lt;br /&gt;
== SVG Animation ==&lt;br /&gt;
&lt;br /&gt;
Animation in SVG is defined in the Animation Module of the [http://www.w3.org/TR/SVG11/animate.html SVG specification]. Animation in SVG conforms to the [http://www.w3.org/TR/2001/REC-smil-animation-20010904/ SMIL specification] (Synchronized Multimedia Integration Language) and extends it (SVG is said to be a ''host'' language of SMIL).&lt;br /&gt;
&lt;br /&gt;
Here I only focus on procedural animation and not programmatic animation (using a scripting language manipulating the DOM). &lt;br /&gt;
&lt;br /&gt;
In SMIL an animation is an object which defines the evolution of a given attribute of a given object (here an SVG element - path, rect, group...) over time. Multiple animations can control the evolution of particular attribute: for example, one will tell the object to turn for 1 second starting at t=0 second and another to move across the document for 2 seconds starting at a later time. So we have this relation:&lt;br /&gt;
             1:n&lt;br /&gt;
  Element &amp;lt;-------&amp;gt; Animation&lt;br /&gt;
&lt;br /&gt;
For a given animation the element which is controlled is called the '''target''' element of the animation. The specific attribute/property which is controlled is called the '''target''' attribute/property.&lt;br /&gt;
&lt;br /&gt;
In fact, it's completely legal to have two animations that control the same attribute of the same element, and they can overlap in time: at any particular time there exists a ''stack'' of animations applying to a particular attribute, and SMIL defines the order in which each animation is applied.&lt;br /&gt;
&lt;br /&gt;
== Animation elements ==&lt;br /&gt;
&lt;br /&gt;
SVG defines 5 animation elements:&lt;br /&gt;
* '''animate'''&lt;br /&gt;
This element is used to animate any scalar attribute or property, such as the &amp;lt;code&amp;gt;width&amp;lt;/code&amp;gt; attribute of an svg:rect element or the CCS property &amp;lt;code&amp;gt;opacity&amp;lt;/code&amp;gt;&lt;br /&gt;
* '''animateMotion'''&lt;br /&gt;
This elements only controls the position of a SVG element, by telling it to follow a given path&lt;br /&gt;
* '''animateColor'''&lt;br /&gt;
This element controls the animation of color valued attributes and properties.&lt;br /&gt;
* '''animateTransform'''&lt;br /&gt;
This element controls the transformation which applies to the target element. It replaces or adds up to the &amp;lt;code&amp;gt;transform&amp;lt;/code&amp;gt; attribute of the element.&lt;br /&gt;
* '''set'''&lt;br /&gt;
This element is used to set a particular value for the target attribute during a specified time interval. It is mainly used for animating attributes which do not span a continuous domain, such as boolean values like the &amp;lt;code&amp;gt;visibility&amp;lt;/code&amp;gt; property.&lt;br /&gt;
&lt;br /&gt;
== Specifying the target element and property ==&lt;br /&gt;
&lt;br /&gt;
There are 2 ways to tell which element a given animation will target. The first one is to embed the [[#Animation elements|animation element]] as a child tag of the element to animate. Here is an example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;circle cx=&amp;quot;100px&amp;quot; cy=&amp;quot;100px&amp;quot; r=&amp;quot;20px&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;animate attributeName=&amp;quot;r&amp;quot; attributeType=&amp;quot;XML&amp;quot; begin=&amp;quot;1s&amp;quot; dur=&amp;quot;2s&amp;quot; from=&amp;quot;20px&amp;quot; to=&amp;quot;50px&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/circle&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;animate&amp;lt;/code&amp;gt; element targets the radius (&amp;lt;code&amp;gt;r&amp;lt;/code&amp;gt;) property of the parent &amp;lt;code&amp;gt;circle&amp;lt;/code&amp;gt; element. Starting 1 second after the document start, the radius will grow for 2 seconds from 20 pixels to 50 pixels. When nothing else is specified, the animation only applies in its interval of time, here [1-3] seconds; from 0 to 1 second and then from 3 second and after, the circle's radius is set back to its ''static'' attribute value, here 20 pixels.&lt;br /&gt;
&lt;br /&gt;
The other way to specify the target element is to reference it in via an &amp;lt;code&amp;gt;xlink:href&amp;lt;/code&amp;gt; attribute of the animation element. the previous animation could be written this way:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;circle id=&amp;quot;balloon&amp;quot; cx=&amp;quot;100px&amp;quot; cy=&amp;quot;100px&amp;quot; r=&amp;quot;20px&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;animate xlink:href=&amp;quot;#balloon&amp;quot; attributeName=&amp;quot;r&amp;quot; attributeType=&amp;quot;XML&amp;quot; begin=&amp;quot;1s&amp;quot; dur=&amp;quot;2s&amp;quot; from=&amp;quot;20px&amp;quot; to=&amp;quot;50px&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To specify which property or attribute of the target element is controlled, we use the two attributes &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;attributeType&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; explains itself, it's the name of the controlled attribute. &amp;lt;code&amp;gt;attributeType&amp;lt;/code&amp;gt; tells whether &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; is searched among the SVG attributes of the element (&amp;lt;code&amp;gt;attributeType=&amp;quot;XML&amp;quot;&amp;lt;/code&amp;gt;) or among the CSS properties of the element (&amp;lt;code&amp;gt;attributeType=&amp;quot;CSS&amp;quot;&amp;lt;/code&amp;gt;). [http://www.w3.org/TR/SVG11/animate.html#TargetElement (SPEC)]&lt;br /&gt;
&lt;br /&gt;
== Timing an animation ==&lt;br /&gt;
&lt;br /&gt;
The first thing to stress is that SMIL (and therefore SVG) animation is '''time-based''', as opposed to '''frame-based'''. '''Frame-based''' animation is something traditional animators are used to, because they actually draw each image of the animation on a separate celluloid sheet, and the timing is related to the rate of images per second the camera will capture. When animation is done on a computer, the animator doesn't draw every image but only some ''key'' images (or ''keyframes'') and then the animation software creates all the necessary images for him (the so-called ''in-betweens''). That means the animator can focus back to a (real-)time based timing. Each keyframe is positioned on a timeline with real time values (instead of frame numbers). Of course at the end the animation is discrete and there is a fixed number of images computed inbetween two keyframes, but the neat property of specifying keyframes at time position is that the final animation frame rate is scalable and the animator doesn't have to care about it anymore. He just tells the software to produce 24 images each second if he targets a theatre film or say 10 images per second for low-bandwidth web animation. The animator doesn't need to reposition the keyframes.&lt;br /&gt;
&lt;br /&gt;
=== In-betweening by interpolation ===&lt;br /&gt;
&lt;br /&gt;
Creating the inbetween images on a computer is done by mean of '''interpolation'''. Interpolation is a mathematical tool that can reconstruct a the continuous evolution of a parameter given a set of discrete values of this parameter over time.&lt;br /&gt;
The following image illustrates that. We know that some attribute A must take value A0, A1, A2 and A3 at times t0, t1, t2 and t3. The red curves is one of the possible continuous function that be used to compute inbetween values of A in the interval [t0, t3].&lt;br /&gt;
&lt;br /&gt;
[[Image:interpolation.png]]&lt;br /&gt;
&lt;br /&gt;
* The animation's time interval&lt;br /&gt;
The first aspect that characterizes an animation is the interval of time on which it applies: when does it begin, when does it end or how long does it run.&lt;br /&gt;
Any of the above mentioned [[#Animation elements|animation elements] accept the attributes &amp;lt;code&amp;gt;begin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;dur&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
There are many ways to define a particular point in time and this is what makes SMIL a very rich animation framework (see below). The simplest is to specify a clock-value which syntax is quite intuitive [http://www.w3.org/TR/SVG11/animate.html#ClockValueSyntax (SPEC)]. Depending on the combination of those 3 attributes, the interval of time of the animation will be [begin, end], [begin, begin+dur], [end-dur, end], etc.&lt;br /&gt;
&lt;br /&gt;
* The attribute values&lt;br /&gt;
To specify the values taken by the attribute over the time interval, one need to tell the value that the parameter must have at the begin and at the end of the interval. here again those values are specified by combinations of three attributes: &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;by&amp;lt;/code&amp;gt;. The attribute &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt; correspond to the begin value, the attribute &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; correspond to the end value. The attribute &amp;lt;code&amp;gt;by&amp;lt;/code&amp;gt; let you define either the initial and final values relative to the other one, that is to = from + by or from = to - by. The following image illusttrate this setup for our hypothetical attribute A&lt;br /&gt;
&lt;br /&gt;
[[Image:time_interval.png]]&lt;br /&gt;
&lt;br /&gt;
The values of A are simply interpolated '''linearly''' in between begin and end. This is the more simple form of '''animation function''' that can defined: by the two extremal pairs of (time, attribute value): (begin, from) and (end, to).&lt;br /&gt;
&lt;br /&gt;
=== More complex timing ===&lt;br /&gt;
&lt;br /&gt;
It's possible to specify a whole set of (keytime, keyvalue) pairs to define the animation function. Each item of the pairs are actually given separately:&lt;br /&gt;
* the set of attribute values (keyvalues) are given by the &amp;lt;code&amp;gt;values&amp;lt;/code&amp;gt; attribute.&lt;br /&gt;
* the set of time values (keytimes) are given by the &amp;lt;code&amp;gt;keyTimes&amp;lt;/code&amp;gt; attribute.&lt;br /&gt;
&lt;br /&gt;
Each set as the form of a semicolon-separated list of values. The thing to notice is that the keytimes are actually '''normalized to [0,1]''', which means that 0 maps to begin and 1 maps to end, and those values must start and end the list of keytimes. The image below illustrates all this:&lt;br /&gt;
&lt;br /&gt;
[[Image:time_interval2.png]]&lt;br /&gt;
&lt;br /&gt;
The keyTimes list can actually be omitted, in which case the keytimes are evenly distributed in the interval [0,1] (or equivalently, evenly in the interval [begin, end])&lt;br /&gt;
&lt;br /&gt;
The (keytime, keyvalue) pairs are joined by straight lines in the above graph, which means that we use '''linear interpolation''' for computing the inbetween values. &lt;br /&gt;
&lt;br /&gt;
When applied to the position of an object, linear interpolation results in un-natural robot-like motions (which may the effect wanted). SMIL allows smoother animations by defining '''spline-based interpolation''' between two (keytime, keyvalue) pairs. For each interval (t0, v0) - (t1, v1) a spline can be defined by two control points defining the tangents of the spline at t0 and t1. Those control points are passed in the attribute &amp;lt;code&amp;gt;keySplines&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:spline_interpolation.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Two other interpolation modes are possible:&lt;br /&gt;
* '''discrete''': this is a degenerate form of interpolation, because the resulting animation function is not continuous. For each interval (t0,v0) - (t1, v1), the attribute value is set to v0 for the whole interval. It ''jumps'' to v1 right when t1 is reached and so on.&lt;br /&gt;
* '''paced''': in this interpolation mode, the attribute is interpolated so that its evolution over time has '''constant speed'''. Because the animation function is defined implicitly, the attribute &amp;lt;code&amp;gt;keyTimes&amp;lt;/code&amp;gt; is not taken into account. This mode is mainly useful for the &amp;lt;code&amp;gt;animateMotion&amp;lt;/code&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
=== Other aspects of animation ===&lt;br /&gt;
* repeating&lt;br /&gt;
* chaining animations.&lt;br /&gt;
* event based synchronisation&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
Examples showcasing some of the effects that can be achieved using procedural animation in SVG.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1px&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 1 --&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces on the floor: there are 6 motions here: fall, squeeze, squeeze-offset and bounce unsqueeze and unsqueeze-offset that are the revert version of 3 first. A classic animation trick is to start squeezing the ball a little before it touches the floor, expressed here by the synchronization &amp;lt;code&amp;gt;begin=fall.end - 0.1s&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td rowspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;path&lt;br /&gt;
   ...&lt;br /&gt;
   transform=&amp;quot;translate(0,4.5456868)&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;animateTransform&lt;br /&gt;
         type=&amp;quot;translate&amp;quot;&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot;&lt;br /&gt;
         from=&amp;quot;0, 0&amp;quot;&lt;br /&gt;
         to=&amp;quot;0, 136&amp;quot;&lt;br /&gt;
         dur=&amp;quot;1s&amp;quot;&lt;br /&gt;
         begin=&amp;quot;0s&amp;quot;&lt;br /&gt;
         attributeType=&amp;quot;XML&amp;quot;&lt;br /&gt;
         attributeName=&amp;quot;transform&amp;quot;&lt;br /&gt;
         id=&amp;quot;fall&amp;quot;&lt;br /&gt;
         keySplines=&amp;quot;0.5 0  0.8 0.5 &amp;quot;&lt;br /&gt;
         calcMode=&amp;quot;spline&amp;quot; /&amp;gt;&lt;br /&gt;
      &amp;lt;animateTransform&lt;br /&gt;
         id=&amp;quot;squeeze&amp;quot;&lt;br /&gt;
         type=&amp;quot;scale&amp;quot;&lt;br /&gt;
         from=&amp;quot;1,1&amp;quot;&lt;br /&gt;
         to=&amp;quot;1.1,0.9&amp;quot;&lt;br /&gt;
         begin=&amp;quot;fall.end-0.1s&amp;quot;&lt;br /&gt;
         attributeName=&amp;quot;transform&amp;quot;&lt;br /&gt;
         attributeType=&amp;quot;XML&amp;quot;&lt;br /&gt;
         dur=&amp;quot;0.2s&amp;quot;&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot; /&amp;gt;&lt;br /&gt;
      &amp;lt;animateTransform&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot;&lt;br /&gt;
         dur=&amp;quot;0.2s&amp;quot;&lt;br /&gt;
         attributeType=&amp;quot;XML&amp;quot;&lt;br /&gt;
         attributeName=&amp;quot;transform&amp;quot;&lt;br /&gt;
         begin=&amp;quot;fall.end-0.1s&amp;quot;&lt;br /&gt;
         to=&amp;quot;-13,0&amp;quot;&lt;br /&gt;
         from=&amp;quot;0,0&amp;quot;&lt;br /&gt;
         type=&amp;quot;translate&amp;quot;&lt;br /&gt;
         id=&amp;quot;squeeze-offset&amp;quot;&lt;br /&gt;
         accumulate=&amp;quot;sum&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball1.png]]&lt;br /&gt;
[http://wiki.inkscape.org/wiki/images/Bouncing_ball1.svg SVG file] |&lt;br /&gt;
[http://www.cdehais.fr/~tof/svg/bouncing_ball1.ogg ogg video]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 2 --&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces between two wall, following a path.&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td rowspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;path&lt;br /&gt;
       ...&lt;br /&gt;
       sodipodi:type=&amp;quot;arc&amp;quot;&lt;br /&gt;
       id=&amp;quot;ball&amp;quot; &lt;br /&gt;
       ... &lt;br /&gt;
&amp;gt;&lt;br /&gt;
      &amp;lt;animateMotion&lt;br /&gt;
         keyTimes=&amp;quot;0; 0.20; 1&amp;quot;&lt;br /&gt;
         keyPoints=&amp;quot;0; 0.33; 1&amp;quot;&lt;br /&gt;
         repeatCount=&amp;quot;indefinite&amp;quot;&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot;&lt;br /&gt;
         rotate=&amp;quot;0&amp;quot;&lt;br /&gt;
         begin=&amp;quot;0s&amp;quot;&lt;br /&gt;
         dur=&amp;quot;2s&amp;quot;&lt;br /&gt;
         calcMode=&amp;quot;linear&amp;quot;&lt;br /&gt;
         id=&amp;quot;animateMotion2680&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;mpath&lt;br /&gt;
           xlink:href=&amp;quot;#motion_path&amp;quot;&lt;br /&gt;
           id=&amp;quot;mpath2682&amp;quot; /&amp;gt;&lt;br /&gt;
      &amp;lt;/animateMotion&amp;gt;&lt;br /&gt;
&amp;lt;/path&amp;gt;&lt;br /&gt;
&amp;lt;path&lt;br /&gt;
   d=&amp;quot;M 82.080559,103.82375 ...&amp;quot;&lt;br /&gt;
   id=&amp;quot;motion_path&amp;quot; ... /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball2.png]]&lt;br /&gt;
[http://wiki.inkscape.org/wiki/images/Bouncing_ball2.svg SVG file] |&lt;br /&gt;
[http://www.cdehais.fr/~tof/svg/bouncing_ball2.ogg ogg video]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 3 --&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces between 2 walls. The motion is defined as a combination a of vertical translation and a horizontal translation. This works because the second animation has an &amp;lt;code&amp;gt;additive=&amp;quot;sum&amp;quot;&amp;lt;/code&amp;gt; attribute, so the corresponding matrix is composited with the matrix defined by the underlying animations.&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td rowspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
&amp;lt;!-- two animation sharing the same path --&amp;gt;&lt;br /&gt;
  &amp;lt;animateMotion&lt;br /&gt;
     id=&amp;quot;animateMotion2302&amp;quot;&lt;br /&gt;
     xlink:href=&amp;quot;#arrow2&amp;quot;&lt;br /&gt;
     dur=&amp;quot;4s&amp;quot;&lt;br /&gt;
     keyTimes=&amp;quot;0; 0.5; 1&amp;quot;&lt;br /&gt;
     keyPoints=&amp;quot;0; 1; 0&amp;quot;&lt;br /&gt;
     calcMode=&amp;quot;linear&amp;quot;&lt;br /&gt;
     repeatCount=&amp;quot;indefinite&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;mpath&lt;br /&gt;
       id=&amp;quot;mpath2305&amp;quot;&lt;br /&gt;
       xlink:href=&amp;quot;#horiz-bounce&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/animateMotion&amp;gt;&lt;br /&gt;
  &amp;lt;animateMotion&lt;br /&gt;
     calcMode=&amp;quot;linear&amp;quot;&lt;br /&gt;
     keyPoints=&amp;quot;0; 1; 0&amp;quot;&lt;br /&gt;
     keyTimes=&amp;quot;0; 0.5; 1&amp;quot;&lt;br /&gt;
     dur=&amp;quot;4s&amp;quot;&lt;br /&gt;
     xlink:href=&amp;quot;#ball&amp;quot;&lt;br /&gt;
     id=&amp;quot;animateMotion2309&amp;quot;&lt;br /&gt;
     repeatCount=&amp;quot;indefinite&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;mpath&lt;br /&gt;
       xlink:href=&amp;quot;#horiz-bounce&amp;quot;&lt;br /&gt;
       id=&amp;quot;mpath2311&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/animateMotion&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
  &amp;lt;animateMotion&lt;br /&gt;
     keySplines=&amp;quot;0.5 0 0.75 0.75, 0 0.5 0.5 0.75&amp;quot;&lt;br /&gt;
     keyPoints=&amp;quot;0;  1; 0&amp;quot;&lt;br /&gt;
     calcMode=&amp;quot;spline&amp;quot;&lt;br /&gt;
     keyTimes=&amp;quot;0;  0.5; 1&amp;quot;&lt;br /&gt;
     id=&amp;quot;animateMotion2298&amp;quot;&lt;br /&gt;
     begin=&amp;quot;0s&amp;quot;&lt;br /&gt;
     dur=&amp;quot;2s&amp;quot;&lt;br /&gt;
     xlink:href=&amp;quot;#ball&amp;quot;&lt;br /&gt;
     additive=&amp;quot;sum&amp;quot;&lt;br /&gt;
     repeatCount=&amp;quot;indefinite&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;mpath&lt;br /&gt;
       id=&amp;quot;mpath2300&amp;quot;&lt;br /&gt;
       xlink:href=&amp;quot;#vert-bounce&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/animateMotion&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball3.png]]&lt;br /&gt;
[http://wiki.inkscape.org/wiki/images/Bouncing_ball3.svg SVG file] |&lt;br /&gt;
[http://www.cdehais.fr/~tof/svg/bouncing_ball3.ogg ogg video]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Useful tools ==&lt;br /&gt;
&lt;br /&gt;
* [http://xmlgraphics.apache.org/batik/tools/browser.html Squiggle ], as part of [http://xmlgraphics.apache.org/batik/ Batik 1.7] has a nearly complete support for SMIL Animation. The [[#Examples|examples]] were all rendered using Squiggle.&lt;br /&gt;
* Inkscape ! I used the xml editor to manually add the animation elements for my test. It's a bit more cumbersome than editing the svg file in a text editor, but doing that in Inkscape eases the computation of key positions (just move the object around and read the position values).&lt;br /&gt;
&lt;br /&gt;
== Various thoughts ==&lt;br /&gt;
&lt;br /&gt;
* There is no direct way to specify a &amp;lt;b&amp;gt;''ping-pong'' animation&amp;lt;/b&amp;gt; in SVG, that is to tell an animation to go back in time when it reaches it's end. To implement this, I see 2 solutions:&lt;br /&gt;
**double the duration d of the animation (&amp;lt;code&amp;gt;dur&amp;lt;/code&amp;gt; attribute) et apply a scale and a symetry around t=0.5 to the animation function. For example the simple linear interpolation defined by &amp;lt;code&amp;gt;keyTimes=&amp;quot;0; 1&amp;quot;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;keyPoints=&amp;quot;0;1&amp;quot;&amp;lt;/code&amp;gt; becomes &amp;lt;code&amp;gt;keyTimes=&amp;quot;0; 0.5; 1&amp;quot;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;keyPoints=&amp;quot;0;1;0&amp;quot;&amp;lt;/code&amp;gt;. This doesn't work for &amp;lt;code&amp;gt;paced&amp;lt;/code&amp;gt; animation though (which make use of an implicit, user-agent dependent animation function).&lt;br /&gt;
** copy the original animation (call it e.g. &amp;lt;code&amp;gt;motion_forward&amp;lt;/code&amp;gt;) and swap the &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; values in the copy. Then specify &amp;lt;code&amp;gt;begin=&amp;quot;motion_forward.end&amp;quot;&amp;lt;/code&amp;gt; to tell the backward animation to start right at the end of the forward animation. This should work for every animation type.&lt;br /&gt;
&lt;br /&gt;
The question is: what maps best to a UI ?&lt;/div&gt;</summary>
		<author><name>ToF</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation&amp;diff=23644</id>
		<title>SVG Animation</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation&amp;diff=23644"/>
		<updated>2008-03-09T22:41:33Z</updated>

		<summary type="html">&lt;p&gt;ToF: /* In-betweening by interpolation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is a '''work in progress'''. [[User:ToF|ToF]]&lt;br /&gt;
&lt;br /&gt;
== SVG Animation ==&lt;br /&gt;
&lt;br /&gt;
Animation in SVG is defined in the Animation Module of the [http://www.w3.org/TR/SVG11/animate.html SVG specification]. Animation in SVG conforms to the [http://www.w3.org/TR/2001/REC-smil-animation-20010904/ SMIL specification] (Synchronized Multimedia Integration Language) and extends it (SVG is said to be a ''host'' language of SMIL).&lt;br /&gt;
&lt;br /&gt;
Here I only focus on procedural animation and not programmatic animation (using a scripting language manipulating the DOM). &lt;br /&gt;
&lt;br /&gt;
In SMIL an animation is an object which defines the evolution of a given attribute of a given object (here an SVG element - path, rect, group...) over time. Multiple animations can control the evolution of particular attribute: for example, one will tell the object to turn for 1 second starting at t=0 second and another to move across the document for 2 seconds starting at a later time. So we have this relation:&lt;br /&gt;
             1:n&lt;br /&gt;
  Element &amp;lt;-------&amp;gt; Animation&lt;br /&gt;
&lt;br /&gt;
For a given animation the element which is controlled is called the '''target''' element of the animation. The specific attribute/property which is controlled is called the '''target''' attribute/property.&lt;br /&gt;
&lt;br /&gt;
In fact, it's completely legal to have two animations that control the same attribute of the same element, and they can overlap in time: at any particular time there exists a ''stack'' of animations applying to a particular attribute, and SMIL defines the order in which each animation is applied.&lt;br /&gt;
&lt;br /&gt;
== Animation elements ==&lt;br /&gt;
&lt;br /&gt;
SVG defines 5 animation elements:&lt;br /&gt;
* '''animate'''&lt;br /&gt;
This element is used to animate any scalar attribute or property, such as the &amp;lt;code&amp;gt;width&amp;lt;/code&amp;gt; attribute of an svg:rect element or the CCS property &amp;lt;code&amp;gt;opacity&amp;lt;/code&amp;gt;&lt;br /&gt;
* '''animateMotion'''&lt;br /&gt;
This elements only controls the position of a SVG element, by telling it to follow a given path&lt;br /&gt;
* '''animateColor'''&lt;br /&gt;
This element controls the animation of color valued attributes and properties.&lt;br /&gt;
* '''animateTransform'''&lt;br /&gt;
This element controls the transformation which applies to the target element. It replaces or adds up to the &amp;lt;code&amp;gt;transform&amp;lt;/code&amp;gt; attribute of the element.&lt;br /&gt;
* '''set'''&lt;br /&gt;
This element is used to set a particular value for the target attribute during a specified time interval. It is mainly used for animating attributes which do not span a continuous domain, such as boolean values like the &amp;lt;code&amp;gt;visibility&amp;lt;/code&amp;gt; property.&lt;br /&gt;
&lt;br /&gt;
== Specifying the target element and property ==&lt;br /&gt;
&lt;br /&gt;
There are 2 ways to tell which element a given animation will target. The first one is to embed the [[#Animation elements|animation element]] as a child tag of the element to animate. Here is an example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;circle cx=&amp;quot;100px&amp;quot; cy=&amp;quot;100px&amp;quot; r=&amp;quot;20px&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;animate attributeName=&amp;quot;r&amp;quot; attributeType=&amp;quot;XML&amp;quot; begin=&amp;quot;1s&amp;quot; dur=&amp;quot;2s&amp;quot; from=&amp;quot;20px&amp;quot; to=&amp;quot;50px&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/circle&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;animate&amp;lt;/code&amp;gt; element targets the radius (&amp;lt;code&amp;gt;r&amp;lt;/code&amp;gt;) property of the parent &amp;lt;code&amp;gt;circle&amp;lt;/code&amp;gt; element. Starting 1 second after the document start, the radius will grow for 2 seconds from 20 pixels to 50 pixels. When nothing else is specified, the animation only applies in its interval of time, here [1-3] seconds; from 0 to 1 second and then from 3 second and after, the circle's radius is set back to its ''static'' attribute value, here 20 pixels.&lt;br /&gt;
&lt;br /&gt;
The other way to specify the target element is to reference it in via an &amp;lt;code&amp;gt;xlink:href&amp;lt;/code&amp;gt; attribute of the animation element. the previous animation could be written this way:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;circle id=&amp;quot;balloon&amp;quot; cx=&amp;quot;100px&amp;quot; cy=&amp;quot;100px&amp;quot; r=&amp;quot;20px&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;animate xlink:href=&amp;quot;#balloon&amp;quot; attributeName=&amp;quot;r&amp;quot; attributeType=&amp;quot;XML&amp;quot; begin=&amp;quot;1s&amp;quot; dur=&amp;quot;2s&amp;quot; from=&amp;quot;20px&amp;quot; to=&amp;quot;50px&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To specify which property or attribute of the target element is controlled, we use the two attributes &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;attributeType&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; explains itself, it's the name of the controlled attribute. &amp;lt;code&amp;gt;attributeType&amp;lt;/code&amp;gt; tells whether &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; is searched among the SVG attributes of the element (&amp;lt;code&amp;gt;attributeType=&amp;quot;XML&amp;quot;&amp;lt;/code&amp;gt;) or among the CSS properties of the element (&amp;lt;code&amp;gt;attributeType=&amp;quot;CSS&amp;quot;&amp;lt;/code&amp;gt;). [http://www.w3.org/TR/SVG11/animate.html#TargetElement (SPEC)]&lt;br /&gt;
&lt;br /&gt;
== Timing an animation ==&lt;br /&gt;
&lt;br /&gt;
The first thing to stress is that SMIL (and therefore SVG) animation is '''time-based''', as opposed to '''frame-based'''. '''Frame-based''' animation is something traditional animators are used to, because they actually draw each image of the animation on a separate celluloid sheet, and the timing is related to the rate of images per second the camera will capture. When animation is done on a computer, the animator doesn't draw every image but only some ''key'' images (or ''keyframes'') and then the animation software creates all the necessary images for him (the so-called ''in-betweens''). That means the animator can focus back to a (real-)time based timing. Each keyframe is positioned on a timeline with real time values (instead of frame numbers). Of course at the end the animation is discrete and there is a fixed number of images computed inbetween two keyframes, but the neat property of specifying keyframes at time position is that the final animation frame rate is scalable and the animator doesn't have to care about it anymore. He just tells the software to produce 24 images each second if he targets a theatre film or say 10 images per second for low-bandwidth web animation. The animator doesn't need to reposition the keyframes.&lt;br /&gt;
&lt;br /&gt;
=== In-betweening by interpolation ===&lt;br /&gt;
&lt;br /&gt;
Creating the inbetween images on a computer is done by mean of '''interpolation'''. Interpolation is a mathematical tool that can reconstruct a the continuous evolution of a parameter given a set of discrete values of this parameter over time.&lt;br /&gt;
The following image illustrates that. We know that some attribute A must take value A0, A1, A2 and A3 at times t0, t1, t2 and t3. The red curves is one of the possible continuous function that be used to compute inbetween values of A in the interval [t0, t3].&lt;br /&gt;
&lt;br /&gt;
[[Image:interpolation.png]]&lt;br /&gt;
&lt;br /&gt;
* The animation's time interval&lt;br /&gt;
The first aspect that characterizes an animation is the interval of time on which it applies: when does it begin, when does it end or how long does it run.&lt;br /&gt;
Any of the above mentioned [[#Animation elements|animation elements] accept the attributes &amp;lt;code&amp;gt;begin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;dur&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
There are many ways to define a particular point in time and this is what makes SMIL a very rich animation framework (see below). The simplest is to specify a clock-value which syntax is quite intuitive [http://www.w3.org/TR/SVG11/animate.html#ClockValueSyntax (SPEC)]. Depending on the combination of those 3 attributes, the interval of time of the animation will be [begin, end], [begin, begin+dur], [end-dur, end], etc.&lt;br /&gt;
&lt;br /&gt;
* The attribute values&lt;br /&gt;
To specify the values taken by the attribute over the time interval, one need to tell the value that the parameter must have at the begin and at the end of the interval. here again those values are specified by combinations of three attributes: &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;by&amp;lt;/code&amp;gt;. The attribute &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt; correspond to the begin value, the attribute &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; correspond to the end value. The attribute &amp;lt;code&amp;gt;by&amp;lt;/code&amp;gt; let you define either the initial and final values relative to the other one, that is to = from + by or from = to - by. The following image illusttrate this setup for our hypothetical attribute A&lt;br /&gt;
&lt;br /&gt;
[[Image:time_interval.png]]&lt;br /&gt;
&lt;br /&gt;
The values of A are simply interpolated '''linearly''' in between begin and end. This is the more simple form of '''animation function''' that can defined: by the two extremal pairs of (time, attribute value): (begin, from) and (end, to).&lt;br /&gt;
&lt;br /&gt;
=== More complex timing ===&lt;br /&gt;
&lt;br /&gt;
It's possible to specify a whole set of (keytime, keyvalue) pairs to define the animation function. Each item of the pairs are actually given separately:&lt;br /&gt;
* the set of attribute values (keyvalues) are given by the &amp;lt;code&amp;gt;values&amp;lt;/code&amp;gt; attribute.&lt;br /&gt;
* the set of time values (keytimes) are given by the &amp;lt;code&amp;gt;keyTimes&amp;lt;/code&amp;gt; attribute.&lt;br /&gt;
&lt;br /&gt;
Each set as the form of a semicolon-separated list of values. The thing to notice is that the keytimes are actually '''normalized to [0,1]''', which means that 0 maps to begin and 1 maps to end, and those values must start and end the list of keytimes. The image below illustrates all this:&lt;br /&gt;
&lt;br /&gt;
[[Image:time_interval2.png]]&lt;br /&gt;
&lt;br /&gt;
The keyTimes list can actually be omitted. In this cases the keytimes are evenly in interval [0,1] (equivalently, evenly in the interval [begin, end])&lt;br /&gt;
&lt;br /&gt;
The (keytime, keyvalue) pairs are joined by straight lines in the above graph, which means that we use '''linear interpolation''' for computing the inbetween values. &lt;br /&gt;
&lt;br /&gt;
When applied to the position of an object, linear interpolation results in un-natural robot-like motions (which may the effect wanted). SMIL allows smoother animations by defining '''spline-based interpolation''' between two (keytime, keyvalue) pairs. For each interval (t0, v0) - (t1, v1) a spline can be defined by two control points defining the tangents of the spline at t0 and t1. Those control points are passed in the attribute &amp;lt;code&amp;gt;keySplines&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:spline_interpolation.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Two other interpolation modes are possible:&lt;br /&gt;
* '''discrete''': this is a degenerate form of interpolation, because the resulting animation function is not continuous. For each interval (t0,v0) - (t1, v1), the attribute value is set to v0 for the whole interval. It ''jumps'' to v1 right when t1 is reached and so on.&lt;br /&gt;
* '''paced''': in this interpolation mode, the attribute is interpolated so that its evolution over time has '''constant speed'''. Because the animation function is defined implicitly, the attribute &amp;lt;code&amp;gt;keyTimes&amp;lt;/code&amp;gt; is not taken into account. This mode is mainly useful for the &amp;lt;code&amp;gt;animateMotion&amp;lt;/code&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
=== Other aspects of animation ===&lt;br /&gt;
* repeating&lt;br /&gt;
* chaining animations.&lt;br /&gt;
* event based synchronisation&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
Examples showcasing some of the effects that can be achieved using procedural animation in SVG.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1px&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 1 --&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces on the floor: there are 6 motions here: fall, squeeze, squeeze-offset and bounce unsqueeze and unsqueeze-offset that are the revert version of 3 first. A classic animation trick is to start squeezing the ball a little before it touches the floor, expressed here by the synchronization &amp;lt;code&amp;gt;begin=fall.end - 0.1s&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td rowspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;path&lt;br /&gt;
   ...&lt;br /&gt;
   transform=&amp;quot;translate(0,4.5456868)&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;animateTransform&lt;br /&gt;
         type=&amp;quot;translate&amp;quot;&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot;&lt;br /&gt;
         from=&amp;quot;0, 0&amp;quot;&lt;br /&gt;
         to=&amp;quot;0, 136&amp;quot;&lt;br /&gt;
         dur=&amp;quot;1s&amp;quot;&lt;br /&gt;
         begin=&amp;quot;0s&amp;quot;&lt;br /&gt;
         attributeType=&amp;quot;XML&amp;quot;&lt;br /&gt;
         attributeName=&amp;quot;transform&amp;quot;&lt;br /&gt;
         id=&amp;quot;fall&amp;quot;&lt;br /&gt;
         keySplines=&amp;quot;0.5 0  0.8 0.5 &amp;quot;&lt;br /&gt;
         calcMode=&amp;quot;spline&amp;quot; /&amp;gt;&lt;br /&gt;
      &amp;lt;animateTransform&lt;br /&gt;
         id=&amp;quot;squeeze&amp;quot;&lt;br /&gt;
         type=&amp;quot;scale&amp;quot;&lt;br /&gt;
         from=&amp;quot;1,1&amp;quot;&lt;br /&gt;
         to=&amp;quot;1.1,0.9&amp;quot;&lt;br /&gt;
         begin=&amp;quot;fall.end-0.1s&amp;quot;&lt;br /&gt;
         attributeName=&amp;quot;transform&amp;quot;&lt;br /&gt;
         attributeType=&amp;quot;XML&amp;quot;&lt;br /&gt;
         dur=&amp;quot;0.2s&amp;quot;&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot; /&amp;gt;&lt;br /&gt;
      &amp;lt;animateTransform&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot;&lt;br /&gt;
         dur=&amp;quot;0.2s&amp;quot;&lt;br /&gt;
         attributeType=&amp;quot;XML&amp;quot;&lt;br /&gt;
         attributeName=&amp;quot;transform&amp;quot;&lt;br /&gt;
         begin=&amp;quot;fall.end-0.1s&amp;quot;&lt;br /&gt;
         to=&amp;quot;-13,0&amp;quot;&lt;br /&gt;
         from=&amp;quot;0,0&amp;quot;&lt;br /&gt;
         type=&amp;quot;translate&amp;quot;&lt;br /&gt;
         id=&amp;quot;squeeze-offset&amp;quot;&lt;br /&gt;
         accumulate=&amp;quot;sum&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball1.png]]&lt;br /&gt;
[http://wiki.inkscape.org/wiki/images/Bouncing_ball1.svg SVG file] |&lt;br /&gt;
[http://www.cdehais.fr/~tof/svg/bouncing_ball1.ogg ogg video]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 2 --&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces between two wall, following a path.&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td rowspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;path&lt;br /&gt;
       ...&lt;br /&gt;
       sodipodi:type=&amp;quot;arc&amp;quot;&lt;br /&gt;
       id=&amp;quot;ball&amp;quot; &lt;br /&gt;
       ... &lt;br /&gt;
&amp;gt;&lt;br /&gt;
      &amp;lt;animateMotion&lt;br /&gt;
         keyTimes=&amp;quot;0; 0.20; 1&amp;quot;&lt;br /&gt;
         keyPoints=&amp;quot;0; 0.33; 1&amp;quot;&lt;br /&gt;
         repeatCount=&amp;quot;indefinite&amp;quot;&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot;&lt;br /&gt;
         rotate=&amp;quot;0&amp;quot;&lt;br /&gt;
         begin=&amp;quot;0s&amp;quot;&lt;br /&gt;
         dur=&amp;quot;2s&amp;quot;&lt;br /&gt;
         calcMode=&amp;quot;linear&amp;quot;&lt;br /&gt;
         id=&amp;quot;animateMotion2680&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;mpath&lt;br /&gt;
           xlink:href=&amp;quot;#motion_path&amp;quot;&lt;br /&gt;
           id=&amp;quot;mpath2682&amp;quot; /&amp;gt;&lt;br /&gt;
      &amp;lt;/animateMotion&amp;gt;&lt;br /&gt;
&amp;lt;/path&amp;gt;&lt;br /&gt;
&amp;lt;path&lt;br /&gt;
   d=&amp;quot;M 82.080559,103.82375 ...&amp;quot;&lt;br /&gt;
   id=&amp;quot;motion_path&amp;quot; ... /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball2.png]]&lt;br /&gt;
[http://wiki.inkscape.org/wiki/images/Bouncing_ball2.svg SVG file] |&lt;br /&gt;
[http://www.cdehais.fr/~tof/svg/bouncing_ball2.ogg ogg video]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 3 --&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces between 2 walls. The motion is defined as a combination a of vertical translation and a horizontal translation. This works because the second animation has an &amp;lt;code&amp;gt;additive=&amp;quot;sum&amp;quot;&amp;lt;/code&amp;gt; attribute, so the corresponding matrix is composited with the matrix defined by the underlying animations.&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td rowspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
&amp;lt;!-- two animation sharing the same path --&amp;gt;&lt;br /&gt;
  &amp;lt;animateMotion&lt;br /&gt;
     id=&amp;quot;animateMotion2302&amp;quot;&lt;br /&gt;
     xlink:href=&amp;quot;#arrow2&amp;quot;&lt;br /&gt;
     dur=&amp;quot;4s&amp;quot;&lt;br /&gt;
     keyTimes=&amp;quot;0; 0.5; 1&amp;quot;&lt;br /&gt;
     keyPoints=&amp;quot;0; 1; 0&amp;quot;&lt;br /&gt;
     calcMode=&amp;quot;linear&amp;quot;&lt;br /&gt;
     repeatCount=&amp;quot;indefinite&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;mpath&lt;br /&gt;
       id=&amp;quot;mpath2305&amp;quot;&lt;br /&gt;
       xlink:href=&amp;quot;#horiz-bounce&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/animateMotion&amp;gt;&lt;br /&gt;
  &amp;lt;animateMotion&lt;br /&gt;
     calcMode=&amp;quot;linear&amp;quot;&lt;br /&gt;
     keyPoints=&amp;quot;0; 1; 0&amp;quot;&lt;br /&gt;
     keyTimes=&amp;quot;0; 0.5; 1&amp;quot;&lt;br /&gt;
     dur=&amp;quot;4s&amp;quot;&lt;br /&gt;
     xlink:href=&amp;quot;#ball&amp;quot;&lt;br /&gt;
     id=&amp;quot;animateMotion2309&amp;quot;&lt;br /&gt;
     repeatCount=&amp;quot;indefinite&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;mpath&lt;br /&gt;
       xlink:href=&amp;quot;#horiz-bounce&amp;quot;&lt;br /&gt;
       id=&amp;quot;mpath2311&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/animateMotion&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
  &amp;lt;animateMotion&lt;br /&gt;
     keySplines=&amp;quot;0.5 0 0.75 0.75, 0 0.5 0.5 0.75&amp;quot;&lt;br /&gt;
     keyPoints=&amp;quot;0;  1; 0&amp;quot;&lt;br /&gt;
     calcMode=&amp;quot;spline&amp;quot;&lt;br /&gt;
     keyTimes=&amp;quot;0;  0.5; 1&amp;quot;&lt;br /&gt;
     id=&amp;quot;animateMotion2298&amp;quot;&lt;br /&gt;
     begin=&amp;quot;0s&amp;quot;&lt;br /&gt;
     dur=&amp;quot;2s&amp;quot;&lt;br /&gt;
     xlink:href=&amp;quot;#ball&amp;quot;&lt;br /&gt;
     additive=&amp;quot;sum&amp;quot;&lt;br /&gt;
     repeatCount=&amp;quot;indefinite&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;mpath&lt;br /&gt;
       id=&amp;quot;mpath2300&amp;quot;&lt;br /&gt;
       xlink:href=&amp;quot;#vert-bounce&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/animateMotion&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball3.png]]&lt;br /&gt;
[http://wiki.inkscape.org/wiki/images/Bouncing_ball3.svg SVG file] |&lt;br /&gt;
[http://www.cdehais.fr/~tof/svg/bouncing_ball3.ogg ogg video]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Useful tools ==&lt;br /&gt;
&lt;br /&gt;
* [http://xmlgraphics.apache.org/batik/tools/browser.html Squiggle ], as part of [http://xmlgraphics.apache.org/batik/ Batik 1.7] has a nearly complete support for SMIL Animation. The [[#Examples|examples]] were all rendered using Squiggle.&lt;br /&gt;
* Inkscape ! I used the xml editor to manually add the animation elements for my test. It's a bit more cumbersome than editing the svg file in a text editor, but doing that in Inkscape eases the computation of key positions (just move the object around and read the position values).&lt;br /&gt;
&lt;br /&gt;
== Various thoughts ==&lt;br /&gt;
&lt;br /&gt;
* There is no direct way to specify a &amp;lt;b&amp;gt;''ping-pong'' animation&amp;lt;/b&amp;gt; in SVG, that is to tell an animation to go back in time when it reaches it's end. To implement this, I see 2 solutions:&lt;br /&gt;
**double the duration d of the animation (&amp;lt;code&amp;gt;dur&amp;lt;/code&amp;gt; attribute) et apply a scale and a symetry around t=0.5 to the animation function. For example the simple linear interpolation defined by &amp;lt;code&amp;gt;keyTimes=&amp;quot;0; 1&amp;quot;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;keyPoints=&amp;quot;0;1&amp;quot;&amp;lt;/code&amp;gt; becomes &amp;lt;code&amp;gt;keyTimes=&amp;quot;0; 0.5; 1&amp;quot;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;keyPoints=&amp;quot;0;1;0&amp;quot;&amp;lt;/code&amp;gt;. This doesn't work for &amp;lt;code&amp;gt;paced&amp;lt;/code&amp;gt; animation though (which make use of an implicit, user-agent dependent animation function).&lt;br /&gt;
** copy the original animation (call it e.g. &amp;lt;code&amp;gt;motion_forward&amp;lt;/code&amp;gt;) and swap the &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; values in the copy. Then specify &amp;lt;code&amp;gt;begin=&amp;quot;motion_forward.end&amp;quot;&amp;lt;/code&amp;gt; to tell the backward animation to start right at the end of the forward animation. This should work for every animation type.&lt;br /&gt;
&lt;br /&gt;
The question is: what maps best to a UI ?&lt;/div&gt;</summary>
		<author><name>ToF</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation&amp;diff=23634</id>
		<title>SVG Animation</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation&amp;diff=23634"/>
		<updated>2008-03-09T22:39:09Z</updated>

		<summary type="html">&lt;p&gt;ToF: /* Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is a '''work in progress'''. [[User:ToF|ToF]]&lt;br /&gt;
&lt;br /&gt;
== SVG Animation ==&lt;br /&gt;
&lt;br /&gt;
Animation in SVG is defined in the Animation Module of the [http://www.w3.org/TR/SVG11/animate.html SVG specification]. Animation in SVG conforms to the [http://www.w3.org/TR/2001/REC-smil-animation-20010904/ SMIL specification] (Synchronized Multimedia Integration Language) and extends it (SVG is said to be a ''host'' language of SMIL).&lt;br /&gt;
&lt;br /&gt;
Here I only focus on procedural animation and not programmatic animation (using a scripting language manipulating the DOM). &lt;br /&gt;
&lt;br /&gt;
In SMIL an animation is an object which defines the evolution of a given attribute of a given object (here an SVG element - path, rect, group...) over time. Multiple animations can control the evolution of particular attribute: for example, one will tell the object to turn for 1 second starting at t=0 second and another to move across the document for 2 seconds starting at a later time. So we have this relation:&lt;br /&gt;
             1:n&lt;br /&gt;
  Element &amp;lt;-------&amp;gt; Animation&lt;br /&gt;
&lt;br /&gt;
For a given animation the element which is controlled is called the '''target''' element of the animation. The specific attribute/property which is controlled is called the '''target''' attribute/property.&lt;br /&gt;
&lt;br /&gt;
In fact, it's completely legal to have two animations that control the same attribute of the same element, and they can overlap in time: at any particular time there exists a ''stack'' of animations applying to a particular attribute, and SMIL defines the order in which each animation is applied.&lt;br /&gt;
&lt;br /&gt;
== Animation elements ==&lt;br /&gt;
&lt;br /&gt;
SVG defines 5 animation elements:&lt;br /&gt;
* '''animate'''&lt;br /&gt;
This element is used to animate any scalar attribute or property, such as the &amp;lt;code&amp;gt;width&amp;lt;/code&amp;gt; attribute of an svg:rect element or the CCS property &amp;lt;code&amp;gt;opacity&amp;lt;/code&amp;gt;&lt;br /&gt;
* '''animateMotion'''&lt;br /&gt;
This elements only controls the position of a SVG element, by telling it to follow a given path&lt;br /&gt;
* '''animateColor'''&lt;br /&gt;
This element controls the animation of color valued attributes and properties.&lt;br /&gt;
* '''animateTransform'''&lt;br /&gt;
This element controls the transformation which applies to the target element. It replaces or adds up to the &amp;lt;code&amp;gt;transform&amp;lt;/code&amp;gt; attribute of the element.&lt;br /&gt;
* '''set'''&lt;br /&gt;
This element is used to set a particular value for the target attribute during a specified time interval. It is mainly used for animating attributes which do not span a continuous domain, such as boolean values like the &amp;lt;code&amp;gt;visibility&amp;lt;/code&amp;gt; property.&lt;br /&gt;
&lt;br /&gt;
== Specifying the target element and property ==&lt;br /&gt;
&lt;br /&gt;
There are 2 ways to tell which element a given animation will target. The first one is to embed the [[#Animation elements|animation element]] as a child tag of the element to animate. Here is an example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;circle cx=&amp;quot;100px&amp;quot; cy=&amp;quot;100px&amp;quot; r=&amp;quot;20px&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;animate attributeName=&amp;quot;r&amp;quot; attributeType=&amp;quot;XML&amp;quot; begin=&amp;quot;1s&amp;quot; dur=&amp;quot;2s&amp;quot; from=&amp;quot;20px&amp;quot; to=&amp;quot;50px&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/circle&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;animate&amp;lt;/code&amp;gt; element targets the radius (&amp;lt;code&amp;gt;r&amp;lt;/code&amp;gt;) property of the parent &amp;lt;code&amp;gt;circle&amp;lt;/code&amp;gt; element. Starting 1 second after the document start, the radius will grow for 2 seconds from 20 pixels to 50 pixels. When nothing else is specified, the animation only applies in its interval of time, here [1-3] seconds; from 0 to 1 second and then from 3 second and after, the circle's radius is set back to its ''static'' attribute value, here 20 pixels.&lt;br /&gt;
&lt;br /&gt;
The other way to specify the target element is to reference it in via an &amp;lt;code&amp;gt;xlink:href&amp;lt;/code&amp;gt; attribute of the animation element. the previous animation could be written this way:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;circle id=&amp;quot;balloon&amp;quot; cx=&amp;quot;100px&amp;quot; cy=&amp;quot;100px&amp;quot; r=&amp;quot;20px&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;animate xlink:href=&amp;quot;#balloon&amp;quot; attributeName=&amp;quot;r&amp;quot; attributeType=&amp;quot;XML&amp;quot; begin=&amp;quot;1s&amp;quot; dur=&amp;quot;2s&amp;quot; from=&amp;quot;20px&amp;quot; to=&amp;quot;50px&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To specify which property or attribute of the target element is controlled, we use the two attributes &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;attributeType&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; explains itself, it's the name of the controlled attribute. &amp;lt;code&amp;gt;attributeType&amp;lt;/code&amp;gt; tells whether &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; is searched among the SVG attributes of the element (&amp;lt;code&amp;gt;attributeType=&amp;quot;XML&amp;quot;&amp;lt;/code&amp;gt;) or among the CSS properties of the element (&amp;lt;code&amp;gt;attributeType=&amp;quot;CSS&amp;quot;&amp;lt;/code&amp;gt;). [http://www.w3.org/TR/SVG11/animate.html#TargetElement (SPEC)]&lt;br /&gt;
&lt;br /&gt;
== Timing an animation ==&lt;br /&gt;
&lt;br /&gt;
The first thing to stress is that SMIL (and therefore SVG) animation is '''time-based''', as opposed to '''frame-based'''. '''Frame-based''' animation is something traditional animators are used to, because they actually draw each image of the animation on a separate celluloid sheet, and the timing is related to the rate of images per second the camera will capture. When animation is done on a computer, the animator doesn't draw every image but only some ''key'' images (or ''keyframes'') and then the animation software creates all the necessary images for him (the so-called ''in-betweens''). That means the animator can focus back to a (real-)time based timing. Each keyframe is positioned on a timeline with real time values (instead of frame numbers). Of course at the end the animation is discrete and there is a fixed number of images computed inbetween two keyframes, but the neat property of specifying keyframes at time position is that the final animation frame rate is scalable and the animator doesn't have to care about it anymore. He just tells the software to produce 24 images each second if he targets a theatre film or say 10 images per second for low-bandwidth web animation. The animator doesn't need to reposition the keyframes.&lt;br /&gt;
&lt;br /&gt;
=== In-betweening by interpolation ===&lt;br /&gt;
&lt;br /&gt;
Creating the inbetween images on a computer is done by mean of '''interpolation'''. Interpolation is a mathematical tool that can reconstruct a the continuous evolution of a parameter given a set of discrete values of this parameter over time.&lt;br /&gt;
The following image illustrates that. We know that some attribute A must take value A0, A1, A2 and A3 at times t0, t1, t2 and t3. The red curves is one of the possible continuous function that be used to compute inbetween values of A in the interval [t0, t3].&lt;br /&gt;
&lt;br /&gt;
[[Image:interpolation.png]]&lt;br /&gt;
&lt;br /&gt;
* which extent of time ?&lt;br /&gt;
* Which extent of time ?&lt;br /&gt;
The first aspect that characterizes an animation is the interval of time on which it applies: when does it begin, when does it end or how long does it run.&lt;br /&gt;
Any of the above mentioned [[#Animation elements|animation elements] accept the attributes &amp;lt;code&amp;gt;begin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;dur&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
There are many ways to define a particular point in time and this is what makes SMIL a very rich animation framework (see below). The simplest is to specify a clock-value which syntax is quite intuitive [http://www.w3.org/TR/SVG11/animate.html#ClockValueSyntax (SPEC)]. Depending on the combination of those 3 attributes, the interval of time of the animation will be [begin, end], [begin, begin+dur], [end-dur, end], etc.&lt;br /&gt;
&lt;br /&gt;
To specify the values taken over the time interval, one need to tell the value that the parameter must have at the begin and at the end of the interval. here again those values are specified by combinations of three attributes: &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;by&amp;lt;/code&amp;gt;. The attribute &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt; correspond to the begin value, the attribute &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; correspond to the end value. The attribute &amp;lt;code&amp;gt;by&amp;lt;/code&amp;gt; let you define either the initial and final values relative to the other one, that is to = from + by or from = to - by. The following image illusttrate this setup for our hypothetical attribute A&lt;br /&gt;
&lt;br /&gt;
[[Image:time_interval.png]]&lt;br /&gt;
&lt;br /&gt;
The values of A are simply interpolated '''linearly''' in between begin and end. This is the more simple form of '''animation function''' that can defined: by the two extremal pairs of (time, attribute value): (begin, from) and (end, to).&lt;br /&gt;
&lt;br /&gt;
=== More complex timing ===&lt;br /&gt;
&lt;br /&gt;
It's possible to specify a whole set of (keytime, keyvalue) pairs to define the animation function. Each item of the pairs are actually given separately:&lt;br /&gt;
* the set of attribute values (keyvalues) are given by the &amp;lt;code&amp;gt;values&amp;lt;/code&amp;gt; attribute.&lt;br /&gt;
* the set of time values (keytimes) are given by the &amp;lt;code&amp;gt;keyTimes&amp;lt;/code&amp;gt; attribute.&lt;br /&gt;
&lt;br /&gt;
Each set as the form of a semicolon-separated list of values. The thing to notice is that the keytimes are actually '''normalized to [0,1]''', which means that 0 maps to begin and 1 maps to end, and those values must start and end the list of keytimes. The image below illustrates all this:&lt;br /&gt;
&lt;br /&gt;
[[Image:time_interval2.png]]&lt;br /&gt;
&lt;br /&gt;
The keyTimes list can actually be omitted. In this cases the keytimes are evenly in interval [0,1] (equivalently, evenly in the interval [begin, end])&lt;br /&gt;
&lt;br /&gt;
The (keytime, keyvalue) pairs are joined by straight lines in the above graph, which means that we use '''linear interpolation''' for computing the inbetween values. &lt;br /&gt;
&lt;br /&gt;
When applied to the position of an object, linear interpolation results in un-natural robot-like motions (which may the effect wanted). SMIL allows smoother animations by defining '''spline-based interpolation''' between two (keytime, keyvalue) pairs. For each interval (t0, v0) - (t1, v1) a spline can be defined by two control points defining the tangents of the spline at t0 and t1. Those control points are passed in the attribute &amp;lt;code&amp;gt;keySplines&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:spline_interpolation.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Two other interpolation modes are possible:&lt;br /&gt;
* '''discrete''': this is a degenerate form of interpolation, because the resulting animation function is not continuous. For each interval (t0,v0) - (t1, v1), the attribute value is set to v0 for the whole interval. It ''jumps'' to v1 right when t1 is reached and so on.&lt;br /&gt;
* '''paced''': in this interpolation mode, the attribute is interpolated so that its evolution over time has '''constant speed'''. Because the animation function is defined implicitly, the attribute &amp;lt;code&amp;gt;keyTimes&amp;lt;/code&amp;gt; is not taken into account. This mode is mainly useful for the &amp;lt;code&amp;gt;animateMotion&amp;lt;/code&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
=== Other aspects of animation ===&lt;br /&gt;
* repeating&lt;br /&gt;
* chaining animations.&lt;br /&gt;
* event based synchronisation&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
Examples showcasing some of the effects that can be achieved using procedural animation in SVG.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1px&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 1 --&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces on the floor: there are 6 motions here: fall, squeeze, squeeze-offset and bounce unsqueeze and unsqueeze-offset that are the revert version of 3 first. A classic animation trick is to start squeezing the ball a little before it touches the floor, expressed here by the synchronization &amp;lt;code&amp;gt;begin=fall.end - 0.1s&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td rowspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;path&lt;br /&gt;
   ...&lt;br /&gt;
   transform=&amp;quot;translate(0,4.5456868)&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;animateTransform&lt;br /&gt;
         type=&amp;quot;translate&amp;quot;&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot;&lt;br /&gt;
         from=&amp;quot;0, 0&amp;quot;&lt;br /&gt;
         to=&amp;quot;0, 136&amp;quot;&lt;br /&gt;
         dur=&amp;quot;1s&amp;quot;&lt;br /&gt;
         begin=&amp;quot;0s&amp;quot;&lt;br /&gt;
         attributeType=&amp;quot;XML&amp;quot;&lt;br /&gt;
         attributeName=&amp;quot;transform&amp;quot;&lt;br /&gt;
         id=&amp;quot;fall&amp;quot;&lt;br /&gt;
         keySplines=&amp;quot;0.5 0  0.8 0.5 &amp;quot;&lt;br /&gt;
         calcMode=&amp;quot;spline&amp;quot; /&amp;gt;&lt;br /&gt;
      &amp;lt;animateTransform&lt;br /&gt;
         id=&amp;quot;squeeze&amp;quot;&lt;br /&gt;
         type=&amp;quot;scale&amp;quot;&lt;br /&gt;
         from=&amp;quot;1,1&amp;quot;&lt;br /&gt;
         to=&amp;quot;1.1,0.9&amp;quot;&lt;br /&gt;
         begin=&amp;quot;fall.end-0.1s&amp;quot;&lt;br /&gt;
         attributeName=&amp;quot;transform&amp;quot;&lt;br /&gt;
         attributeType=&amp;quot;XML&amp;quot;&lt;br /&gt;
         dur=&amp;quot;0.2s&amp;quot;&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot; /&amp;gt;&lt;br /&gt;
      &amp;lt;animateTransform&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot;&lt;br /&gt;
         dur=&amp;quot;0.2s&amp;quot;&lt;br /&gt;
         attributeType=&amp;quot;XML&amp;quot;&lt;br /&gt;
         attributeName=&amp;quot;transform&amp;quot;&lt;br /&gt;
         begin=&amp;quot;fall.end-0.1s&amp;quot;&lt;br /&gt;
         to=&amp;quot;-13,0&amp;quot;&lt;br /&gt;
         from=&amp;quot;0,0&amp;quot;&lt;br /&gt;
         type=&amp;quot;translate&amp;quot;&lt;br /&gt;
         id=&amp;quot;squeeze-offset&amp;quot;&lt;br /&gt;
         accumulate=&amp;quot;sum&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball1.png]]&lt;br /&gt;
[http://wiki.inkscape.org/wiki/images/Bouncing_ball1.svg SVG file] |&lt;br /&gt;
[http://www.cdehais.fr/~tof/svg/bouncing_ball1.ogg ogg video]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 2 --&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces between two wall, following a path.&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td rowspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;path&lt;br /&gt;
       ...&lt;br /&gt;
       sodipodi:type=&amp;quot;arc&amp;quot;&lt;br /&gt;
       id=&amp;quot;ball&amp;quot; &lt;br /&gt;
       ... &lt;br /&gt;
&amp;gt;&lt;br /&gt;
      &amp;lt;animateMotion&lt;br /&gt;
         keyTimes=&amp;quot;0; 0.20; 1&amp;quot;&lt;br /&gt;
         keyPoints=&amp;quot;0; 0.33; 1&amp;quot;&lt;br /&gt;
         repeatCount=&amp;quot;indefinite&amp;quot;&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot;&lt;br /&gt;
         rotate=&amp;quot;0&amp;quot;&lt;br /&gt;
         begin=&amp;quot;0s&amp;quot;&lt;br /&gt;
         dur=&amp;quot;2s&amp;quot;&lt;br /&gt;
         calcMode=&amp;quot;linear&amp;quot;&lt;br /&gt;
         id=&amp;quot;animateMotion2680&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;mpath&lt;br /&gt;
           xlink:href=&amp;quot;#motion_path&amp;quot;&lt;br /&gt;
           id=&amp;quot;mpath2682&amp;quot; /&amp;gt;&lt;br /&gt;
      &amp;lt;/animateMotion&amp;gt;&lt;br /&gt;
&amp;lt;/path&amp;gt;&lt;br /&gt;
&amp;lt;path&lt;br /&gt;
   d=&amp;quot;M 82.080559,103.82375 ...&amp;quot;&lt;br /&gt;
   id=&amp;quot;motion_path&amp;quot; ... /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball2.png]]&lt;br /&gt;
[http://wiki.inkscape.org/wiki/images/Bouncing_ball2.svg SVG file] |&lt;br /&gt;
[http://www.cdehais.fr/~tof/svg/bouncing_ball2.ogg ogg video]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 3 --&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces between 2 walls. The motion is defined as a combination a of vertical translation and a horizontal translation. This works because the second animation has an &amp;lt;code&amp;gt;additive=&amp;quot;sum&amp;quot;&amp;lt;/code&amp;gt; attribute, so the corresponding matrix is composited with the matrix defined by the underlying animations.&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td rowspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
&amp;lt;!-- two animation sharing the same path --&amp;gt;&lt;br /&gt;
  &amp;lt;animateMotion&lt;br /&gt;
     id=&amp;quot;animateMotion2302&amp;quot;&lt;br /&gt;
     xlink:href=&amp;quot;#arrow2&amp;quot;&lt;br /&gt;
     dur=&amp;quot;4s&amp;quot;&lt;br /&gt;
     keyTimes=&amp;quot;0; 0.5; 1&amp;quot;&lt;br /&gt;
     keyPoints=&amp;quot;0; 1; 0&amp;quot;&lt;br /&gt;
     calcMode=&amp;quot;linear&amp;quot;&lt;br /&gt;
     repeatCount=&amp;quot;indefinite&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;mpath&lt;br /&gt;
       id=&amp;quot;mpath2305&amp;quot;&lt;br /&gt;
       xlink:href=&amp;quot;#horiz-bounce&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/animateMotion&amp;gt;&lt;br /&gt;
  &amp;lt;animateMotion&lt;br /&gt;
     calcMode=&amp;quot;linear&amp;quot;&lt;br /&gt;
     keyPoints=&amp;quot;0; 1; 0&amp;quot;&lt;br /&gt;
     keyTimes=&amp;quot;0; 0.5; 1&amp;quot;&lt;br /&gt;
     dur=&amp;quot;4s&amp;quot;&lt;br /&gt;
     xlink:href=&amp;quot;#ball&amp;quot;&lt;br /&gt;
     id=&amp;quot;animateMotion2309&amp;quot;&lt;br /&gt;
     repeatCount=&amp;quot;indefinite&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;mpath&lt;br /&gt;
       xlink:href=&amp;quot;#horiz-bounce&amp;quot;&lt;br /&gt;
       id=&amp;quot;mpath2311&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/animateMotion&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
  &amp;lt;animateMotion&lt;br /&gt;
     keySplines=&amp;quot;0.5 0 0.75 0.75, 0 0.5 0.5 0.75&amp;quot;&lt;br /&gt;
     keyPoints=&amp;quot;0;  1; 0&amp;quot;&lt;br /&gt;
     calcMode=&amp;quot;spline&amp;quot;&lt;br /&gt;
     keyTimes=&amp;quot;0;  0.5; 1&amp;quot;&lt;br /&gt;
     id=&amp;quot;animateMotion2298&amp;quot;&lt;br /&gt;
     begin=&amp;quot;0s&amp;quot;&lt;br /&gt;
     dur=&amp;quot;2s&amp;quot;&lt;br /&gt;
     xlink:href=&amp;quot;#ball&amp;quot;&lt;br /&gt;
     additive=&amp;quot;sum&amp;quot;&lt;br /&gt;
     repeatCount=&amp;quot;indefinite&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;mpath&lt;br /&gt;
       id=&amp;quot;mpath2300&amp;quot;&lt;br /&gt;
       xlink:href=&amp;quot;#vert-bounce&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/animateMotion&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball3.png]]&lt;br /&gt;
[http://wiki.inkscape.org/wiki/images/Bouncing_ball3.svg SVG file] |&lt;br /&gt;
[http://www.cdehais.fr/~tof/svg/bouncing_ball3.ogg ogg video]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Useful tools ==&lt;br /&gt;
&lt;br /&gt;
* [http://xmlgraphics.apache.org/batik/tools/browser.html Squiggle ], as part of [http://xmlgraphics.apache.org/batik/ Batik 1.7] has a nearly complete support for SMIL Animation. The [[#Examples|examples]] were all rendered using Squiggle.&lt;br /&gt;
* Inkscape ! I used the xml editor to manually add the animation elements for my test. It's a bit more cumbersome than editing the svg file in a text editor, but doing that in Inkscape eases the computation of key positions (just move the object around and read the position values).&lt;br /&gt;
&lt;br /&gt;
== Various thoughts ==&lt;br /&gt;
&lt;br /&gt;
* There is no direct way to specify a &amp;lt;b&amp;gt;''ping-pong'' animation&amp;lt;/b&amp;gt; in SVG, that is to tell an animation to go back in time when it reaches it's end. To implement this, I see 2 solutions:&lt;br /&gt;
**double the duration d of the animation (&amp;lt;code&amp;gt;dur&amp;lt;/code&amp;gt; attribute) et apply a scale and a symetry around t=0.5 to the animation function. For example the simple linear interpolation defined by &amp;lt;code&amp;gt;keyTimes=&amp;quot;0; 1&amp;quot;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;keyPoints=&amp;quot;0;1&amp;quot;&amp;lt;/code&amp;gt; becomes &amp;lt;code&amp;gt;keyTimes=&amp;quot;0; 0.5; 1&amp;quot;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;keyPoints=&amp;quot;0;1;0&amp;quot;&amp;lt;/code&amp;gt;. This doesn't work for &amp;lt;code&amp;gt;paced&amp;lt;/code&amp;gt; animation though (which make use of an implicit, user-agent dependent animation function).&lt;br /&gt;
** copy the original animation (call it e.g. &amp;lt;code&amp;gt;motion_forward&amp;lt;/code&amp;gt;) and swap the &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; values in the copy. Then specify &amp;lt;code&amp;gt;begin=&amp;quot;motion_forward.end&amp;quot;&amp;lt;/code&amp;gt; to tell the backward animation to start right at the end of the forward animation. This should work for every animation type.&lt;br /&gt;
&lt;br /&gt;
The question is: what maps best to a UI ?&lt;/div&gt;</summary>
		<author><name>ToF</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=File:Bouncing_ball3.svg&amp;diff=23624</id>
		<title>File:Bouncing ball3.svg</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=File:Bouncing_ball3.svg&amp;diff=23624"/>
		<updated>2008-03-09T22:38:35Z</updated>

		<summary type="html">&lt;p&gt;ToF: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>ToF</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=File:Bouncing_ball2.svg&amp;diff=23614</id>
		<title>File:Bouncing ball2.svg</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=File:Bouncing_ball2.svg&amp;diff=23614"/>
		<updated>2008-03-09T22:38:18Z</updated>

		<summary type="html">&lt;p&gt;ToF: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>ToF</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=File:Bouncing_ball1.svg&amp;diff=23604</id>
		<title>File:Bouncing ball1.svg</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=File:Bouncing_ball1.svg&amp;diff=23604"/>
		<updated>2008-03-09T22:30:24Z</updated>

		<summary type="html">&lt;p&gt;ToF: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>ToF</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation&amp;diff=23594</id>
		<title>SVG Animation</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation&amp;diff=23594"/>
		<updated>2008-03-09T22:29:42Z</updated>

		<summary type="html">&lt;p&gt;ToF: /* Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is a '''work in progress'''. [[User:ToF|ToF]]&lt;br /&gt;
&lt;br /&gt;
== SVG Animation ==&lt;br /&gt;
&lt;br /&gt;
Animation in SVG is defined in the Animation Module of the [http://www.w3.org/TR/SVG11/animate.html SVG specification]. Animation in SVG conforms to the [http://www.w3.org/TR/2001/REC-smil-animation-20010904/ SMIL specification] (Synchronized Multimedia Integration Language) and extends it (SVG is said to be a ''host'' language of SMIL).&lt;br /&gt;
&lt;br /&gt;
Here I only focus on procedural animation and not programmatic animation (using a scripting language manipulating the DOM). &lt;br /&gt;
&lt;br /&gt;
In SMIL an animation is an object which defines the evolution of a given attribute of a given object (here an SVG element - path, rect, group...) over time. Multiple animations can control the evolution of particular attribute: for example, one will tell the object to turn for 1 second starting at t=0 second and another to move across the document for 2 seconds starting at a later time. So we have this relation:&lt;br /&gt;
             1:n&lt;br /&gt;
  Element &amp;lt;-------&amp;gt; Animation&lt;br /&gt;
&lt;br /&gt;
For a given animation the element which is controlled is called the '''target''' element of the animation. The specific attribute/property which is controlled is called the '''target''' attribute/property.&lt;br /&gt;
&lt;br /&gt;
In fact, it's completely legal to have two animations that control the same attribute of the same element, and they can overlap in time: at any particular time there exists a ''stack'' of animations applying to a particular attribute, and SMIL defines the order in which each animation is applied.&lt;br /&gt;
&lt;br /&gt;
== Animation elements ==&lt;br /&gt;
&lt;br /&gt;
SVG defines 5 animation elements:&lt;br /&gt;
* '''animate'''&lt;br /&gt;
This element is used to animate any scalar attribute or property, such as the &amp;lt;code&amp;gt;width&amp;lt;/code&amp;gt; attribute of an svg:rect element or the CCS property &amp;lt;code&amp;gt;opacity&amp;lt;/code&amp;gt;&lt;br /&gt;
* '''animateMotion'''&lt;br /&gt;
This elements only controls the position of a SVG element, by telling it to follow a given path&lt;br /&gt;
* '''animateColor'''&lt;br /&gt;
This element controls the animation of color valued attributes and properties.&lt;br /&gt;
* '''animateTransform'''&lt;br /&gt;
This element controls the transformation which applies to the target element. It replaces or adds up to the &amp;lt;code&amp;gt;transform&amp;lt;/code&amp;gt; attribute of the element.&lt;br /&gt;
* '''set'''&lt;br /&gt;
This element is used to set a particular value for the target attribute during a specified time interval. It is mainly used for animating attributes which do not span a continuous domain, such as boolean values like the &amp;lt;code&amp;gt;visibility&amp;lt;/code&amp;gt; property.&lt;br /&gt;
&lt;br /&gt;
== Specifying the target element and property ==&lt;br /&gt;
&lt;br /&gt;
There are 2 ways to tell which element a given animation will target. The first one is to embed the [[#Animation elements|animation element]] as a child tag of the element to animate. Here is an example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;circle cx=&amp;quot;100px&amp;quot; cy=&amp;quot;100px&amp;quot; r=&amp;quot;20px&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;animate attributeName=&amp;quot;r&amp;quot; attributeType=&amp;quot;XML&amp;quot; begin=&amp;quot;1s&amp;quot; dur=&amp;quot;2s&amp;quot; from=&amp;quot;20px&amp;quot; to=&amp;quot;50px&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/circle&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;animate&amp;lt;/code&amp;gt; element targets the radius (&amp;lt;code&amp;gt;r&amp;lt;/code&amp;gt;) property of the parent &amp;lt;code&amp;gt;circle&amp;lt;/code&amp;gt; element. Starting 1 second after the document start, the radius will grow for 2 seconds from 20 pixels to 50 pixels. When nothing else is specified, the animation only applies in its interval of time, here [1-3] seconds; from 0 to 1 second and then from 3 second and after, the circle's radius is set back to its ''static'' attribute value, here 20 pixels.&lt;br /&gt;
&lt;br /&gt;
The other way to specify the target element is to reference it in via an &amp;lt;code&amp;gt;xlink:href&amp;lt;/code&amp;gt; attribute of the animation element. the previous animation could be written this way:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;circle id=&amp;quot;balloon&amp;quot; cx=&amp;quot;100px&amp;quot; cy=&amp;quot;100px&amp;quot; r=&amp;quot;20px&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;animate xlink:href=&amp;quot;#balloon&amp;quot; attributeName=&amp;quot;r&amp;quot; attributeType=&amp;quot;XML&amp;quot; begin=&amp;quot;1s&amp;quot; dur=&amp;quot;2s&amp;quot; from=&amp;quot;20px&amp;quot; to=&amp;quot;50px&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To specify which property or attribute of the target element is controlled, we use the two attributes &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;attributeType&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; explains itself, it's the name of the controlled attribute. &amp;lt;code&amp;gt;attributeType&amp;lt;/code&amp;gt; tells whether &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; is searched among the SVG attributes of the element (&amp;lt;code&amp;gt;attributeType=&amp;quot;XML&amp;quot;&amp;lt;/code&amp;gt;) or among the CSS properties of the element (&amp;lt;code&amp;gt;attributeType=&amp;quot;CSS&amp;quot;&amp;lt;/code&amp;gt;). [http://www.w3.org/TR/SVG11/animate.html#TargetElement (SPEC)]&lt;br /&gt;
&lt;br /&gt;
== Timing an animation ==&lt;br /&gt;
&lt;br /&gt;
The first thing to stress is that SMIL (and therefore SVG) animation is '''time-based''', as opposed to '''frame-based'''. '''Frame-based''' animation is something traditional animators are used to, because they actually draw each image of the animation on a separate celluloid sheet, and the timing is related to the rate of images per second the camera will capture. When animation is done on a computer, the animator doesn't draw every image but only some ''key'' images (or ''keyframes'') and then the animation software creates all the necessary images for him (the so-called ''in-betweens''). That means the animator can focus back to a (real-)time based timing. Each keyframe is positioned on a timeline with real time values (instead of frame numbers). Of course at the end the animation is discrete and there is a fixed number of images computed inbetween two keyframes, but the neat property of specifying keyframes at time position is that the final animation frame rate is scalable and the animator doesn't have to care about it anymore. He just tells the software to produce 24 images each second if he targets a theatre film or say 10 images per second for low-bandwidth web animation. The animator doesn't need to reposition the keyframes.&lt;br /&gt;
&lt;br /&gt;
=== In-betweening by interpolation ===&lt;br /&gt;
&lt;br /&gt;
Creating the inbetween images on a computer is done by mean of '''interpolation'''. Interpolation is a mathematical tool that can reconstruct a the continuous evolution of a parameter given a set of discrete values of this parameter over time.&lt;br /&gt;
The following image illustrates that. We know that some attribute A must take value A0, A1, A2 and A3 at times t0, t1, t2 and t3. The red curves is one of the possible continuous function that be used to compute inbetween values of A in the interval [t0, t3].&lt;br /&gt;
&lt;br /&gt;
[[Image:interpolation.png]]&lt;br /&gt;
&lt;br /&gt;
* which extent of time ?&lt;br /&gt;
* Which extent of time ?&lt;br /&gt;
The first aspect that characterizes an animation is the interval of time on which it applies: when does it begin, when does it end or how long does it run.&lt;br /&gt;
Any of the above mentioned [[#Animation elements|animation elements] accept the attributes &amp;lt;code&amp;gt;begin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;dur&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
There are many ways to define a particular point in time and this is what makes SMIL a very rich animation framework (see below). The simplest is to specify a clock-value which syntax is quite intuitive [http://www.w3.org/TR/SVG11/animate.html#ClockValueSyntax (SPEC)]. Depending on the combination of those 3 attributes, the interval of time of the animation will be [begin, end], [begin, begin+dur], [end-dur, end], etc.&lt;br /&gt;
&lt;br /&gt;
To specify the values taken over the time interval, one need to tell the value that the parameter must have at the begin and at the end of the interval. here again those values are specified by combinations of three attributes: &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;by&amp;lt;/code&amp;gt;. The attribute &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt; correspond to the begin value, the attribute &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; correspond to the end value. The attribute &amp;lt;code&amp;gt;by&amp;lt;/code&amp;gt; let you define either the initial and final values relative to the other one, that is to = from + by or from = to - by. The following image illusttrate this setup for our hypothetical attribute A&lt;br /&gt;
&lt;br /&gt;
[[Image:time_interval.png]]&lt;br /&gt;
&lt;br /&gt;
The values of A are simply interpolated '''linearly''' in between begin and end. This is the more simple form of '''animation function''' that can defined: by the two extremal pairs of (time, attribute value): (begin, from) and (end, to).&lt;br /&gt;
&lt;br /&gt;
=== More complex timing ===&lt;br /&gt;
&lt;br /&gt;
It's possible to specify a whole set of (keytime, keyvalue) pairs to define the animation function. Each item of the pairs are actually given separately:&lt;br /&gt;
* the set of attribute values (keyvalues) are given by the &amp;lt;code&amp;gt;values&amp;lt;/code&amp;gt; attribute.&lt;br /&gt;
* the set of time values (keytimes) are given by the &amp;lt;code&amp;gt;keyTimes&amp;lt;/code&amp;gt; attribute.&lt;br /&gt;
&lt;br /&gt;
Each set as the form of a semicolon-separated list of values. The thing to notice is that the keytimes are actually '''normalized to [0,1]''', which means that 0 maps to begin and 1 maps to end, and those values must start and end the list of keytimes. The image below illustrates all this:&lt;br /&gt;
&lt;br /&gt;
[[Image:time_interval2.png]]&lt;br /&gt;
&lt;br /&gt;
The keyTimes list can actually be omitted. In this cases the keytimes are evenly in interval [0,1] (equivalently, evenly in the interval [begin, end])&lt;br /&gt;
&lt;br /&gt;
The (keytime, keyvalue) pairs are joined by straight lines in the above graph, which means that we use '''linear interpolation''' for computing the inbetween values. &lt;br /&gt;
&lt;br /&gt;
When applied to the position of an object, linear interpolation results in un-natural robot-like motions (which may the effect wanted). SMIL allows smoother animations by defining '''spline-based interpolation''' between two (keytime, keyvalue) pairs. For each interval (t0, v0) - (t1, v1) a spline can be defined by two control points defining the tangents of the spline at t0 and t1. Those control points are passed in the attribute &amp;lt;code&amp;gt;keySplines&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:spline_interpolation.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Two other interpolation modes are possible:&lt;br /&gt;
* '''discrete''': this is a degenerate form of interpolation, because the resulting animation function is not continuous. For each interval (t0,v0) - (t1, v1), the attribute value is set to v0 for the whole interval. It ''jumps'' to v1 right when t1 is reached and so on.&lt;br /&gt;
* '''paced''': in this interpolation mode, the attribute is interpolated so that its evolution over time has '''constant speed'''. Because the animation function is defined implicitly, the attribute &amp;lt;code&amp;gt;keyTimes&amp;lt;/code&amp;gt; is not taken into account. This mode is mainly useful for the &amp;lt;code&amp;gt;animateMotion&amp;lt;/code&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
=== Other aspects of animation ===&lt;br /&gt;
* repeating&lt;br /&gt;
* chaining animations.&lt;br /&gt;
* event based synchronisation&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
Examples showcasing some of the effects that can be achieved using procedural animation in SVG.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1px&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 1 --&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces on the floor: there are 6 motions here: fall, squeeze, squeeze-offset and bounce unsqueeze and unsqueeze-offset that are the revert version of 3 first. A classic animation trick is to start squeezing the ball a little before it touches the floor, expressed here by the synchronization &amp;lt;code&amp;gt;begin=fall.end - 0.1s&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td rowspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;path&lt;br /&gt;
   ...&lt;br /&gt;
   transform=&amp;quot;translate(0,4.5456868)&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;animateTransform&lt;br /&gt;
         type=&amp;quot;translate&amp;quot;&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot;&lt;br /&gt;
         from=&amp;quot;0, 0&amp;quot;&lt;br /&gt;
         to=&amp;quot;0, 136&amp;quot;&lt;br /&gt;
         dur=&amp;quot;1s&amp;quot;&lt;br /&gt;
         begin=&amp;quot;0s&amp;quot;&lt;br /&gt;
         attributeType=&amp;quot;XML&amp;quot;&lt;br /&gt;
         attributeName=&amp;quot;transform&amp;quot;&lt;br /&gt;
         id=&amp;quot;fall&amp;quot;&lt;br /&gt;
         keySplines=&amp;quot;0.5 0  0.8 0.5 &amp;quot;&lt;br /&gt;
         calcMode=&amp;quot;spline&amp;quot; /&amp;gt;&lt;br /&gt;
      &amp;lt;animateTransform&lt;br /&gt;
         id=&amp;quot;squeeze&amp;quot;&lt;br /&gt;
         type=&amp;quot;scale&amp;quot;&lt;br /&gt;
         from=&amp;quot;1,1&amp;quot;&lt;br /&gt;
         to=&amp;quot;1.1,0.9&amp;quot;&lt;br /&gt;
         begin=&amp;quot;fall.end-0.1s&amp;quot;&lt;br /&gt;
         attributeName=&amp;quot;transform&amp;quot;&lt;br /&gt;
         attributeType=&amp;quot;XML&amp;quot;&lt;br /&gt;
         dur=&amp;quot;0.2s&amp;quot;&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot; /&amp;gt;&lt;br /&gt;
      &amp;lt;animateTransform&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot;&lt;br /&gt;
         dur=&amp;quot;0.2s&amp;quot;&lt;br /&gt;
         attributeType=&amp;quot;XML&amp;quot;&lt;br /&gt;
         attributeName=&amp;quot;transform&amp;quot;&lt;br /&gt;
         begin=&amp;quot;fall.end-0.1s&amp;quot;&lt;br /&gt;
         to=&amp;quot;-13,0&amp;quot;&lt;br /&gt;
         from=&amp;quot;0,0&amp;quot;&lt;br /&gt;
         type=&amp;quot;translate&amp;quot;&lt;br /&gt;
         id=&amp;quot;squeeze-offset&amp;quot;&lt;br /&gt;
         accumulate=&amp;quot;sum&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball1.png]]&lt;br /&gt;
[[Image:bouncing_ball1.svg|SVG file]] |&lt;br /&gt;
[http://www.cdehais.fr/~tof/svg/bouncing_ball1.ogg ogg video]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 2 --&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces between two wall, following a path.&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td rowspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;path&lt;br /&gt;
       ...&lt;br /&gt;
       sodipodi:type=&amp;quot;arc&amp;quot;&lt;br /&gt;
       id=&amp;quot;ball&amp;quot; &lt;br /&gt;
       ... &lt;br /&gt;
&amp;gt;&lt;br /&gt;
      &amp;lt;animateMotion&lt;br /&gt;
         keyTimes=&amp;quot;0; 0.20; 1&amp;quot;&lt;br /&gt;
         keyPoints=&amp;quot;0; 0.33; 1&amp;quot;&lt;br /&gt;
         repeatCount=&amp;quot;indefinite&amp;quot;&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot;&lt;br /&gt;
         rotate=&amp;quot;0&amp;quot;&lt;br /&gt;
         begin=&amp;quot;0s&amp;quot;&lt;br /&gt;
         dur=&amp;quot;2s&amp;quot;&lt;br /&gt;
         calcMode=&amp;quot;linear&amp;quot;&lt;br /&gt;
         id=&amp;quot;animateMotion2680&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;mpath&lt;br /&gt;
           xlink:href=&amp;quot;#motion_path&amp;quot;&lt;br /&gt;
           id=&amp;quot;mpath2682&amp;quot; /&amp;gt;&lt;br /&gt;
      &amp;lt;/animateMotion&amp;gt;&lt;br /&gt;
&amp;lt;/path&amp;gt;&lt;br /&gt;
&amp;lt;path&lt;br /&gt;
   d=&amp;quot;M 82.080559,103.82375 ...&amp;quot;&lt;br /&gt;
   id=&amp;quot;motion_path&amp;quot; ... /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball2.png]]&lt;br /&gt;
[[Image:bouncing_ball2.svg|SVG file]] |&lt;br /&gt;
[http://www.cdehais.fr/~tof/svg/bouncing_ball2.ogg ogg video]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 3 --&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces between 2 walls. The motion is defined as a combination a of vertical translation and a horizontal translation. This works because the second animation has an &amp;lt;code&amp;gt;additive=&amp;quot;sum&amp;quot;&amp;lt;/code&amp;gt; attribute, so the corresponding matrix is composited with the matrix defined by the underlying animations.&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td rowspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
&amp;lt;!-- two animation sharing the same path --&amp;gt;&lt;br /&gt;
  &amp;lt;animateMotion&lt;br /&gt;
     id=&amp;quot;animateMotion2302&amp;quot;&lt;br /&gt;
     xlink:href=&amp;quot;#arrow2&amp;quot;&lt;br /&gt;
     dur=&amp;quot;4s&amp;quot;&lt;br /&gt;
     keyTimes=&amp;quot;0; 0.5; 1&amp;quot;&lt;br /&gt;
     keyPoints=&amp;quot;0; 1; 0&amp;quot;&lt;br /&gt;
     calcMode=&amp;quot;linear&amp;quot;&lt;br /&gt;
     repeatCount=&amp;quot;indefinite&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;mpath&lt;br /&gt;
       id=&amp;quot;mpath2305&amp;quot;&lt;br /&gt;
       xlink:href=&amp;quot;#horiz-bounce&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/animateMotion&amp;gt;&lt;br /&gt;
  &amp;lt;animateMotion&lt;br /&gt;
     calcMode=&amp;quot;linear&amp;quot;&lt;br /&gt;
     keyPoints=&amp;quot;0; 1; 0&amp;quot;&lt;br /&gt;
     keyTimes=&amp;quot;0; 0.5; 1&amp;quot;&lt;br /&gt;
     dur=&amp;quot;4s&amp;quot;&lt;br /&gt;
     xlink:href=&amp;quot;#ball&amp;quot;&lt;br /&gt;
     id=&amp;quot;animateMotion2309&amp;quot;&lt;br /&gt;
     repeatCount=&amp;quot;indefinite&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;mpath&lt;br /&gt;
       xlink:href=&amp;quot;#horiz-bounce&amp;quot;&lt;br /&gt;
       id=&amp;quot;mpath2311&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/animateMotion&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
  &amp;lt;animateMotion&lt;br /&gt;
     keySplines=&amp;quot;0.5 0 0.75 0.75, 0 0.5 0.5 0.75&amp;quot;&lt;br /&gt;
     keyPoints=&amp;quot;0;  1; 0&amp;quot;&lt;br /&gt;
     calcMode=&amp;quot;spline&amp;quot;&lt;br /&gt;
     keyTimes=&amp;quot;0;  0.5; 1&amp;quot;&lt;br /&gt;
     id=&amp;quot;animateMotion2298&amp;quot;&lt;br /&gt;
     begin=&amp;quot;0s&amp;quot;&lt;br /&gt;
     dur=&amp;quot;2s&amp;quot;&lt;br /&gt;
     xlink:href=&amp;quot;#ball&amp;quot;&lt;br /&gt;
     additive=&amp;quot;sum&amp;quot;&lt;br /&gt;
     repeatCount=&amp;quot;indefinite&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;mpath&lt;br /&gt;
       id=&amp;quot;mpath2300&amp;quot;&lt;br /&gt;
       xlink:href=&amp;quot;#vert-bounce&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/animateMotion&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball3.png]]&lt;br /&gt;
[[Image:bouncing_ball3.svg|SVG file]] |&lt;br /&gt;
[http://www.cdehais.fr/~tof/svg/bouncing_ball3.ogg ogg video]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Useful tools ==&lt;br /&gt;
&lt;br /&gt;
* [http://xmlgraphics.apache.org/batik/tools/browser.html Squiggle ], as part of [http://xmlgraphics.apache.org/batik/ Batik 1.7] has a nearly complete support for SMIL Animation. The [[#Examples|examples]] were all rendered using Squiggle.&lt;br /&gt;
* Inkscape ! I used the xml editor to manually add the animation elements for my test. It's a bit more cumbersome than editing the svg file in a text editor, but doing that in Inkscape eases the computation of key positions (just move the object around and read the position values).&lt;br /&gt;
&lt;br /&gt;
== Various thoughts ==&lt;br /&gt;
&lt;br /&gt;
* There is no direct way to specify a &amp;lt;b&amp;gt;''ping-pong'' animation&amp;lt;/b&amp;gt; in SVG, that is to tell an animation to go back in time when it reaches it's end. To implement this, I see 2 solutions:&lt;br /&gt;
**double the duration d of the animation (&amp;lt;code&amp;gt;dur&amp;lt;/code&amp;gt; attribute) et apply a scale and a symetry around t=0.5 to the animation function. For example the simple linear interpolation defined by &amp;lt;code&amp;gt;keyTimes=&amp;quot;0; 1&amp;quot;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;keyPoints=&amp;quot;0;1&amp;quot;&amp;lt;/code&amp;gt; becomes &amp;lt;code&amp;gt;keyTimes=&amp;quot;0; 0.5; 1&amp;quot;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;keyPoints=&amp;quot;0;1;0&amp;quot;&amp;lt;/code&amp;gt;. This doesn't work for &amp;lt;code&amp;gt;paced&amp;lt;/code&amp;gt; animation though (which make use of an implicit, user-agent dependent animation function).&lt;br /&gt;
** copy the original animation (call it e.g. &amp;lt;code&amp;gt;motion_forward&amp;lt;/code&amp;gt;) and swap the &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; values in the copy. Then specify &amp;lt;code&amp;gt;begin=&amp;quot;motion_forward.end&amp;quot;&amp;lt;/code&amp;gt; to tell the backward animation to start right at the end of the forward animation. This should work for every animation type.&lt;br /&gt;
&lt;br /&gt;
The question is: what maps best to a UI ?&lt;/div&gt;</summary>
		<author><name>ToF</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation&amp;diff=23544</id>
		<title>SVG Animation</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation&amp;diff=23544"/>
		<updated>2008-03-09T22:13:52Z</updated>

		<summary type="html">&lt;p&gt;ToF: /* Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is a '''work in progress'''. [[User:ToF|ToF]]&lt;br /&gt;
&lt;br /&gt;
== SVG Animation ==&lt;br /&gt;
&lt;br /&gt;
Animation in SVG is defined in the Animation Module of the [http://www.w3.org/TR/SVG11/animate.html SVG specification]. Animation in SVG conforms to the [http://www.w3.org/TR/2001/REC-smil-animation-20010904/ SMIL specification] (Synchronized Multimedia Integration Language) and extends it (SVG is said to be a ''host'' language of SMIL).&lt;br /&gt;
&lt;br /&gt;
Here I only focus on procedural animation and not programmatic animation (using a scripting language manipulating the DOM). &lt;br /&gt;
&lt;br /&gt;
In SMIL an animation is an object which defines the evolution of a given attribute of a given object (here an SVG element - path, rect, group...) over time. Multiple animations can control the evolution of particular attribute: for example, one will tell the object to turn for 1 second starting at t=0 second and another to move across the document for 2 seconds starting at a later time. So we have this relation:&lt;br /&gt;
             1:n&lt;br /&gt;
  Element &amp;lt;-------&amp;gt; Animation&lt;br /&gt;
&lt;br /&gt;
For a given animation the element which is controlled is called the '''target''' element of the animation. The specific attribute/property which is controlled is called the '''target''' attribute/property.&lt;br /&gt;
&lt;br /&gt;
In fact, it's completely legal to have two animations that control the same attribute of the same element, and they can overlap in time: at any particular time there exists a ''stack'' of animations applying to a particular attribute, and SMIL defines the order in which each animation is applied.&lt;br /&gt;
&lt;br /&gt;
== Animation elements ==&lt;br /&gt;
&lt;br /&gt;
SVG defines 5 animation elements:&lt;br /&gt;
* '''animate'''&lt;br /&gt;
This element is used to animate any scalar attribute or property, such as the &amp;lt;code&amp;gt;width&amp;lt;/code&amp;gt; attribute of an svg:rect element or the CCS property &amp;lt;code&amp;gt;opacity&amp;lt;/code&amp;gt;&lt;br /&gt;
* '''animateMotion'''&lt;br /&gt;
This elements only controls the position of a SVG element, by telling it to follow a given path&lt;br /&gt;
* '''animateColor'''&lt;br /&gt;
This element controls the animation of color valued attributes and properties.&lt;br /&gt;
* '''animateTransform'''&lt;br /&gt;
This element controls the transformation which applies to the target element. It replaces or adds up to the &amp;lt;code&amp;gt;transform&amp;lt;/code&amp;gt; attribute of the element.&lt;br /&gt;
* '''set'''&lt;br /&gt;
This element is used to set a particular value for the target attribute during a specified time interval. It is mainly used for animating attributes which do not span a continuous domain, such as boolean values like the &amp;lt;code&amp;gt;visibility&amp;lt;/code&amp;gt; property.&lt;br /&gt;
&lt;br /&gt;
== Specifying the target element and property ==&lt;br /&gt;
&lt;br /&gt;
There are 2 ways to tell which element a given animation will target. The first one is to embed the [[#Animation elements|animation element]] as a child tag of the element to animate. Here is an example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;circle cx=&amp;quot;100px&amp;quot; cy=&amp;quot;100px&amp;quot; r=&amp;quot;20px&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;animate attributeName=&amp;quot;r&amp;quot; attributeType=&amp;quot;XML&amp;quot; begin=&amp;quot;1s&amp;quot; dur=&amp;quot;2s&amp;quot; from=&amp;quot;20px&amp;quot; to=&amp;quot;50px&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/circle&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;animate&amp;lt;/code&amp;gt; element targets the radius (&amp;lt;code&amp;gt;r&amp;lt;/code&amp;gt;) property of the parent &amp;lt;code&amp;gt;circle&amp;lt;/code&amp;gt; element. Starting 1 second after the document start, the radius will grow for 2 seconds from 20 pixels to 50 pixels. When nothing else is specified, the animation only applies in its interval of time, here [1-3] seconds; from 0 to 1 second and then from 3 second and after, the circle's radius is set back to its ''static'' attribute value, here 20 pixels.&lt;br /&gt;
&lt;br /&gt;
The other way to specify the target element is to reference it in via an &amp;lt;code&amp;gt;xlink:href&amp;lt;/code&amp;gt; attribute of the animation element. the previous animation could be written this way:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;circle id=&amp;quot;balloon&amp;quot; cx=&amp;quot;100px&amp;quot; cy=&amp;quot;100px&amp;quot; r=&amp;quot;20px&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;animate xlink:href=&amp;quot;#balloon&amp;quot; attributeName=&amp;quot;r&amp;quot; attributeType=&amp;quot;XML&amp;quot; begin=&amp;quot;1s&amp;quot; dur=&amp;quot;2s&amp;quot; from=&amp;quot;20px&amp;quot; to=&amp;quot;50px&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To specify which property or attribute of the target element is controlled, we use the two attributes &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;attributeType&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; explains itself, it's the name of the controlled attribute. &amp;lt;code&amp;gt;attributeType&amp;lt;/code&amp;gt; tells whether &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; is searched among the SVG attributes of the element (&amp;lt;code&amp;gt;attributeType=&amp;quot;XML&amp;quot;&amp;lt;/code&amp;gt;) or among the CSS properties of the element (&amp;lt;code&amp;gt;attributeType=&amp;quot;CSS&amp;quot;&amp;lt;/code&amp;gt;). [http://www.w3.org/TR/SVG11/animate.html#TargetElement (SPEC)]&lt;br /&gt;
&lt;br /&gt;
== Timing an animation ==&lt;br /&gt;
&lt;br /&gt;
The first thing to stress is that SMIL (and therefore SVG) animation is '''time-based''', as opposed to '''frame-based'''. '''Frame-based''' animation is something traditional animators are used to, because they actually draw each image of the animation on a separate celluloid sheet, and the timing is related to the rate of images per second the camera will capture. When animation is done on a computer, the animator doesn't draw every image but only some ''key'' images (or ''keyframes'') and then the animation software creates all the necessary images for him (the so-called ''in-betweens''). That means the animator can focus back to a (real-)time based timing. Each keyframe is positioned on a timeline with real time values (instead of frame numbers). Of course at the end the animation is discrete and there is a fixed number of images computed inbetween two keyframes, but the neat property of specifying keyframes at time position is that the final animation frame rate is scalable and the animator doesn't have to care about it anymore. He just tells the software to produce 24 images each second if he targets a theatre film or say 10 images per second for low-bandwidth web animation. The animator doesn't need to reposition the keyframes.&lt;br /&gt;
&lt;br /&gt;
=== In-betweening by interpolation ===&lt;br /&gt;
&lt;br /&gt;
Creating the inbetween images on a computer is done by mean of '''interpolation'''. Interpolation is a mathematical tool that can reconstruct a the continuous evolution of a parameter given a set of discrete values of this parameter over time.&lt;br /&gt;
The following image illustrates that. We know that some attribute A must take value A0, A1, A2 and A3 at times t0, t1, t2 and t3. The red curves is one of the possible continuous function that be used to compute inbetween values of A in the interval [t0, t3].&lt;br /&gt;
&lt;br /&gt;
[[Image:interpolation.png]]&lt;br /&gt;
&lt;br /&gt;
* which extent of time ?&lt;br /&gt;
* Which extent of time ?&lt;br /&gt;
The first aspect that characterizes an animation is the interval of time on which it applies: when does it begin, when does it end or how long does it run.&lt;br /&gt;
Any of the above mentioned [[#Animation elements|animation elements] accept the attributes &amp;lt;code&amp;gt;begin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;dur&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
There are many ways to define a particular point in time and this is what makes SMIL a very rich animation framework (see below). The simplest is to specify a clock-value which syntax is quite intuitive [http://www.w3.org/TR/SVG11/animate.html#ClockValueSyntax (SPEC)]. Depending on the combination of those 3 attributes, the interval of time of the animation will be [begin, end], [begin, begin+dur], [end-dur, end], etc.&lt;br /&gt;
&lt;br /&gt;
To specify the values taken over the time interval, one need to tell the value that the parameter must have at the begin and at the end of the interval. here again those values are specified by combinations of three attributes: &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;by&amp;lt;/code&amp;gt;. The attribute &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt; correspond to the begin value, the attribute &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; correspond to the end value. The attribute &amp;lt;code&amp;gt;by&amp;lt;/code&amp;gt; let you define either the initial and final values relative to the other one, that is to = from + by or from = to - by. The following image illusttrate this setup for our hypothetical attribute A&lt;br /&gt;
&lt;br /&gt;
[[Image:time_interval.png]]&lt;br /&gt;
&lt;br /&gt;
The values of A are simply interpolated '''linearly''' in between begin and end. This is the more simple form of '''animation function''' that can defined: by the two extremal pairs of (time, attribute value): (begin, from) and (end, to).&lt;br /&gt;
&lt;br /&gt;
=== More complex timing ===&lt;br /&gt;
&lt;br /&gt;
It's possible to specify a whole set of (keytime, keyvalue) pairs to define the animation function. Each item of the pairs are actually given separately:&lt;br /&gt;
* the set of attribute values (keyvalues) are given by the &amp;lt;code&amp;gt;values&amp;lt;/code&amp;gt; attribute.&lt;br /&gt;
* the set of time values (keytimes) are given by the &amp;lt;code&amp;gt;keyTimes&amp;lt;/code&amp;gt; attribute.&lt;br /&gt;
&lt;br /&gt;
Each set as the form of a semicolon-separated list of values. The thing to notice is that the keytimes are actually '''normalized to [0,1]''', which means that 0 maps to begin and 1 maps to end, and those values must start and end the list of keytimes. The image below illustrates all this:&lt;br /&gt;
&lt;br /&gt;
[[Image:time_interval2.png]]&lt;br /&gt;
&lt;br /&gt;
The keyTimes list can actually be omitted. In this cases the keytimes are evenly in interval [0,1] (equivalently, evenly in the interval [begin, end])&lt;br /&gt;
&lt;br /&gt;
The (keytime, keyvalue) pairs are joined by straight lines in the above graph, which means that we use '''linear interpolation''' for computing the inbetween values. &lt;br /&gt;
&lt;br /&gt;
When applied to the position of an object, linear interpolation results in un-natural robot-like motions (which may the effect wanted). SMIL allows smoother animations by defining '''spline-based interpolation''' between two (keytime, keyvalue) pairs. For each interval (t0, v0) - (t1, v1) a spline can be defined by two control points defining the tangents of the spline at t0 and t1. Those control points are passed in the attribute &amp;lt;code&amp;gt;keySplines&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:spline_interpolation.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Two other interpolation modes are possible:&lt;br /&gt;
* '''discrete''': this is a degenerate form of interpolation, because the resulting animation function is not continuous. For each interval (t0,v0) - (t1, v1), the attribute value is set to v0 for the whole interval. It ''jumps'' to v1 right when t1 is reached and so on.&lt;br /&gt;
* '''paced''': in this interpolation mode, the attribute is interpolated so that its evolution over time has '''constant speed'''. Because the animation function is defined implicitly, the attribute &amp;lt;code&amp;gt;keyTimes&amp;lt;/code&amp;gt; is not taken into account. This mode is mainly useful for the &amp;lt;code&amp;gt;animateMotion&amp;lt;/code&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
=== Other aspects of animation ===&lt;br /&gt;
* repeating&lt;br /&gt;
* chaining animations.&lt;br /&gt;
* event based synchronisation&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
Examples showcasing some of the effects that can be achieved using procedural animation in SVG.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1px&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 1 --&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces on the floor: there are 6 motions here: fall, squeeze, squeeze-offset and bounce unsqueeze and unsqueeze-offset that are the revert version of 3 first. A classic animation trick is to start squeezing the ball a little before it touches the floor, expressed here by the synchronization &amp;lt;code&amp;gt;begin=fall.end - 0.1s&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td rowspan=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;path&lt;br /&gt;
   ...&lt;br /&gt;
   transform=&amp;quot;translate(0,4.5456868)&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;animateTransform&lt;br /&gt;
         type=&amp;quot;translate&amp;quot;&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot;&lt;br /&gt;
         from=&amp;quot;0, 0&amp;quot;&lt;br /&gt;
         to=&amp;quot;0, 136&amp;quot;&lt;br /&gt;
         dur=&amp;quot;1s&amp;quot;&lt;br /&gt;
         begin=&amp;quot;0s&amp;quot;&lt;br /&gt;
         attributeType=&amp;quot;XML&amp;quot;&lt;br /&gt;
         attributeName=&amp;quot;transform&amp;quot;&lt;br /&gt;
         id=&amp;quot;fall&amp;quot;&lt;br /&gt;
         keySplines=&amp;quot;0.5 0  0.8 0.5 &amp;quot;&lt;br /&gt;
         calcMode=&amp;quot;spline&amp;quot; /&amp;gt;&lt;br /&gt;
      &amp;lt;animateTransform&lt;br /&gt;
         id=&amp;quot;squeeze&amp;quot;&lt;br /&gt;
         type=&amp;quot;scale&amp;quot;&lt;br /&gt;
         from=&amp;quot;1,1&amp;quot;&lt;br /&gt;
         to=&amp;quot;1.1,0.9&amp;quot;&lt;br /&gt;
         begin=&amp;quot;fall.end-0.1s&amp;quot;&lt;br /&gt;
         attributeName=&amp;quot;transform&amp;quot;&lt;br /&gt;
         attributeType=&amp;quot;XML&amp;quot;&lt;br /&gt;
         dur=&amp;quot;0.2s&amp;quot;&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot; /&amp;gt;&lt;br /&gt;
      &amp;lt;animateTransform&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot;&lt;br /&gt;
         dur=&amp;quot;0.2s&amp;quot;&lt;br /&gt;
         attributeType=&amp;quot;XML&amp;quot;&lt;br /&gt;
         attributeName=&amp;quot;transform&amp;quot;&lt;br /&gt;
         begin=&amp;quot;fall.end-0.1s&amp;quot;&lt;br /&gt;
         to=&amp;quot;-13,0&amp;quot;&lt;br /&gt;
         from=&amp;quot;0,0&amp;quot;&lt;br /&gt;
         type=&amp;quot;translate&amp;quot;&lt;br /&gt;
         id=&amp;quot;squeeze-offset&amp;quot;&lt;br /&gt;
         accumulate=&amp;quot;sum&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball1.png]]&lt;br /&gt;
[http://www.cdehais.fr/~tof/svg/bouncing_ball1.ogg ogg video]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 2 --&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces on the floor: there are 2 motions&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball2.png]]&lt;br /&gt;
[http://www.cdehais.fr/~tof/svg/bouncing_ball2.ogg ogg video]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 3 --&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces on the floor: there are 2 motions&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball3.png]]&lt;br /&gt;
[http://www.cdehais.fr/~tof/svg/bouncing_ball3.ogg ogg video]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Useful tools ==&lt;br /&gt;
&lt;br /&gt;
* [http://xmlgraphics.apache.org/batik/tools/browser.html Squiggle ], as part of [http://xmlgraphics.apache.org/batik/ Batik 1.7] has a nearly complete support for SMIL Animation. The [[#Examples|examples]] were all rendered using Squiggle.&lt;br /&gt;
* Inkscape ! I used the xml editor to manually add the animation elements for my test. It's a bit more cumbersome than editing the svg file in a text editor, but doing that in Inkscape eases the computation of key positions (just move the object around and read the position values).&lt;br /&gt;
&lt;br /&gt;
== Various thoughts ==&lt;br /&gt;
&lt;br /&gt;
* There is no direct way to specify a &amp;lt;b&amp;gt;''ping-pong'' animation&amp;lt;/b&amp;gt; in SVG, that is to tell an animation to go back in time when it reaches it's end. To implement this, I see 2 solutions:&lt;br /&gt;
**double the duration d of the animation (&amp;lt;code&amp;gt;dur&amp;lt;/code&amp;gt; attribute) et apply a scale and a symetry around t=0.5 to the animation function. For example the simple linear interpolation defined by &amp;lt;code&amp;gt;keyTimes=&amp;quot;0; 1&amp;quot;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;keyPoints=&amp;quot;0;1&amp;quot;&amp;lt;/code&amp;gt; becomes &amp;lt;code&amp;gt;keyTimes=&amp;quot;0; 0.5; 1&amp;quot;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;keyPoints=&amp;quot;0;1;0&amp;quot;&amp;lt;/code&amp;gt;. This doesn't work for &amp;lt;code&amp;gt;paced&amp;lt;/code&amp;gt; animation though (which make use of an implicit, user-agent dependent animation function).&lt;br /&gt;
** copy the original animation (call it e.g. &amp;lt;code&amp;gt;motion_forward&amp;lt;/code&amp;gt;) and swap the &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; values in the copy. Then specify &amp;lt;code&amp;gt;begin=&amp;quot;motion_forward.end&amp;quot;&amp;lt;/code&amp;gt; to tell the backward animation to start right at the end of the forward animation. This should work for every animation type.&lt;br /&gt;
&lt;br /&gt;
The question is: what maps best to a UI ?&lt;/div&gt;</summary>
		<author><name>ToF</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation&amp;diff=23534</id>
		<title>SVG Animation</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation&amp;diff=23534"/>
		<updated>2008-03-09T22:10:52Z</updated>

		<summary type="html">&lt;p&gt;ToF: /* Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is a '''work in progress'''. [[User:ToF|ToF]]&lt;br /&gt;
&lt;br /&gt;
== SVG Animation ==&lt;br /&gt;
&lt;br /&gt;
Animation in SVG is defined in the Animation Module of the [http://www.w3.org/TR/SVG11/animate.html SVG specification]. Animation in SVG conforms to the [http://www.w3.org/TR/2001/REC-smil-animation-20010904/ SMIL specification] (Synchronized Multimedia Integration Language) and extends it (SVG is said to be a ''host'' language of SMIL).&lt;br /&gt;
&lt;br /&gt;
Here I only focus on procedural animation and not programmatic animation (using a scripting language manipulating the DOM). &lt;br /&gt;
&lt;br /&gt;
In SMIL an animation is an object which defines the evolution of a given attribute of a given object (here an SVG element - path, rect, group...) over time. Multiple animations can control the evolution of particular attribute: for example, one will tell the object to turn for 1 second starting at t=0 second and another to move across the document for 2 seconds starting at a later time. So we have this relation:&lt;br /&gt;
             1:n&lt;br /&gt;
  Element &amp;lt;-------&amp;gt; Animation&lt;br /&gt;
&lt;br /&gt;
For a given animation the element which is controlled is called the '''target''' element of the animation. The specific attribute/property which is controlled is called the '''target''' attribute/property.&lt;br /&gt;
&lt;br /&gt;
In fact, it's completely legal to have two animations that control the same attribute of the same element, and they can overlap in time: at any particular time there exists a ''stack'' of animations applying to a particular attribute, and SMIL defines the order in which each animation is applied.&lt;br /&gt;
&lt;br /&gt;
== Animation elements ==&lt;br /&gt;
&lt;br /&gt;
SVG defines 5 animation elements:&lt;br /&gt;
* '''animate'''&lt;br /&gt;
This element is used to animate any scalar attribute or property, such as the &amp;lt;code&amp;gt;width&amp;lt;/code&amp;gt; attribute of an svg:rect element or the CCS property &amp;lt;code&amp;gt;opacity&amp;lt;/code&amp;gt;&lt;br /&gt;
* '''animateMotion'''&lt;br /&gt;
This elements only controls the position of a SVG element, by telling it to follow a given path&lt;br /&gt;
* '''animateColor'''&lt;br /&gt;
This element controls the animation of color valued attributes and properties.&lt;br /&gt;
* '''animateTransform'''&lt;br /&gt;
This element controls the transformation which applies to the target element. It replaces or adds up to the &amp;lt;code&amp;gt;transform&amp;lt;/code&amp;gt; attribute of the element.&lt;br /&gt;
* '''set'''&lt;br /&gt;
This element is used to set a particular value for the target attribute during a specified time interval. It is mainly used for animating attributes which do not span a continuous domain, such as boolean values like the &amp;lt;code&amp;gt;visibility&amp;lt;/code&amp;gt; property.&lt;br /&gt;
&lt;br /&gt;
== Specifying the target element and property ==&lt;br /&gt;
&lt;br /&gt;
There are 2 ways to tell which element a given animation will target. The first one is to embed the [[#Animation elements|animation element]] as a child tag of the element to animate. Here is an example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;circle cx=&amp;quot;100px&amp;quot; cy=&amp;quot;100px&amp;quot; r=&amp;quot;20px&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;animate attributeName=&amp;quot;r&amp;quot; attributeType=&amp;quot;XML&amp;quot; begin=&amp;quot;1s&amp;quot; dur=&amp;quot;2s&amp;quot; from=&amp;quot;20px&amp;quot; to=&amp;quot;50px&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/circle&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;animate&amp;lt;/code&amp;gt; element targets the radius (&amp;lt;code&amp;gt;r&amp;lt;/code&amp;gt;) property of the parent &amp;lt;code&amp;gt;circle&amp;lt;/code&amp;gt; element. Starting 1 second after the document start, the radius will grow for 2 seconds from 20 pixels to 50 pixels. When nothing else is specified, the animation only applies in its interval of time, here [1-3] seconds; from 0 to 1 second and then from 3 second and after, the circle's radius is set back to its ''static'' attribute value, here 20 pixels.&lt;br /&gt;
&lt;br /&gt;
The other way to specify the target element is to reference it in via an &amp;lt;code&amp;gt;xlink:href&amp;lt;/code&amp;gt; attribute of the animation element. the previous animation could be written this way:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;circle id=&amp;quot;balloon&amp;quot; cx=&amp;quot;100px&amp;quot; cy=&amp;quot;100px&amp;quot; r=&amp;quot;20px&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;animate xlink:href=&amp;quot;#balloon&amp;quot; attributeName=&amp;quot;r&amp;quot; attributeType=&amp;quot;XML&amp;quot; begin=&amp;quot;1s&amp;quot; dur=&amp;quot;2s&amp;quot; from=&amp;quot;20px&amp;quot; to=&amp;quot;50px&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To specify which property or attribute of the target element is controlled, we use the two attributes &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;attributeType&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; explains itself, it's the name of the controlled attribute. &amp;lt;code&amp;gt;attributeType&amp;lt;/code&amp;gt; tells whether &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; is searched among the SVG attributes of the element (&amp;lt;code&amp;gt;attributeType=&amp;quot;XML&amp;quot;&amp;lt;/code&amp;gt;) or among the CSS properties of the element (&amp;lt;code&amp;gt;attributeType=&amp;quot;CSS&amp;quot;&amp;lt;/code&amp;gt;). [http://www.w3.org/TR/SVG11/animate.html#TargetElement (SPEC)]&lt;br /&gt;
&lt;br /&gt;
== Timing an animation ==&lt;br /&gt;
&lt;br /&gt;
The first thing to stress is that SMIL (and therefore SVG) animation is '''time-based''', as opposed to '''frame-based'''. '''Frame-based''' animation is something traditional animators are used to, because they actually draw each image of the animation on a separate celluloid sheet, and the timing is related to the rate of images per second the camera will capture. When animation is done on a computer, the animator doesn't draw every image but only some ''key'' images (or ''keyframes'') and then the animation software creates all the necessary images for him (the so-called ''in-betweens''). That means the animator can focus back to a (real-)time based timing. Each keyframe is positioned on a timeline with real time values (instead of frame numbers). Of course at the end the animation is discrete and there is a fixed number of images computed inbetween two keyframes, but the neat property of specifying keyframes at time position is that the final animation frame rate is scalable and the animator doesn't have to care about it anymore. He just tells the software to produce 24 images each second if he targets a theatre film or say 10 images per second for low-bandwidth web animation. The animator doesn't need to reposition the keyframes.&lt;br /&gt;
&lt;br /&gt;
=== In-betweening by interpolation ===&lt;br /&gt;
&lt;br /&gt;
Creating the inbetween images on a computer is done by mean of '''interpolation'''. Interpolation is a mathematical tool that can reconstruct a the continuous evolution of a parameter given a set of discrete values of this parameter over time.&lt;br /&gt;
The following image illustrates that. We know that some attribute A must take value A0, A1, A2 and A3 at times t0, t1, t2 and t3. The red curves is one of the possible continuous function that be used to compute inbetween values of A in the interval [t0, t3].&lt;br /&gt;
&lt;br /&gt;
[[Image:interpolation.png]]&lt;br /&gt;
&lt;br /&gt;
* which extent of time ?&lt;br /&gt;
* Which extent of time ?&lt;br /&gt;
The first aspect that characterizes an animation is the interval of time on which it applies: when does it begin, when does it end or how long does it run.&lt;br /&gt;
Any of the above mentioned [[#Animation elements|animation elements] accept the attributes &amp;lt;code&amp;gt;begin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;dur&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
There are many ways to define a particular point in time and this is what makes SMIL a very rich animation framework (see below). The simplest is to specify a clock-value which syntax is quite intuitive [http://www.w3.org/TR/SVG11/animate.html#ClockValueSyntax (SPEC)]. Depending on the combination of those 3 attributes, the interval of time of the animation will be [begin, end], [begin, begin+dur], [end-dur, end], etc.&lt;br /&gt;
&lt;br /&gt;
To specify the values taken over the time interval, one need to tell the value that the parameter must have at the begin and at the end of the interval. here again those values are specified by combinations of three attributes: &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;by&amp;lt;/code&amp;gt;. The attribute &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt; correspond to the begin value, the attribute &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; correspond to the end value. The attribute &amp;lt;code&amp;gt;by&amp;lt;/code&amp;gt; let you define either the initial and final values relative to the other one, that is to = from + by or from = to - by. The following image illusttrate this setup for our hypothetical attribute A&lt;br /&gt;
&lt;br /&gt;
[[Image:time_interval.png]]&lt;br /&gt;
&lt;br /&gt;
The values of A are simply interpolated '''linearly''' in between begin and end. This is the more simple form of '''animation function''' that can defined: by the two extremal pairs of (time, attribute value): (begin, from) and (end, to).&lt;br /&gt;
&lt;br /&gt;
=== More complex timing ===&lt;br /&gt;
&lt;br /&gt;
It's possible to specify a whole set of (keytime, keyvalue) pairs to define the animation function. Each item of the pairs are actually given separately:&lt;br /&gt;
* the set of attribute values (keyvalues) are given by the &amp;lt;code&amp;gt;values&amp;lt;/code&amp;gt; attribute.&lt;br /&gt;
* the set of time values (keytimes) are given by the &amp;lt;code&amp;gt;keyTimes&amp;lt;/code&amp;gt; attribute.&lt;br /&gt;
&lt;br /&gt;
Each set as the form of a semicolon-separated list of values. The thing to notice is that the keytimes are actually '''normalized to [0,1]''', which means that 0 maps to begin and 1 maps to end, and those values must start and end the list of keytimes. The image below illustrates all this:&lt;br /&gt;
&lt;br /&gt;
[[Image:time_interval2.png]]&lt;br /&gt;
&lt;br /&gt;
The keyTimes list can actually be omitted. In this cases the keytimes are evenly in interval [0,1] (equivalently, evenly in the interval [begin, end])&lt;br /&gt;
&lt;br /&gt;
The (keytime, keyvalue) pairs are joined by straight lines in the above graph, which means that we use '''linear interpolation''' for computing the inbetween values. &lt;br /&gt;
&lt;br /&gt;
When applied to the position of an object, linear interpolation results in un-natural robot-like motions (which may the effect wanted). SMIL allows smoother animations by defining '''spline-based interpolation''' between two (keytime, keyvalue) pairs. For each interval (t0, v0) - (t1, v1) a spline can be defined by two control points defining the tangents of the spline at t0 and t1. Those control points are passed in the attribute &amp;lt;code&amp;gt;keySplines&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:spline_interpolation.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Two other interpolation modes are possible:&lt;br /&gt;
* '''discrete''': this is a degenerate form of interpolation, because the resulting animation function is not continuous. For each interval (t0,v0) - (t1, v1), the attribute value is set to v0 for the whole interval. It ''jumps'' to v1 right when t1 is reached and so on.&lt;br /&gt;
* '''paced''': in this interpolation mode, the attribute is interpolated so that its evolution over time has '''constant speed'''. Because the animation function is defined implicitly, the attribute &amp;lt;code&amp;gt;keyTimes&amp;lt;/code&amp;gt; is not taken into account. This mode is mainly useful for the &amp;lt;code&amp;gt;animateMotion&amp;lt;/code&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
=== Other aspects of animation ===&lt;br /&gt;
* repeating&lt;br /&gt;
* chaining animations.&lt;br /&gt;
* event based synchronisation&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
Examples showcasing some of the effects that can be achieved using procedural animation in SVG.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1px&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 1 --&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces on the floor: there are 6 motions here: fall, squeeze, squeeze-offset and bounce unsqueeze and unsqueeze-offset that are the revert version of 3 first. A classic animation trick is to start squeezing the ball a little before it touches the floor, expressed here by the synchronization &amp;lt;code&amp;gt;begin=fall.end - 0.1s&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;path&lt;br /&gt;
   ...&lt;br /&gt;
   transform=&amp;quot;translate(0,4.5456868)&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;animateTransform&lt;br /&gt;
         type=&amp;quot;translate&amp;quot;&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot;&lt;br /&gt;
         from=&amp;quot;0, 0&amp;quot;&lt;br /&gt;
         to=&amp;quot;0, 136&amp;quot;&lt;br /&gt;
         dur=&amp;quot;1s&amp;quot;&lt;br /&gt;
         begin=&amp;quot;0s&amp;quot;&lt;br /&gt;
         attributeType=&amp;quot;XML&amp;quot;&lt;br /&gt;
         attributeName=&amp;quot;transform&amp;quot;&lt;br /&gt;
         id=&amp;quot;fall&amp;quot;&lt;br /&gt;
         keySplines=&amp;quot;0.5 0  0.8 0.5 &amp;quot;&lt;br /&gt;
         calcMode=&amp;quot;spline&amp;quot; /&amp;gt;&lt;br /&gt;
      &amp;lt;animateTransform&lt;br /&gt;
         id=&amp;quot;squeeze&amp;quot;&lt;br /&gt;
         type=&amp;quot;scale&amp;quot;&lt;br /&gt;
         from=&amp;quot;1,1&amp;quot;&lt;br /&gt;
         to=&amp;quot;1.1,0.9&amp;quot;&lt;br /&gt;
         begin=&amp;quot;fall.end-0.1s&amp;quot;&lt;br /&gt;
         attributeName=&amp;quot;transform&amp;quot;&lt;br /&gt;
         attributeType=&amp;quot;XML&amp;quot;&lt;br /&gt;
         dur=&amp;quot;0.2s&amp;quot;&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot; /&amp;gt;&lt;br /&gt;
      &amp;lt;animateTransform&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot;&lt;br /&gt;
         dur=&amp;quot;0.2s&amp;quot;&lt;br /&gt;
         attributeType=&amp;quot;XML&amp;quot;&lt;br /&gt;
         attributeName=&amp;quot;transform&amp;quot;&lt;br /&gt;
         begin=&amp;quot;fall.end-0.1s&amp;quot;&lt;br /&gt;
         to=&amp;quot;-13,0&amp;quot;&lt;br /&gt;
         from=&amp;quot;0,0&amp;quot;&lt;br /&gt;
         type=&amp;quot;translate&amp;quot;&lt;br /&gt;
         id=&amp;quot;squeeze-offset&amp;quot;&lt;br /&gt;
         accumulate=&amp;quot;sum&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball1.png]]&lt;br /&gt;
[http://www.cdehais.fr/~tof/svg/bouncing_ball1.ogg ogg video]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 2 --&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces on the floor: there are 2 motions&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball2.png]]&lt;br /&gt;
[http://www.cdehais.fr/~tof/svg/bouncing_ball2.ogg ogg video]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 3 --&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces on the floor: there are 2 motions&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball3.png]]&lt;br /&gt;
[http://www.cdehais.fr/~tof/svg/bouncing_ball3.ogg ogg video]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Useful tools ==&lt;br /&gt;
&lt;br /&gt;
* [http://xmlgraphics.apache.org/batik/tools/browser.html Squiggle ], as part of [http://xmlgraphics.apache.org/batik/ Batik 1.7] has a nearly complete support for SMIL Animation. The [[#Examples|examples]] were all rendered using Squiggle.&lt;br /&gt;
* Inkscape ! I used the xml editor to manually add the animation elements for my test. It's a bit more cumbersome than editing the svg file in a text editor, but doing that in Inkscape eases the computation of key positions (just move the object around and read the position values).&lt;br /&gt;
&lt;br /&gt;
== Various thoughts ==&lt;br /&gt;
&lt;br /&gt;
* There is no direct way to specify a &amp;lt;b&amp;gt;''ping-pong'' animation&amp;lt;/b&amp;gt; in SVG, that is to tell an animation to go back in time when it reaches it's end. To implement this, I see 2 solutions:&lt;br /&gt;
**double the duration d of the animation (&amp;lt;code&amp;gt;dur&amp;lt;/code&amp;gt; attribute) et apply a scale and a symetry around t=0.5 to the animation function. For example the simple linear interpolation defined by &amp;lt;code&amp;gt;keyTimes=&amp;quot;0; 1&amp;quot;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;keyPoints=&amp;quot;0;1&amp;quot;&amp;lt;/code&amp;gt; becomes &amp;lt;code&amp;gt;keyTimes=&amp;quot;0; 0.5; 1&amp;quot;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;keyPoints=&amp;quot;0;1;0&amp;quot;&amp;lt;/code&amp;gt;. This doesn't work for &amp;lt;code&amp;gt;paced&amp;lt;/code&amp;gt; animation though (which make use of an implicit, user-agent dependent animation function).&lt;br /&gt;
** copy the original animation (call it e.g. &amp;lt;code&amp;gt;motion_forward&amp;lt;/code&amp;gt;) and swap the &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; values in the copy. Then specify &amp;lt;code&amp;gt;begin=&amp;quot;motion_forward.end&amp;quot;&amp;lt;/code&amp;gt; to tell the backward animation to start right at the end of the forward animation. This should work for every animation type.&lt;br /&gt;
&lt;br /&gt;
The question is: what maps best to a UI ?&lt;/div&gt;</summary>
		<author><name>ToF</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation&amp;diff=23514</id>
		<title>SVG Animation</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation&amp;diff=23514"/>
		<updated>2008-03-09T22:09:41Z</updated>

		<summary type="html">&lt;p&gt;ToF: /* Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is a '''work in progress'''. [[User:ToF|ToF]]&lt;br /&gt;
&lt;br /&gt;
== SVG Animation ==&lt;br /&gt;
&lt;br /&gt;
Animation in SVG is defined in the Animation Module of the [http://www.w3.org/TR/SVG11/animate.html SVG specification]. Animation in SVG conforms to the [http://www.w3.org/TR/2001/REC-smil-animation-20010904/ SMIL specification] (Synchronized Multimedia Integration Language) and extends it (SVG is said to be a ''host'' language of SMIL).&lt;br /&gt;
&lt;br /&gt;
Here I only focus on procedural animation and not programmatic animation (using a scripting language manipulating the DOM). &lt;br /&gt;
&lt;br /&gt;
In SMIL an animation is an object which defines the evolution of a given attribute of a given object (here an SVG element - path, rect, group...) over time. Multiple animations can control the evolution of particular attribute: for example, one will tell the object to turn for 1 second starting at t=0 second and another to move across the document for 2 seconds starting at a later time. So we have this relation:&lt;br /&gt;
             1:n&lt;br /&gt;
  Element &amp;lt;-------&amp;gt; Animation&lt;br /&gt;
&lt;br /&gt;
For a given animation the element which is controlled is called the '''target''' element of the animation. The specific attribute/property which is controlled is called the '''target''' attribute/property.&lt;br /&gt;
&lt;br /&gt;
In fact, it's completely legal to have two animations that control the same attribute of the same element, and they can overlap in time: at any particular time there exists a ''stack'' of animations applying to a particular attribute, and SMIL defines the order in which each animation is applied.&lt;br /&gt;
&lt;br /&gt;
== Animation elements ==&lt;br /&gt;
&lt;br /&gt;
SVG defines 5 animation elements:&lt;br /&gt;
* '''animate'''&lt;br /&gt;
This element is used to animate any scalar attribute or property, such as the &amp;lt;code&amp;gt;width&amp;lt;/code&amp;gt; attribute of an svg:rect element or the CCS property &amp;lt;code&amp;gt;opacity&amp;lt;/code&amp;gt;&lt;br /&gt;
* '''animateMotion'''&lt;br /&gt;
This elements only controls the position of a SVG element, by telling it to follow a given path&lt;br /&gt;
* '''animateColor'''&lt;br /&gt;
This element controls the animation of color valued attributes and properties.&lt;br /&gt;
* '''animateTransform'''&lt;br /&gt;
This element controls the transformation which applies to the target element. It replaces or adds up to the &amp;lt;code&amp;gt;transform&amp;lt;/code&amp;gt; attribute of the element.&lt;br /&gt;
* '''set'''&lt;br /&gt;
This element is used to set a particular value for the target attribute during a specified time interval. It is mainly used for animating attributes which do not span a continuous domain, such as boolean values like the &amp;lt;code&amp;gt;visibility&amp;lt;/code&amp;gt; property.&lt;br /&gt;
&lt;br /&gt;
== Specifying the target element and property ==&lt;br /&gt;
&lt;br /&gt;
There are 2 ways to tell which element a given animation will target. The first one is to embed the [[#Animation elements|animation element]] as a child tag of the element to animate. Here is an example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;circle cx=&amp;quot;100px&amp;quot; cy=&amp;quot;100px&amp;quot; r=&amp;quot;20px&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;animate attributeName=&amp;quot;r&amp;quot; attributeType=&amp;quot;XML&amp;quot; begin=&amp;quot;1s&amp;quot; dur=&amp;quot;2s&amp;quot; from=&amp;quot;20px&amp;quot; to=&amp;quot;50px&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/circle&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;animate&amp;lt;/code&amp;gt; element targets the radius (&amp;lt;code&amp;gt;r&amp;lt;/code&amp;gt;) property of the parent &amp;lt;code&amp;gt;circle&amp;lt;/code&amp;gt; element. Starting 1 second after the document start, the radius will grow for 2 seconds from 20 pixels to 50 pixels. When nothing else is specified, the animation only applies in its interval of time, here [1-3] seconds; from 0 to 1 second and then from 3 second and after, the circle's radius is set back to its ''static'' attribute value, here 20 pixels.&lt;br /&gt;
&lt;br /&gt;
The other way to specify the target element is to reference it in via an &amp;lt;code&amp;gt;xlink:href&amp;lt;/code&amp;gt; attribute of the animation element. the previous animation could be written this way:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;circle id=&amp;quot;balloon&amp;quot; cx=&amp;quot;100px&amp;quot; cy=&amp;quot;100px&amp;quot; r=&amp;quot;20px&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;animate xlink:href=&amp;quot;#balloon&amp;quot; attributeName=&amp;quot;r&amp;quot; attributeType=&amp;quot;XML&amp;quot; begin=&amp;quot;1s&amp;quot; dur=&amp;quot;2s&amp;quot; from=&amp;quot;20px&amp;quot; to=&amp;quot;50px&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To specify which property or attribute of the target element is controlled, we use the two attributes &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;attributeType&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; explains itself, it's the name of the controlled attribute. &amp;lt;code&amp;gt;attributeType&amp;lt;/code&amp;gt; tells whether &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; is searched among the SVG attributes of the element (&amp;lt;code&amp;gt;attributeType=&amp;quot;XML&amp;quot;&amp;lt;/code&amp;gt;) or among the CSS properties of the element (&amp;lt;code&amp;gt;attributeType=&amp;quot;CSS&amp;quot;&amp;lt;/code&amp;gt;). [http://www.w3.org/TR/SVG11/animate.html#TargetElement (SPEC)]&lt;br /&gt;
&lt;br /&gt;
== Timing an animation ==&lt;br /&gt;
&lt;br /&gt;
The first thing to stress is that SMIL (and therefore SVG) animation is '''time-based''', as opposed to '''frame-based'''. '''Frame-based''' animation is something traditional animators are used to, because they actually draw each image of the animation on a separate celluloid sheet, and the timing is related to the rate of images per second the camera will capture. When animation is done on a computer, the animator doesn't draw every image but only some ''key'' images (or ''keyframes'') and then the animation software creates all the necessary images for him (the so-called ''in-betweens''). That means the animator can focus back to a (real-)time based timing. Each keyframe is positioned on a timeline with real time values (instead of frame numbers). Of course at the end the animation is discrete and there is a fixed number of images computed inbetween two keyframes, but the neat property of specifying keyframes at time position is that the final animation frame rate is scalable and the animator doesn't have to care about it anymore. He just tells the software to produce 24 images each second if he targets a theatre film or say 10 images per second for low-bandwidth web animation. The animator doesn't need to reposition the keyframes.&lt;br /&gt;
&lt;br /&gt;
=== In-betweening by interpolation ===&lt;br /&gt;
&lt;br /&gt;
Creating the inbetween images on a computer is done by mean of '''interpolation'''. Interpolation is a mathematical tool that can reconstruct a the continuous evolution of a parameter given a set of discrete values of this parameter over time.&lt;br /&gt;
The following image illustrates that. We know that some attribute A must take value A0, A1, A2 and A3 at times t0, t1, t2 and t3. The red curves is one of the possible continuous function that be used to compute inbetween values of A in the interval [t0, t3].&lt;br /&gt;
&lt;br /&gt;
[[Image:interpolation.png]]&lt;br /&gt;
&lt;br /&gt;
* which extent of time ?&lt;br /&gt;
* Which extent of time ?&lt;br /&gt;
The first aspect that characterizes an animation is the interval of time on which it applies: when does it begin, when does it end or how long does it run.&lt;br /&gt;
Any of the above mentioned [[#Animation elements|animation elements] accept the attributes &amp;lt;code&amp;gt;begin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;dur&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
There are many ways to define a particular point in time and this is what makes SMIL a very rich animation framework (see below). The simplest is to specify a clock-value which syntax is quite intuitive [http://www.w3.org/TR/SVG11/animate.html#ClockValueSyntax (SPEC)]. Depending on the combination of those 3 attributes, the interval of time of the animation will be [begin, end], [begin, begin+dur], [end-dur, end], etc.&lt;br /&gt;
&lt;br /&gt;
To specify the values taken over the time interval, one need to tell the value that the parameter must have at the begin and at the end of the interval. here again those values are specified by combinations of three attributes: &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;by&amp;lt;/code&amp;gt;. The attribute &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt; correspond to the begin value, the attribute &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; correspond to the end value. The attribute &amp;lt;code&amp;gt;by&amp;lt;/code&amp;gt; let you define either the initial and final values relative to the other one, that is to = from + by or from = to - by. The following image illusttrate this setup for our hypothetical attribute A&lt;br /&gt;
&lt;br /&gt;
[[Image:time_interval.png]]&lt;br /&gt;
&lt;br /&gt;
The values of A are simply interpolated '''linearly''' in between begin and end. This is the more simple form of '''animation function''' that can defined: by the two extremal pairs of (time, attribute value): (begin, from) and (end, to).&lt;br /&gt;
&lt;br /&gt;
=== More complex timing ===&lt;br /&gt;
&lt;br /&gt;
It's possible to specify a whole set of (keytime, keyvalue) pairs to define the animation function. Each item of the pairs are actually given separately:&lt;br /&gt;
* the set of attribute values (keyvalues) are given by the &amp;lt;code&amp;gt;values&amp;lt;/code&amp;gt; attribute.&lt;br /&gt;
* the set of time values (keytimes) are given by the &amp;lt;code&amp;gt;keyTimes&amp;lt;/code&amp;gt; attribute.&lt;br /&gt;
&lt;br /&gt;
Each set as the form of a semicolon-separated list of values. The thing to notice is that the keytimes are actually '''normalized to [0,1]''', which means that 0 maps to begin and 1 maps to end, and those values must start and end the list of keytimes. The image below illustrates all this:&lt;br /&gt;
&lt;br /&gt;
[[Image:time_interval2.png]]&lt;br /&gt;
&lt;br /&gt;
The keyTimes list can actually be omitted. In this cases the keytimes are evenly in interval [0,1] (equivalently, evenly in the interval [begin, end])&lt;br /&gt;
&lt;br /&gt;
The (keytime, keyvalue) pairs are joined by straight lines in the above graph, which means that we use '''linear interpolation''' for computing the inbetween values. &lt;br /&gt;
&lt;br /&gt;
When applied to the position of an object, linear interpolation results in un-natural robot-like motions (which may the effect wanted). SMIL allows smoother animations by defining '''spline-based interpolation''' between two (keytime, keyvalue) pairs. For each interval (t0, v0) - (t1, v1) a spline can be defined by two control points defining the tangents of the spline at t0 and t1. Those control points are passed in the attribute &amp;lt;code&amp;gt;keySplines&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:spline_interpolation.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Two other interpolation modes are possible:&lt;br /&gt;
* '''discrete''': this is a degenerate form of interpolation, because the resulting animation function is not continuous. For each interval (t0,v0) - (t1, v1), the attribute value is set to v0 for the whole interval. It ''jumps'' to v1 right when t1 is reached and so on.&lt;br /&gt;
* '''paced''': in this interpolation mode, the attribute is interpolated so that its evolution over time has '''constant speed'''. Because the animation function is defined implicitly, the attribute &amp;lt;code&amp;gt;keyTimes&amp;lt;/code&amp;gt; is not taken into account. This mode is mainly useful for the &amp;lt;code&amp;gt;animateMotion&amp;lt;/code&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
=== Other aspects of animation ===&lt;br /&gt;
* repeating&lt;br /&gt;
* chaining animations.&lt;br /&gt;
* event based synchronisation&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
Examples showcasing some of the effects that can be achieved using procedural animation in SVG.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1px&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 1 --&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces on the floor: there are 6 motions here: fall, squeeze, squeeze-offset and bounce unsqueeze and unsqueeze-offset that are the revert version of 3 first. A classic animation trick is to start squeezing the ball a little before it touches the floor, expressed here by the synchronization &amp;lt;code begin=fall.end - 0.1s&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;path&lt;br /&gt;
   ...&lt;br /&gt;
   transform=&amp;quot;translate(0,4.5456868)&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;animateTransform&lt;br /&gt;
         type=&amp;quot;translate&amp;quot;&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot;&lt;br /&gt;
         from=&amp;quot;0, 0&amp;quot;&lt;br /&gt;
         to=&amp;quot;0, 136&amp;quot;&lt;br /&gt;
         dur=&amp;quot;1s&amp;quot;&lt;br /&gt;
         begin=&amp;quot;0s&amp;quot;&lt;br /&gt;
         attributeType=&amp;quot;XML&amp;quot;&lt;br /&gt;
         attributeName=&amp;quot;transform&amp;quot;&lt;br /&gt;
         id=&amp;quot;fall&amp;quot;&lt;br /&gt;
         keySplines=&amp;quot;0.5 0  0.8 0.5 &amp;quot;&lt;br /&gt;
         calcMode=&amp;quot;spline&amp;quot; /&amp;gt;&lt;br /&gt;
      &amp;lt;animateTransform&lt;br /&gt;
         id=&amp;quot;squeeze&amp;quot;&lt;br /&gt;
         type=&amp;quot;scale&amp;quot;&lt;br /&gt;
         from=&amp;quot;1,1&amp;quot;&lt;br /&gt;
         to=&amp;quot;1.1,0.9&amp;quot;&lt;br /&gt;
         begin=&amp;quot;fall.end-0.1s&amp;quot;&lt;br /&gt;
         attributeName=&amp;quot;transform&amp;quot;&lt;br /&gt;
         attributeType=&amp;quot;XML&amp;quot;&lt;br /&gt;
         dur=&amp;quot;0.2s&amp;quot;&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot; /&amp;gt;&lt;br /&gt;
      &amp;lt;animateTransform&lt;br /&gt;
         additive=&amp;quot;sum&amp;quot;&lt;br /&gt;
         dur=&amp;quot;0.2s&amp;quot;&lt;br /&gt;
         attributeType=&amp;quot;XML&amp;quot;&lt;br /&gt;
         attributeName=&amp;quot;transform&amp;quot;&lt;br /&gt;
         begin=&amp;quot;fall.end-0.1s&amp;quot;&lt;br /&gt;
         to=&amp;quot;-13,0&amp;quot;&lt;br /&gt;
         from=&amp;quot;0,0&amp;quot;&lt;br /&gt;
         type=&amp;quot;translate&amp;quot;&lt;br /&gt;
         id=&amp;quot;squeeze-offset&amp;quot;&lt;br /&gt;
         accumulate=&amp;quot;sum&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball1.png]]&lt;br /&gt;
[http://www.cdehais.fr/~tof/svg/bouncing_ball1.ogg ogg video]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 2 --&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces on the floor: there are 2 motions&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball2.png]]&lt;br /&gt;
[http://www.cdehais.fr/~tof/svg/bouncing_ball2.ogg ogg video]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 3 --&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces on the floor: there are 2 motions&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball3.png]]&lt;br /&gt;
[http://www.cdehais.fr/~tof/svg/bouncing_ball3.ogg ogg video]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Useful tools ==&lt;br /&gt;
&lt;br /&gt;
* [http://xmlgraphics.apache.org/batik/tools/browser.html Squiggle ], as part of [http://xmlgraphics.apache.org/batik/ Batik 1.7] has a nearly complete support for SMIL Animation. The [[#Examples|examples]] were all rendered using Squiggle.&lt;br /&gt;
* Inkscape ! I used the xml editor to manually add the animation elements for my test. It's a bit more cumbersome than editing the svg file in a text editor, but doing that in Inkscape eases the computation of key positions (just move the object around and read the position values).&lt;br /&gt;
&lt;br /&gt;
== Various thoughts ==&lt;br /&gt;
&lt;br /&gt;
* There is no direct way to specify a &amp;lt;b&amp;gt;''ping-pong'' animation&amp;lt;/b&amp;gt; in SVG, that is to tell an animation to go back in time when it reaches it's end. To implement this, I see 2 solutions:&lt;br /&gt;
**double the duration d of the animation (&amp;lt;code&amp;gt;dur&amp;lt;/code&amp;gt; attribute) et apply a scale and a symetry around t=0.5 to the animation function. For example the simple linear interpolation defined by &amp;lt;code&amp;gt;keyTimes=&amp;quot;0; 1&amp;quot;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;keyPoints=&amp;quot;0;1&amp;quot;&amp;lt;/code&amp;gt; becomes &amp;lt;code&amp;gt;keyTimes=&amp;quot;0; 0.5; 1&amp;quot;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;keyPoints=&amp;quot;0;1;0&amp;quot;&amp;lt;/code&amp;gt;. This doesn't work for &amp;lt;code&amp;gt;paced&amp;lt;/code&amp;gt; animation though (which make use of an implicit, user-agent dependent animation function).&lt;br /&gt;
** copy the original animation (call it e.g. &amp;lt;code&amp;gt;motion_forward&amp;lt;/code&amp;gt;) and swap the &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; values in the copy. Then specify &amp;lt;code&amp;gt;begin=&amp;quot;motion_forward.end&amp;quot;&amp;lt;/code&amp;gt; to tell the backward animation to start right at the end of the forward animation. This should work for every animation type.&lt;br /&gt;
&lt;br /&gt;
The question is: what maps best to a UI ?&lt;/div&gt;</summary>
		<author><name>ToF</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation&amp;diff=23484</id>
		<title>SVG Animation</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation&amp;diff=23484"/>
		<updated>2008-03-09T21:59:26Z</updated>

		<summary type="html">&lt;p&gt;ToF: /* Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is a '''work in progress'''. [[User:ToF|ToF]]&lt;br /&gt;
&lt;br /&gt;
== SVG Animation ==&lt;br /&gt;
&lt;br /&gt;
Animation in SVG is defined in the Animation Module of the [http://www.w3.org/TR/SVG11/animate.html SVG specification]. Animation in SVG conforms to the [http://www.w3.org/TR/2001/REC-smil-animation-20010904/ SMIL specification] (Synchronized Multimedia Integration Language) and extends it (SVG is said to be a ''host'' language of SMIL).&lt;br /&gt;
&lt;br /&gt;
Here I only focus on procedural animation and not programmatic animation (using a scripting language manipulating the DOM). &lt;br /&gt;
&lt;br /&gt;
In SMIL an animation is an object which defines the evolution of a given attribute of a given object (here an SVG element - path, rect, group...) over time. Multiple animations can control the evolution of particular attribute: for example, one will tell the object to turn for 1 second starting at t=0 second and another to move across the document for 2 seconds starting at a later time. So we have this relation:&lt;br /&gt;
             1:n&lt;br /&gt;
  Element &amp;lt;-------&amp;gt; Animation&lt;br /&gt;
&lt;br /&gt;
For a given animation the element which is controlled is called the '''target''' element of the animation. The specific attribute/property which is controlled is called the '''target''' attribute/property.&lt;br /&gt;
&lt;br /&gt;
In fact, it's completely legal to have two animations that control the same attribute of the same element, and they can overlap in time: at any particular time there exists a ''stack'' of animations applying to a particular attribute, and SMIL defines the order in which each animation is applied.&lt;br /&gt;
&lt;br /&gt;
== Animation elements ==&lt;br /&gt;
&lt;br /&gt;
SVG defines 5 animation elements:&lt;br /&gt;
* '''animate'''&lt;br /&gt;
This element is used to animate any scalar attribute or property, such as the &amp;lt;code&amp;gt;width&amp;lt;/code&amp;gt; attribute of an svg:rect element or the CCS property &amp;lt;code&amp;gt;opacity&amp;lt;/code&amp;gt;&lt;br /&gt;
* '''animateMotion'''&lt;br /&gt;
This elements only controls the position of a SVG element, by telling it to follow a given path&lt;br /&gt;
* '''animateColor'''&lt;br /&gt;
This element controls the animation of color valued attributes and properties.&lt;br /&gt;
* '''animateTransform'''&lt;br /&gt;
This element controls the transformation which applies to the target element. It replaces or adds up to the &amp;lt;code&amp;gt;transform&amp;lt;/code&amp;gt; attribute of the element.&lt;br /&gt;
* '''set'''&lt;br /&gt;
This element is used to set a particular value for the target attribute during a specified time interval. It is mainly used for animating attributes which do not span a continuous domain, such as boolean values like the &amp;lt;code&amp;gt;visibility&amp;lt;/code&amp;gt; property.&lt;br /&gt;
&lt;br /&gt;
== Specifying the target element and property ==&lt;br /&gt;
&lt;br /&gt;
There are 2 ways to tell which element a given animation will target. The first one is to embed the [[#Animation elements|animation element]] as a child tag of the element to animate. Here is an example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;circle cx=&amp;quot;100px&amp;quot; cy=&amp;quot;100px&amp;quot; r=&amp;quot;20px&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;animate attributeName=&amp;quot;r&amp;quot; attributeType=&amp;quot;XML&amp;quot; begin=&amp;quot;1s&amp;quot; dur=&amp;quot;2s&amp;quot; from=&amp;quot;20px&amp;quot; to=&amp;quot;50px&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/circle&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;animate&amp;lt;/code&amp;gt; element targets the radius (&amp;lt;code&amp;gt;r&amp;lt;/code&amp;gt;) property of the parent &amp;lt;code&amp;gt;circle&amp;lt;/code&amp;gt; element. Starting 1 second after the document start, the radius will grow for 2 seconds from 20 pixels to 50 pixels. When nothing else is specified, the animation only applies in its interval of time, here [1-3] seconds; from 0 to 1 second and then from 3 second and after, the circle's radius is set back to its ''static'' attribute value, here 20 pixels.&lt;br /&gt;
&lt;br /&gt;
The other way to specify the target element is to reference it in via an &amp;lt;code&amp;gt;xlink:href&amp;lt;/code&amp;gt; attribute of the animation element. the previous animation could be written this way:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;circle id=&amp;quot;balloon&amp;quot; cx=&amp;quot;100px&amp;quot; cy=&amp;quot;100px&amp;quot; r=&amp;quot;20px&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;animate xlink:href=&amp;quot;#balloon&amp;quot; attributeName=&amp;quot;r&amp;quot; attributeType=&amp;quot;XML&amp;quot; begin=&amp;quot;1s&amp;quot; dur=&amp;quot;2s&amp;quot; from=&amp;quot;20px&amp;quot; to=&amp;quot;50px&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To specify which property or attribute of the target element is controlled, we use the two attributes &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;attributeType&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; explains itself, it's the name of the controlled attribute. &amp;lt;code&amp;gt;attributeType&amp;lt;/code&amp;gt; tells whether &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; is searched among the SVG attributes of the element (&amp;lt;code&amp;gt;attributeType=&amp;quot;XML&amp;quot;&amp;lt;/code&amp;gt;) or among the CSS properties of the element (&amp;lt;code&amp;gt;attributeType=&amp;quot;CSS&amp;quot;&amp;lt;/code&amp;gt;). [http://www.w3.org/TR/SVG11/animate.html#TargetElement (SPEC)]&lt;br /&gt;
&lt;br /&gt;
== Timing an animation ==&lt;br /&gt;
&lt;br /&gt;
The first thing to stress is that SMIL (and therefore SVG) animation is '''time-based''', as opposed to '''frame-based'''. '''Frame-based''' animation is something traditional animators are used to, because they actually draw each image of the animation on a separate celluloid sheet, and the timing is related to the rate of images per second the camera will capture. When animation is done on a computer, the animator doesn't draw every image but only some ''key'' images (or ''keyframes'') and then the animation software creates all the necessary images for him (the so-called ''in-betweens''). That means the animator can focus back to a (real-)time based timing. Each keyframe is positioned on a timeline with real time values (instead of frame numbers). Of course at the end the animation is discrete and there is a fixed number of images computed inbetween two keyframes, but the neat property of specifying keyframes at time position is that the final animation frame rate is scalable and the animator doesn't have to care about it anymore. He just tells the software to produce 24 images each second if he targets a theatre film or say 10 images per second for low-bandwidth web animation. The animator doesn't need to reposition the keyframes.&lt;br /&gt;
&lt;br /&gt;
=== In-betweening by interpolation ===&lt;br /&gt;
&lt;br /&gt;
Creating the inbetween images on a computer is done by mean of '''interpolation'''. Interpolation is a mathematical tool that can reconstruct a the continuous evolution of a parameter given a set of discrete values of this parameter over time.&lt;br /&gt;
The following image illustrates that. We know that some attribute A must take value A0, A1, A2 and A3 at times t0, t1, t2 and t3. The red curves is one of the possible continuous function that be used to compute inbetween values of A in the interval [t0, t3].&lt;br /&gt;
&lt;br /&gt;
[[Image:interpolation.png]]&lt;br /&gt;
&lt;br /&gt;
* which extent of time ?&lt;br /&gt;
* Which extent of time ?&lt;br /&gt;
The first aspect that characterizes an animation is the interval of time on which it applies: when does it begin, when does it end or how long does it run.&lt;br /&gt;
Any of the above mentioned [[#Animation elements|animation elements] accept the attributes &amp;lt;code&amp;gt;begin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;dur&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
There are many ways to define a particular point in time and this is what makes SMIL a very rich animation framework (see below). The simplest is to specify a clock-value which syntax is quite intuitive [http://www.w3.org/TR/SVG11/animate.html#ClockValueSyntax (SPEC)]. Depending on the combination of those 3 attributes, the interval of time of the animation will be [begin, end], [begin, begin+dur], [end-dur, end], etc.&lt;br /&gt;
&lt;br /&gt;
To specify the values taken over the time interval, one need to tell the value that the parameter must have at the begin and at the end of the interval. here again those values are specified by combinations of three attributes: &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;by&amp;lt;/code&amp;gt;. The attribute &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt; correspond to the begin value, the attribute &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; correspond to the end value. The attribute &amp;lt;code&amp;gt;by&amp;lt;/code&amp;gt; let you define either the initial and final values relative to the other one, that is to = from + by or from = to - by. The following image illusttrate this setup for our hypothetical attribute A&lt;br /&gt;
&lt;br /&gt;
[[Image:time_interval.png]]&lt;br /&gt;
&lt;br /&gt;
The values of A are simply interpolated '''linearly''' in between begin and end. This is the more simple form of '''animation function''' that can defined: by the two extremal pairs of (time, attribute value): (begin, from) and (end, to).&lt;br /&gt;
&lt;br /&gt;
=== More complex timing ===&lt;br /&gt;
&lt;br /&gt;
It's possible to specify a whole set of (keytime, keyvalue) pairs to define the animation function. Each item of the pairs are actually given separately:&lt;br /&gt;
* the set of attribute values (keyvalues) are given by the &amp;lt;code&amp;gt;values&amp;lt;/code&amp;gt; attribute.&lt;br /&gt;
* the set of time values (keytimes) are given by the &amp;lt;code&amp;gt;keyTimes&amp;lt;/code&amp;gt; attribute.&lt;br /&gt;
&lt;br /&gt;
Each set as the form of a semicolon-separated list of values. The thing to notice is that the keytimes are actually '''normalized to [0,1]''', which means that 0 maps to begin and 1 maps to end, and those values must start and end the list of keytimes. The image below illustrates all this:&lt;br /&gt;
&lt;br /&gt;
[[Image:time_interval2.png]]&lt;br /&gt;
&lt;br /&gt;
The keyTimes list can actually be omitted. In this cases the keytimes are evenly in interval [0,1] (equivalently, evenly in the interval [begin, end])&lt;br /&gt;
&lt;br /&gt;
The (keytime, keyvalue) pairs are joined by straight lines in the above graph, which means that we use '''linear interpolation''' for computing the inbetween values. &lt;br /&gt;
&lt;br /&gt;
When applied to the position of an object, linear interpolation results in un-natural robot-like motions (which may the effect wanted). SMIL allows smoother animations by defining '''spline-based interpolation''' between two (keytime, keyvalue) pairs. For each interval (t0, v0) - (t1, v1) a spline can be defined by two control points defining the tangents of the spline at t0 and t1. Those control points are passed in the attribute &amp;lt;code&amp;gt;keySplines&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:spline_interpolation.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Two other interpolation modes are possible:&lt;br /&gt;
* '''discrete''': this is a degenerate form of interpolation, because the resulting animation function is not continuous. For each interval (t0,v0) - (t1, v1), the attribute value is set to v0 for the whole interval. It ''jumps'' to v1 right when t1 is reached and so on.&lt;br /&gt;
* '''paced''': in this interpolation mode, the attribute is interpolated so that its evolution over time has '''constant speed'''. Because the animation function is defined implicitly, the attribute &amp;lt;code&amp;gt;keyTimes&amp;lt;/code&amp;gt; is not taken into account. This mode is mainly useful for the &amp;lt;code&amp;gt;animateMotion&amp;lt;/code&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
=== Other aspects of animation ===&lt;br /&gt;
* repeating&lt;br /&gt;
* chaining animations.&lt;br /&gt;
* event based synchronisation&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
Examples showcasing some of the effects that can be achieved using procedural animation in SVG.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1px&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 1 --&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces on the floor: there are 2 motions&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball1.png]]&lt;br /&gt;
[http://www.cdehais.fr/~tof/svg/bouncing_ball1.ogg ogg video]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 2 --&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces on the floor: there are 2 motions&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball2.png]]&lt;br /&gt;
[http://www.cdehais.fr/~tof/svg/bouncing_ball2.ogg ogg video]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 3 --&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces on the floor: there are 2 motions&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball3.png]]&lt;br /&gt;
[http://www.cdehais.fr/~tof/svg/bouncing_ball3.ogg ogg video]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Useful tools ==&lt;br /&gt;
&lt;br /&gt;
* [http://xmlgraphics.apache.org/batik/tools/browser.html Squiggle ], as part of [http://xmlgraphics.apache.org/batik/ Batik 1.7] has a nearly complete support for SMIL Animation. The [[#Examples|examples]] were all rendered using Squiggle.&lt;br /&gt;
* Inkscape ! I used the xml editor to manually add the animation elements for my test. It's a bit more cumbersome than editing the svg file in a text editor, but doing that in Inkscape eases the computation of key positions (just move the object around and read the position values).&lt;br /&gt;
&lt;br /&gt;
== Various thoughts ==&lt;br /&gt;
&lt;br /&gt;
* There is no direct way to specify a &amp;lt;b&amp;gt;''ping-pong'' animation&amp;lt;/b&amp;gt; in SVG, that is to tell an animation to go back in time when it reaches it's end. To implement this, I see 2 solutions:&lt;br /&gt;
**double the duration d of the animation (&amp;lt;code&amp;gt;dur&amp;lt;/code&amp;gt; attribute) et apply a scale and a symetry around t=0.5 to the animation function. For example the simple linear interpolation defined by &amp;lt;code&amp;gt;keyTimes=&amp;quot;0; 1&amp;quot;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;keyPoints=&amp;quot;0;1&amp;quot;&amp;lt;/code&amp;gt; becomes &amp;lt;code&amp;gt;keyTimes=&amp;quot;0; 0.5; 1&amp;quot;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;keyPoints=&amp;quot;0;1;0&amp;quot;&amp;lt;/code&amp;gt;. This doesn't work for &amp;lt;code&amp;gt;paced&amp;lt;/code&amp;gt; animation though (which make use of an implicit, user-agent dependent animation function).&lt;br /&gt;
** copy the original animation (call it e.g. &amp;lt;code&amp;gt;motion_forward&amp;lt;/code&amp;gt;) and swap the &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; values in the copy. Then specify &amp;lt;code&amp;gt;begin=&amp;quot;motion_forward.end&amp;quot;&amp;lt;/code&amp;gt; to tell the backward animation to start right at the end of the forward animation. This should work for every animation type.&lt;br /&gt;
&lt;br /&gt;
The question is: what maps best to a UI ?&lt;/div&gt;</summary>
		<author><name>ToF</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation&amp;diff=23474</id>
		<title>SVG Animation</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation&amp;diff=23474"/>
		<updated>2008-03-09T21:54:48Z</updated>

		<summary type="html">&lt;p&gt;ToF: /* Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is a '''work in progress'''. [[User:ToF|ToF]]&lt;br /&gt;
&lt;br /&gt;
== SVG Animation ==&lt;br /&gt;
&lt;br /&gt;
Animation in SVG is defined in the Animation Module of the [http://www.w3.org/TR/SVG11/animate.html SVG specification]. Animation in SVG conforms to the [http://www.w3.org/TR/2001/REC-smil-animation-20010904/ SMIL specification] (Synchronized Multimedia Integration Language) and extends it (SVG is said to be a ''host'' language of SMIL).&lt;br /&gt;
&lt;br /&gt;
Here I only focus on procedural animation and not programmatic animation (using a scripting language manipulating the DOM). &lt;br /&gt;
&lt;br /&gt;
In SMIL an animation is an object which defines the evolution of a given attribute of a given object (here an SVG element - path, rect, group...) over time. Multiple animations can control the evolution of particular attribute: for example, one will tell the object to turn for 1 second starting at t=0 second and another to move across the document for 2 seconds starting at a later time. So we have this relation:&lt;br /&gt;
             1:n&lt;br /&gt;
  Element &amp;lt;-------&amp;gt; Animation&lt;br /&gt;
&lt;br /&gt;
For a given animation the element which is controlled is called the '''target''' element of the animation. The specific attribute/property which is controlled is called the '''target''' attribute/property.&lt;br /&gt;
&lt;br /&gt;
In fact, it's completely legal to have two animations that control the same attribute of the same element, and they can overlap in time: at any particular time there exists a ''stack'' of animations applying to a particular attribute, and SMIL defines the order in which each animation is applied.&lt;br /&gt;
&lt;br /&gt;
== Animation elements ==&lt;br /&gt;
&lt;br /&gt;
SVG defines 5 animation elements:&lt;br /&gt;
* '''animate'''&lt;br /&gt;
This element is used to animate any scalar attribute or property, such as the &amp;lt;code&amp;gt;width&amp;lt;/code&amp;gt; attribute of an svg:rect element or the CCS property &amp;lt;code&amp;gt;opacity&amp;lt;/code&amp;gt;&lt;br /&gt;
* '''animateMotion'''&lt;br /&gt;
This elements only controls the position of a SVG element, by telling it to follow a given path&lt;br /&gt;
* '''animateColor'''&lt;br /&gt;
This element controls the animation of color valued attributes and properties.&lt;br /&gt;
* '''animateTransform'''&lt;br /&gt;
This element controls the transformation which applies to the target element. It replaces or adds up to the &amp;lt;code&amp;gt;transform&amp;lt;/code&amp;gt; attribute of the element.&lt;br /&gt;
* '''set'''&lt;br /&gt;
This element is used to set a particular value for the target attribute during a specified time interval. It is mainly used for animating attributes which do not span a continuous domain, such as boolean values like the &amp;lt;code&amp;gt;visibility&amp;lt;/code&amp;gt; property.&lt;br /&gt;
&lt;br /&gt;
== Specifying the target element and property ==&lt;br /&gt;
&lt;br /&gt;
There are 2 ways to tell which element a given animation will target. The first one is to embed the [[#Animation elements|animation element]] as a child tag of the element to animate. Here is an example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;circle cx=&amp;quot;100px&amp;quot; cy=&amp;quot;100px&amp;quot; r=&amp;quot;20px&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;animate attributeName=&amp;quot;r&amp;quot; attributeType=&amp;quot;XML&amp;quot; begin=&amp;quot;1s&amp;quot; dur=&amp;quot;2s&amp;quot; from=&amp;quot;20px&amp;quot; to=&amp;quot;50px&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/circle&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;animate&amp;lt;/code&amp;gt; element targets the radius (&amp;lt;code&amp;gt;r&amp;lt;/code&amp;gt;) property of the parent &amp;lt;code&amp;gt;circle&amp;lt;/code&amp;gt; element. Starting 1 second after the document start, the radius will grow for 2 seconds from 20 pixels to 50 pixels. When nothing else is specified, the animation only applies in its interval of time, here [1-3] seconds; from 0 to 1 second and then from 3 second and after, the circle's radius is set back to its ''static'' attribute value, here 20 pixels.&lt;br /&gt;
&lt;br /&gt;
The other way to specify the target element is to reference it in via an &amp;lt;code&amp;gt;xlink:href&amp;lt;/code&amp;gt; attribute of the animation element. the previous animation could be written this way:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;circle id=&amp;quot;balloon&amp;quot; cx=&amp;quot;100px&amp;quot; cy=&amp;quot;100px&amp;quot; r=&amp;quot;20px&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;animate xlink:href=&amp;quot;#balloon&amp;quot; attributeName=&amp;quot;r&amp;quot; attributeType=&amp;quot;XML&amp;quot; begin=&amp;quot;1s&amp;quot; dur=&amp;quot;2s&amp;quot; from=&amp;quot;20px&amp;quot; to=&amp;quot;50px&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To specify which property or attribute of the target element is controlled, we use the two attributes &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;attributeType&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; explains itself, it's the name of the controlled attribute. &amp;lt;code&amp;gt;attributeType&amp;lt;/code&amp;gt; tells whether &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; is searched among the SVG attributes of the element (&amp;lt;code&amp;gt;attributeType=&amp;quot;XML&amp;quot;&amp;lt;/code&amp;gt;) or among the CSS properties of the element (&amp;lt;code&amp;gt;attributeType=&amp;quot;CSS&amp;quot;&amp;lt;/code&amp;gt;). [http://www.w3.org/TR/SVG11/animate.html#TargetElement (SPEC)]&lt;br /&gt;
&lt;br /&gt;
== Timing an animation ==&lt;br /&gt;
&lt;br /&gt;
The first thing to stress is that SMIL (and therefore SVG) animation is '''time-based''', as opposed to '''frame-based'''. '''Frame-based''' animation is something traditional animators are used to, because they actually draw each image of the animation on a separate celluloid sheet, and the timing is related to the rate of images per second the camera will capture. When animation is done on a computer, the animator doesn't draw every image but only some ''key'' images (or ''keyframes'') and then the animation software creates all the necessary images for him (the so-called ''in-betweens''). That means the animator can focus back to a (real-)time based timing. Each keyframe is positioned on a timeline with real time values (instead of frame numbers). Of course at the end the animation is discrete and there is a fixed number of images computed inbetween two keyframes, but the neat property of specifying keyframes at time position is that the final animation frame rate is scalable and the animator doesn't have to care about it anymore. He just tells the software to produce 24 images each second if he targets a theatre film or say 10 images per second for low-bandwidth web animation. The animator doesn't need to reposition the keyframes.&lt;br /&gt;
&lt;br /&gt;
=== In-betweening by interpolation ===&lt;br /&gt;
&lt;br /&gt;
Creating the inbetween images on a computer is done by mean of '''interpolation'''. Interpolation is a mathematical tool that can reconstruct a the continuous evolution of a parameter given a set of discrete values of this parameter over time.&lt;br /&gt;
The following image illustrates that. We know that some attribute A must take value A0, A1, A2 and A3 at times t0, t1, t2 and t3. The red curves is one of the possible continuous function that be used to compute inbetween values of A in the interval [t0, t3].&lt;br /&gt;
&lt;br /&gt;
[[Image:interpolation.png]]&lt;br /&gt;
&lt;br /&gt;
* which extent of time ?&lt;br /&gt;
* Which extent of time ?&lt;br /&gt;
The first aspect that characterizes an animation is the interval of time on which it applies: when does it begin, when does it end or how long does it run.&lt;br /&gt;
Any of the above mentioned [[#Animation elements|animation elements] accept the attributes &amp;lt;code&amp;gt;begin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;dur&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
There are many ways to define a particular point in time and this is what makes SMIL a very rich animation framework (see below). The simplest is to specify a clock-value which syntax is quite intuitive [http://www.w3.org/TR/SVG11/animate.html#ClockValueSyntax (SPEC)]. Depending on the combination of those 3 attributes, the interval of time of the animation will be [begin, end], [begin, begin+dur], [end-dur, end], etc.&lt;br /&gt;
&lt;br /&gt;
To specify the values taken over the time interval, one need to tell the value that the parameter must have at the begin and at the end of the interval. here again those values are specified by combinations of three attributes: &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;by&amp;lt;/code&amp;gt;. The attribute &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt; correspond to the begin value, the attribute &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; correspond to the end value. The attribute &amp;lt;code&amp;gt;by&amp;lt;/code&amp;gt; let you define either the initial and final values relative to the other one, that is to = from + by or from = to - by. The following image illusttrate this setup for our hypothetical attribute A&lt;br /&gt;
&lt;br /&gt;
[[Image:time_interval.png]]&lt;br /&gt;
&lt;br /&gt;
The values of A are simply interpolated '''linearly''' in between begin and end. This is the more simple form of '''animation function''' that can defined: by the two extremal pairs of (time, attribute value): (begin, from) and (end, to).&lt;br /&gt;
&lt;br /&gt;
=== More complex timing ===&lt;br /&gt;
&lt;br /&gt;
It's possible to specify a whole set of (keytime, keyvalue) pairs to define the animation function. Each item of the pairs are actually given separately:&lt;br /&gt;
* the set of attribute values (keyvalues) are given by the &amp;lt;code&amp;gt;values&amp;lt;/code&amp;gt; attribute.&lt;br /&gt;
* the set of time values (keytimes) are given by the &amp;lt;code&amp;gt;keyTimes&amp;lt;/code&amp;gt; attribute.&lt;br /&gt;
&lt;br /&gt;
Each set as the form of a semicolon-separated list of values. The thing to notice is that the keytimes are actually '''normalized to [0,1]''', which means that 0 maps to begin and 1 maps to end, and those values must start and end the list of keytimes. The image below illustrates all this:&lt;br /&gt;
&lt;br /&gt;
[[Image:time_interval2.png]]&lt;br /&gt;
&lt;br /&gt;
The keyTimes list can actually be omitted. In this cases the keytimes are evenly in interval [0,1] (equivalently, evenly in the interval [begin, end])&lt;br /&gt;
&lt;br /&gt;
The (keytime, keyvalue) pairs are joined by straight lines in the above graph, which means that we use '''linear interpolation''' for computing the inbetween values. &lt;br /&gt;
&lt;br /&gt;
When applied to the position of an object, linear interpolation results in un-natural robot-like motions (which may the effect wanted). SMIL allows smoother animations by defining '''spline-based interpolation''' between two (keytime, keyvalue) pairs. For each interval (t0, v0) - (t1, v1) a spline can be defined by two control points defining the tangents of the spline at t0 and t1. Those control points are passed in the attribute &amp;lt;code&amp;gt;keySplines&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:spline_interpolation.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Two other interpolation modes are possible:&lt;br /&gt;
* '''discrete''': this is a degenerate form of interpolation, because the resulting animation function is not continuous. For each interval (t0,v0) - (t1, v1), the attribute value is set to v0 for the whole interval. It ''jumps'' to v1 right when t1 is reached and so on.&lt;br /&gt;
* '''paced''': in this interpolation mode, the attribute is interpolated so that its evolution over time has '''constant speed'''. Because the animation function is defined implicitly, the attribute &amp;lt;code&amp;gt;keyTimes&amp;lt;/code&amp;gt; is not taken into account. This mode is mainly useful for the &amp;lt;code&amp;gt;animateMotion&amp;lt;/code&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
=== Other aspects of animation ===&lt;br /&gt;
* repeating&lt;br /&gt;
* chaining animations.&lt;br /&gt;
* event based synchronisation&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
Examples showcasing some of the effects that can be achieved using procedural animation in SVG.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1px&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 1 --&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces on the floor: there are 2 motions&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball1.png]]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 2 --&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces on the floor: there are 2 motions&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball2.png]]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 3 --&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces on the floor: there are 2 motions&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball3.png]]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Useful tools ==&lt;br /&gt;
&lt;br /&gt;
* [http://xmlgraphics.apache.org/batik/tools/browser.html Squiggle ], as part of [http://xmlgraphics.apache.org/batik/ Batik 1.7] has a nearly complete support for SMIL Animation. The [[#Examples|examples]] were all rendered using Squiggle.&lt;br /&gt;
* Inkscape ! I used the xml editor to manually add the animation elements for my test. It's a bit more cumbersome than editing the svg file in a text editor, but doing that in Inkscape eases the computation of key positions (just move the object around and read the position values).&lt;br /&gt;
&lt;br /&gt;
== Various thoughts ==&lt;br /&gt;
&lt;br /&gt;
* There is no direct way to specify a &amp;lt;b&amp;gt;''ping-pong'' animation&amp;lt;/b&amp;gt; in SVG, that is to tell an animation to go back in time when it reaches it's end. To implement this, I see 2 solutions:&lt;br /&gt;
**double the duration d of the animation (&amp;lt;code&amp;gt;dur&amp;lt;/code&amp;gt; attribute) et apply a scale and a symetry around t=0.5 to the animation function. For example the simple linear interpolation defined by &amp;lt;code&amp;gt;keyTimes=&amp;quot;0; 1&amp;quot;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;keyPoints=&amp;quot;0;1&amp;quot;&amp;lt;/code&amp;gt; becomes &amp;lt;code&amp;gt;keyTimes=&amp;quot;0; 0.5; 1&amp;quot;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;keyPoints=&amp;quot;0;1;0&amp;quot;&amp;lt;/code&amp;gt;. This doesn't work for &amp;lt;code&amp;gt;paced&amp;lt;/code&amp;gt; animation though (which make use of an implicit, user-agent dependent animation function).&lt;br /&gt;
** copy the original animation (call it e.g. &amp;lt;code&amp;gt;motion_forward&amp;lt;/code&amp;gt;) and swap the &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; values in the copy. Then specify &amp;lt;code&amp;gt;begin=&amp;quot;motion_forward.end&amp;quot;&amp;lt;/code&amp;gt; to tell the backward animation to start right at the end of the forward animation. This should work for every animation type.&lt;br /&gt;
&lt;br /&gt;
The question is: what maps best to a UI ?&lt;/div&gt;</summary>
		<author><name>ToF</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=File:Bouncing_ball1.png&amp;diff=23464</id>
		<title>File:Bouncing ball1.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=File:Bouncing_ball1.png&amp;diff=23464"/>
		<updated>2008-03-09T21:54:19Z</updated>

		<summary type="html">&lt;p&gt;ToF: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>ToF</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation&amp;diff=23454</id>
		<title>SVG Animation</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation&amp;diff=23454"/>
		<updated>2008-03-09T21:53:04Z</updated>

		<summary type="html">&lt;p&gt;ToF: /* Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is a '''work in progress'''. [[User:ToF|ToF]]&lt;br /&gt;
&lt;br /&gt;
== SVG Animation ==&lt;br /&gt;
&lt;br /&gt;
Animation in SVG is defined in the Animation Module of the [http://www.w3.org/TR/SVG11/animate.html SVG specification]. Animation in SVG conforms to the [http://www.w3.org/TR/2001/REC-smil-animation-20010904/ SMIL specification] (Synchronized Multimedia Integration Language) and extends it (SVG is said to be a ''host'' language of SMIL).&lt;br /&gt;
&lt;br /&gt;
Here I only focus on procedural animation and not programmatic animation (using a scripting language manipulating the DOM). &lt;br /&gt;
&lt;br /&gt;
In SMIL an animation is an object which defines the evolution of a given attribute of a given object (here an SVG element - path, rect, group...) over time. Multiple animations can control the evolution of particular attribute: for example, one will tell the object to turn for 1 second starting at t=0 second and another to move across the document for 2 seconds starting at a later time. So we have this relation:&lt;br /&gt;
             1:n&lt;br /&gt;
  Element &amp;lt;-------&amp;gt; Animation&lt;br /&gt;
&lt;br /&gt;
For a given animation the element which is controlled is called the '''target''' element of the animation. The specific attribute/property which is controlled is called the '''target''' attribute/property.&lt;br /&gt;
&lt;br /&gt;
In fact, it's completely legal to have two animations that control the same attribute of the same element, and they can overlap in time: at any particular time there exists a ''stack'' of animations applying to a particular attribute, and SMIL defines the order in which each animation is applied.&lt;br /&gt;
&lt;br /&gt;
== Animation elements ==&lt;br /&gt;
&lt;br /&gt;
SVG defines 5 animation elements:&lt;br /&gt;
* '''animate'''&lt;br /&gt;
This element is used to animate any scalar attribute or property, such as the &amp;lt;code&amp;gt;width&amp;lt;/code&amp;gt; attribute of an svg:rect element or the CCS property &amp;lt;code&amp;gt;opacity&amp;lt;/code&amp;gt;&lt;br /&gt;
* '''animateMotion'''&lt;br /&gt;
This elements only controls the position of a SVG element, by telling it to follow a given path&lt;br /&gt;
* '''animateColor'''&lt;br /&gt;
This element controls the animation of color valued attributes and properties.&lt;br /&gt;
* '''animateTransform'''&lt;br /&gt;
This element controls the transformation which applies to the target element. It replaces or adds up to the &amp;lt;code&amp;gt;transform&amp;lt;/code&amp;gt; attribute of the element.&lt;br /&gt;
* '''set'''&lt;br /&gt;
This element is used to set a particular value for the target attribute during a specified time interval. It is mainly used for animating attributes which do not span a continuous domain, such as boolean values like the &amp;lt;code&amp;gt;visibility&amp;lt;/code&amp;gt; property.&lt;br /&gt;
&lt;br /&gt;
== Specifying the target element and property ==&lt;br /&gt;
&lt;br /&gt;
There are 2 ways to tell which element a given animation will target. The first one is to embed the [[#Animation elements|animation element]] as a child tag of the element to animate. Here is an example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;circle cx=&amp;quot;100px&amp;quot; cy=&amp;quot;100px&amp;quot; r=&amp;quot;20px&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;animate attributeName=&amp;quot;r&amp;quot; attributeType=&amp;quot;XML&amp;quot; begin=&amp;quot;1s&amp;quot; dur=&amp;quot;2s&amp;quot; from=&amp;quot;20px&amp;quot; to=&amp;quot;50px&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/circle&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;animate&amp;lt;/code&amp;gt; element targets the radius (&amp;lt;code&amp;gt;r&amp;lt;/code&amp;gt;) property of the parent &amp;lt;code&amp;gt;circle&amp;lt;/code&amp;gt; element. Starting 1 second after the document start, the radius will grow for 2 seconds from 20 pixels to 50 pixels. When nothing else is specified, the animation only applies in its interval of time, here [1-3] seconds; from 0 to 1 second and then from 3 second and after, the circle's radius is set back to its ''static'' attribute value, here 20 pixels.&lt;br /&gt;
&lt;br /&gt;
The other way to specify the target element is to reference it in via an &amp;lt;code&amp;gt;xlink:href&amp;lt;/code&amp;gt; attribute of the animation element. the previous animation could be written this way:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;circle id=&amp;quot;balloon&amp;quot; cx=&amp;quot;100px&amp;quot; cy=&amp;quot;100px&amp;quot; r=&amp;quot;20px&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;animate xlink:href=&amp;quot;#balloon&amp;quot; attributeName=&amp;quot;r&amp;quot; attributeType=&amp;quot;XML&amp;quot; begin=&amp;quot;1s&amp;quot; dur=&amp;quot;2s&amp;quot; from=&amp;quot;20px&amp;quot; to=&amp;quot;50px&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To specify which property or attribute of the target element is controlled, we use the two attributes &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;attributeType&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; explains itself, it's the name of the controlled attribute. &amp;lt;code&amp;gt;attributeType&amp;lt;/code&amp;gt; tells whether &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; is searched among the SVG attributes of the element (&amp;lt;code&amp;gt;attributeType=&amp;quot;XML&amp;quot;&amp;lt;/code&amp;gt;) or among the CSS properties of the element (&amp;lt;code&amp;gt;attributeType=&amp;quot;CSS&amp;quot;&amp;lt;/code&amp;gt;). [http://www.w3.org/TR/SVG11/animate.html#TargetElement (SPEC)]&lt;br /&gt;
&lt;br /&gt;
== Timing an animation ==&lt;br /&gt;
&lt;br /&gt;
The first thing to stress is that SMIL (and therefore SVG) animation is '''time-based''', as opposed to '''frame-based'''. '''Frame-based''' animation is something traditional animators are used to, because they actually draw each image of the animation on a separate celluloid sheet, and the timing is related to the rate of images per second the camera will capture. When animation is done on a computer, the animator doesn't draw every image but only some ''key'' images (or ''keyframes'') and then the animation software creates all the necessary images for him (the so-called ''in-betweens''). That means the animator can focus back to a (real-)time based timing. Each keyframe is positioned on a timeline with real time values (instead of frame numbers). Of course at the end the animation is discrete and there is a fixed number of images computed inbetween two keyframes, but the neat property of specifying keyframes at time position is that the final animation frame rate is scalable and the animator doesn't have to care about it anymore. He just tells the software to produce 24 images each second if he targets a theatre film or say 10 images per second for low-bandwidth web animation. The animator doesn't need to reposition the keyframes.&lt;br /&gt;
&lt;br /&gt;
=== In-betweening by interpolation ===&lt;br /&gt;
&lt;br /&gt;
Creating the inbetween images on a computer is done by mean of '''interpolation'''. Interpolation is a mathematical tool that can reconstruct a the continuous evolution of a parameter given a set of discrete values of this parameter over time.&lt;br /&gt;
The following image illustrates that. We know that some attribute A must take value A0, A1, A2 and A3 at times t0, t1, t2 and t3. The red curves is one of the possible continuous function that be used to compute inbetween values of A in the interval [t0, t3].&lt;br /&gt;
&lt;br /&gt;
[[Image:interpolation.png]]&lt;br /&gt;
&lt;br /&gt;
* which extent of time ?&lt;br /&gt;
* Which extent of time ?&lt;br /&gt;
The first aspect that characterizes an animation is the interval of time on which it applies: when does it begin, when does it end or how long does it run.&lt;br /&gt;
Any of the above mentioned [[#Animation elements|animation elements] accept the attributes &amp;lt;code&amp;gt;begin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;dur&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
There are many ways to define a particular point in time and this is what makes SMIL a very rich animation framework (see below). The simplest is to specify a clock-value which syntax is quite intuitive [http://www.w3.org/TR/SVG11/animate.html#ClockValueSyntax (SPEC)]. Depending on the combination of those 3 attributes, the interval of time of the animation will be [begin, end], [begin, begin+dur], [end-dur, end], etc.&lt;br /&gt;
&lt;br /&gt;
To specify the values taken over the time interval, one need to tell the value that the parameter must have at the begin and at the end of the interval. here again those values are specified by combinations of three attributes: &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;by&amp;lt;/code&amp;gt;. The attribute &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt; correspond to the begin value, the attribute &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; correspond to the end value. The attribute &amp;lt;code&amp;gt;by&amp;lt;/code&amp;gt; let you define either the initial and final values relative to the other one, that is to = from + by or from = to - by. The following image illusttrate this setup for our hypothetical attribute A&lt;br /&gt;
&lt;br /&gt;
[[Image:time_interval.png]]&lt;br /&gt;
&lt;br /&gt;
The values of A are simply interpolated '''linearly''' in between begin and end. This is the more simple form of '''animation function''' that can defined: by the two extremal pairs of (time, attribute value): (begin, from) and (end, to).&lt;br /&gt;
&lt;br /&gt;
=== More complex timing ===&lt;br /&gt;
&lt;br /&gt;
It's possible to specify a whole set of (keytime, keyvalue) pairs to define the animation function. Each item of the pairs are actually given separately:&lt;br /&gt;
* the set of attribute values (keyvalues) are given by the &amp;lt;code&amp;gt;values&amp;lt;/code&amp;gt; attribute.&lt;br /&gt;
* the set of time values (keytimes) are given by the &amp;lt;code&amp;gt;keyTimes&amp;lt;/code&amp;gt; attribute.&lt;br /&gt;
&lt;br /&gt;
Each set as the form of a semicolon-separated list of values. The thing to notice is that the keytimes are actually '''normalized to [0,1]''', which means that 0 maps to begin and 1 maps to end, and those values must start and end the list of keytimes. The image below illustrates all this:&lt;br /&gt;
&lt;br /&gt;
[[Image:time_interval2.png]]&lt;br /&gt;
&lt;br /&gt;
The keyTimes list can actually be omitted. In this cases the keytimes are evenly in interval [0,1] (equivalently, evenly in the interval [begin, end])&lt;br /&gt;
&lt;br /&gt;
The (keytime, keyvalue) pairs are joined by straight lines in the above graph, which means that we use '''linear interpolation''' for computing the inbetween values. &lt;br /&gt;
&lt;br /&gt;
When applied to the position of an object, linear interpolation results in un-natural robot-like motions (which may the effect wanted). SMIL allows smoother animations by defining '''spline-based interpolation''' between two (keytime, keyvalue) pairs. For each interval (t0, v0) - (t1, v1) a spline can be defined by two control points defining the tangents of the spline at t0 and t1. Those control points are passed in the attribute &amp;lt;code&amp;gt;keySplines&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:spline_interpolation.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Two other interpolation modes are possible:&lt;br /&gt;
* '''discrete''': this is a degenerate form of interpolation, because the resulting animation function is not continuous. For each interval (t0,v0) - (t1, v1), the attribute value is set to v0 for the whole interval. It ''jumps'' to v1 right when t1 is reached and so on.&lt;br /&gt;
* '''paced''': in this interpolation mode, the attribute is interpolated so that its evolution over time has '''constant speed'''. Because the animation function is defined implicitly, the attribute &amp;lt;code&amp;gt;keyTimes&amp;lt;/code&amp;gt; is not taken into account. This mode is mainly useful for the &amp;lt;code&amp;gt;animateMotion&amp;lt;/code&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
=== Other aspects of animation ===&lt;br /&gt;
* repeating&lt;br /&gt;
* chaining animations.&lt;br /&gt;
* event based synchronisation&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
Examples showcasing some of the effects that can be achieved using procedural animation in SVG.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table style=&amp;quot;border: solid black 1px;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 1 --&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces on the floor: there are 2 motions&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball1.png]]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 2 --&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces on the floor: there are 2 motions&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball2.png]]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 3 --&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces on the floor: there are 2 motions&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball3.png]]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Useful tools ==&lt;br /&gt;
&lt;br /&gt;
* [http://xmlgraphics.apache.org/batik/tools/browser.html Squiggle ], as part of [http://xmlgraphics.apache.org/batik/ Batik 1.7] has a nearly complete support for SMIL Animation. The [[#Examples|examples]] were all rendered using Squiggle.&lt;br /&gt;
* Inkscape ! I used the xml editor to manually add the animation elements for my test. It's a bit more cumbersome than editing the svg file in a text editor, but doing that in Inkscape eases the computation of key positions (just move the object around and read the position values).&lt;br /&gt;
&lt;br /&gt;
== Various thoughts ==&lt;br /&gt;
&lt;br /&gt;
* There is no direct way to specify a &amp;lt;b&amp;gt;''ping-pong'' animation&amp;lt;/b&amp;gt; in SVG, that is to tell an animation to go back in time when it reaches it's end. To implement this, I see 2 solutions:&lt;br /&gt;
**double the duration d of the animation (&amp;lt;code&amp;gt;dur&amp;lt;/code&amp;gt; attribute) et apply a scale and a symetry around t=0.5 to the animation function. For example the simple linear interpolation defined by &amp;lt;code&amp;gt;keyTimes=&amp;quot;0; 1&amp;quot;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;keyPoints=&amp;quot;0;1&amp;quot;&amp;lt;/code&amp;gt; becomes &amp;lt;code&amp;gt;keyTimes=&amp;quot;0; 0.5; 1&amp;quot;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;keyPoints=&amp;quot;0;1;0&amp;quot;&amp;lt;/code&amp;gt;. This doesn't work for &amp;lt;code&amp;gt;paced&amp;lt;/code&amp;gt; animation though (which make use of an implicit, user-agent dependent animation function).&lt;br /&gt;
** copy the original animation (call it e.g. &amp;lt;code&amp;gt;motion_forward&amp;lt;/code&amp;gt;) and swap the &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; values in the copy. Then specify &amp;lt;code&amp;gt;begin=&amp;quot;motion_forward.end&amp;quot;&amp;lt;/code&amp;gt; to tell the backward animation to start right at the end of the forward animation. This should work for every animation type.&lt;br /&gt;
&lt;br /&gt;
The question is: what maps best to a UI ?&lt;/div&gt;</summary>
		<author><name>ToF</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation&amp;diff=23444</id>
		<title>SVG Animation</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation&amp;diff=23444"/>
		<updated>2008-03-09T21:52:11Z</updated>

		<summary type="html">&lt;p&gt;ToF: /* Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is a '''work in progress'''. [[User:ToF|ToF]]&lt;br /&gt;
&lt;br /&gt;
== SVG Animation ==&lt;br /&gt;
&lt;br /&gt;
Animation in SVG is defined in the Animation Module of the [http://www.w3.org/TR/SVG11/animate.html SVG specification]. Animation in SVG conforms to the [http://www.w3.org/TR/2001/REC-smil-animation-20010904/ SMIL specification] (Synchronized Multimedia Integration Language) and extends it (SVG is said to be a ''host'' language of SMIL).&lt;br /&gt;
&lt;br /&gt;
Here I only focus on procedural animation and not programmatic animation (using a scripting language manipulating the DOM). &lt;br /&gt;
&lt;br /&gt;
In SMIL an animation is an object which defines the evolution of a given attribute of a given object (here an SVG element - path, rect, group...) over time. Multiple animations can control the evolution of particular attribute: for example, one will tell the object to turn for 1 second starting at t=0 second and another to move across the document for 2 seconds starting at a later time. So we have this relation:&lt;br /&gt;
             1:n&lt;br /&gt;
  Element &amp;lt;-------&amp;gt; Animation&lt;br /&gt;
&lt;br /&gt;
For a given animation the element which is controlled is called the '''target''' element of the animation. The specific attribute/property which is controlled is called the '''target''' attribute/property.&lt;br /&gt;
&lt;br /&gt;
In fact, it's completely legal to have two animations that control the same attribute of the same element, and they can overlap in time: at any particular time there exists a ''stack'' of animations applying to a particular attribute, and SMIL defines the order in which each animation is applied.&lt;br /&gt;
&lt;br /&gt;
== Animation elements ==&lt;br /&gt;
&lt;br /&gt;
SVG defines 5 animation elements:&lt;br /&gt;
* '''animate'''&lt;br /&gt;
This element is used to animate any scalar attribute or property, such as the &amp;lt;code&amp;gt;width&amp;lt;/code&amp;gt; attribute of an svg:rect element or the CCS property &amp;lt;code&amp;gt;opacity&amp;lt;/code&amp;gt;&lt;br /&gt;
* '''animateMotion'''&lt;br /&gt;
This elements only controls the position of a SVG element, by telling it to follow a given path&lt;br /&gt;
* '''animateColor'''&lt;br /&gt;
This element controls the animation of color valued attributes and properties.&lt;br /&gt;
* '''animateTransform'''&lt;br /&gt;
This element controls the transformation which applies to the target element. It replaces or adds up to the &amp;lt;code&amp;gt;transform&amp;lt;/code&amp;gt; attribute of the element.&lt;br /&gt;
* '''set'''&lt;br /&gt;
This element is used to set a particular value for the target attribute during a specified time interval. It is mainly used for animating attributes which do not span a continuous domain, such as boolean values like the &amp;lt;code&amp;gt;visibility&amp;lt;/code&amp;gt; property.&lt;br /&gt;
&lt;br /&gt;
== Specifying the target element and property ==&lt;br /&gt;
&lt;br /&gt;
There are 2 ways to tell which element a given animation will target. The first one is to embed the [[#Animation elements|animation element]] as a child tag of the element to animate. Here is an example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;circle cx=&amp;quot;100px&amp;quot; cy=&amp;quot;100px&amp;quot; r=&amp;quot;20px&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;animate attributeName=&amp;quot;r&amp;quot; attributeType=&amp;quot;XML&amp;quot; begin=&amp;quot;1s&amp;quot; dur=&amp;quot;2s&amp;quot; from=&amp;quot;20px&amp;quot; to=&amp;quot;50px&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/circle&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;animate&amp;lt;/code&amp;gt; element targets the radius (&amp;lt;code&amp;gt;r&amp;lt;/code&amp;gt;) property of the parent &amp;lt;code&amp;gt;circle&amp;lt;/code&amp;gt; element. Starting 1 second after the document start, the radius will grow for 2 seconds from 20 pixels to 50 pixels. When nothing else is specified, the animation only applies in its interval of time, here [1-3] seconds; from 0 to 1 second and then from 3 second and after, the circle's radius is set back to its ''static'' attribute value, here 20 pixels.&lt;br /&gt;
&lt;br /&gt;
The other way to specify the target element is to reference it in via an &amp;lt;code&amp;gt;xlink:href&amp;lt;/code&amp;gt; attribute of the animation element. the previous animation could be written this way:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;circle id=&amp;quot;balloon&amp;quot; cx=&amp;quot;100px&amp;quot; cy=&amp;quot;100px&amp;quot; r=&amp;quot;20px&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;animate xlink:href=&amp;quot;#balloon&amp;quot; attributeName=&amp;quot;r&amp;quot; attributeType=&amp;quot;XML&amp;quot; begin=&amp;quot;1s&amp;quot; dur=&amp;quot;2s&amp;quot; from=&amp;quot;20px&amp;quot; to=&amp;quot;50px&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To specify which property or attribute of the target element is controlled, we use the two attributes &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;attributeType&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; explains itself, it's the name of the controlled attribute. &amp;lt;code&amp;gt;attributeType&amp;lt;/code&amp;gt; tells whether &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; is searched among the SVG attributes of the element (&amp;lt;code&amp;gt;attributeType=&amp;quot;XML&amp;quot;&amp;lt;/code&amp;gt;) or among the CSS properties of the element (&amp;lt;code&amp;gt;attributeType=&amp;quot;CSS&amp;quot;&amp;lt;/code&amp;gt;). [http://www.w3.org/TR/SVG11/animate.html#TargetElement (SPEC)]&lt;br /&gt;
&lt;br /&gt;
== Timing an animation ==&lt;br /&gt;
&lt;br /&gt;
The first thing to stress is that SMIL (and therefore SVG) animation is '''time-based''', as opposed to '''frame-based'''. '''Frame-based''' animation is something traditional animators are used to, because they actually draw each image of the animation on a separate celluloid sheet, and the timing is related to the rate of images per second the camera will capture. When animation is done on a computer, the animator doesn't draw every image but only some ''key'' images (or ''keyframes'') and then the animation software creates all the necessary images for him (the so-called ''in-betweens''). That means the animator can focus back to a (real-)time based timing. Each keyframe is positioned on a timeline with real time values (instead of frame numbers). Of course at the end the animation is discrete and there is a fixed number of images computed inbetween two keyframes, but the neat property of specifying keyframes at time position is that the final animation frame rate is scalable and the animator doesn't have to care about it anymore. He just tells the software to produce 24 images each second if he targets a theatre film or say 10 images per second for low-bandwidth web animation. The animator doesn't need to reposition the keyframes.&lt;br /&gt;
&lt;br /&gt;
=== In-betweening by interpolation ===&lt;br /&gt;
&lt;br /&gt;
Creating the inbetween images on a computer is done by mean of '''interpolation'''. Interpolation is a mathematical tool that can reconstruct a the continuous evolution of a parameter given a set of discrete values of this parameter over time.&lt;br /&gt;
The following image illustrates that. We know that some attribute A must take value A0, A1, A2 and A3 at times t0, t1, t2 and t3. The red curves is one of the possible continuous function that be used to compute inbetween values of A in the interval [t0, t3].&lt;br /&gt;
&lt;br /&gt;
[[Image:interpolation.png]]&lt;br /&gt;
&lt;br /&gt;
* which extent of time ?&lt;br /&gt;
* Which extent of time ?&lt;br /&gt;
The first aspect that characterizes an animation is the interval of time on which it applies: when does it begin, when does it end or how long does it run.&lt;br /&gt;
Any of the above mentioned [[#Animation elements|animation elements] accept the attributes &amp;lt;code&amp;gt;begin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;dur&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
There are many ways to define a particular point in time and this is what makes SMIL a very rich animation framework (see below). The simplest is to specify a clock-value which syntax is quite intuitive [http://www.w3.org/TR/SVG11/animate.html#ClockValueSyntax (SPEC)]. Depending on the combination of those 3 attributes, the interval of time of the animation will be [begin, end], [begin, begin+dur], [end-dur, end], etc.&lt;br /&gt;
&lt;br /&gt;
To specify the values taken over the time interval, one need to tell the value that the parameter must have at the begin and at the end of the interval. here again those values are specified by combinations of three attributes: &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;by&amp;lt;/code&amp;gt;. The attribute &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt; correspond to the begin value, the attribute &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; correspond to the end value. The attribute &amp;lt;code&amp;gt;by&amp;lt;/code&amp;gt; let you define either the initial and final values relative to the other one, that is to = from + by or from = to - by. The following image illusttrate this setup for our hypothetical attribute A&lt;br /&gt;
&lt;br /&gt;
[[Image:time_interval.png]]&lt;br /&gt;
&lt;br /&gt;
The values of A are simply interpolated '''linearly''' in between begin and end. This is the more simple form of '''animation function''' that can defined: by the two extremal pairs of (time, attribute value): (begin, from) and (end, to).&lt;br /&gt;
&lt;br /&gt;
=== More complex timing ===&lt;br /&gt;
&lt;br /&gt;
It's possible to specify a whole set of (keytime, keyvalue) pairs to define the animation function. Each item of the pairs are actually given separately:&lt;br /&gt;
* the set of attribute values (keyvalues) are given by the &amp;lt;code&amp;gt;values&amp;lt;/code&amp;gt; attribute.&lt;br /&gt;
* the set of time values (keytimes) are given by the &amp;lt;code&amp;gt;keyTimes&amp;lt;/code&amp;gt; attribute.&lt;br /&gt;
&lt;br /&gt;
Each set as the form of a semicolon-separated list of values. The thing to notice is that the keytimes are actually '''normalized to [0,1]''', which means that 0 maps to begin and 1 maps to end, and those values must start and end the list of keytimes. The image below illustrates all this:&lt;br /&gt;
&lt;br /&gt;
[[Image:time_interval2.png]]&lt;br /&gt;
&lt;br /&gt;
The keyTimes list can actually be omitted. In this cases the keytimes are evenly in interval [0,1] (equivalently, evenly in the interval [begin, end])&lt;br /&gt;
&lt;br /&gt;
The (keytime, keyvalue) pairs are joined by straight lines in the above graph, which means that we use '''linear interpolation''' for computing the inbetween values. &lt;br /&gt;
&lt;br /&gt;
When applied to the position of an object, linear interpolation results in un-natural robot-like motions (which may the effect wanted). SMIL allows smoother animations by defining '''spline-based interpolation''' between two (keytime, keyvalue) pairs. For each interval (t0, v0) - (t1, v1) a spline can be defined by two control points defining the tangents of the spline at t0 and t1. Those control points are passed in the attribute &amp;lt;code&amp;gt;keySplines&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:spline_interpolation.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Two other interpolation modes are possible:&lt;br /&gt;
* '''discrete''': this is a degenerate form of interpolation, because the resulting animation function is not continuous. For each interval (t0,v0) - (t1, v1), the attribute value is set to v0 for the whole interval. It ''jumps'' to v1 right when t1 is reached and so on.&lt;br /&gt;
* '''paced''': in this interpolation mode, the attribute is interpolated so that its evolution over time has '''constant speed'''. Because the animation function is defined implicitly, the attribute &amp;lt;code&amp;gt;keyTimes&amp;lt;/code&amp;gt; is not taken into account. This mode is mainly useful for the &amp;lt;code&amp;gt;animateMotion&amp;lt;/code&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
=== Other aspects of animation ===&lt;br /&gt;
* repeating&lt;br /&gt;
* chaining animations.&lt;br /&gt;
* event based synchronisation&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
Examples showcasing some of the effects that can be achieved using procedural animation in SVG.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table style=&amp;quot;border: solid black 1px;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 1 --&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces on the floor: there are 2 motions&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball1.png]]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 2 --&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces on the floor: there are 2 motions&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball2.png]]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- example 3 --&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
A ball bounces on the floor: there are 2 motions&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
[[Image:bouncing_ball3.png]]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Useful tools ==&lt;br /&gt;
&lt;br /&gt;
* [http://xmlgraphics.apache.org/batik/tools/browser.html Squiggle ], as part of [http://xmlgraphics.apache.org/batik/ Batik 1.7] has a nearly complete support for SMIL Animation. The [[#Examples|examples]] were all rendered using Squiggle.&lt;br /&gt;
* Inkscape ! I used the xml editor to manually add the animation elements for my test. It's a bit more cumbersome than editing the svg file in a text editor, but doing that in Inkscape eases the computation of key positions (just move the object around and read the position values).&lt;br /&gt;
&lt;br /&gt;
== Various thoughts ==&lt;br /&gt;
&lt;br /&gt;
* There is no direct way to specify a &amp;lt;b&amp;gt;''ping-pong'' animation&amp;lt;/b&amp;gt; in SVG, that is to tell an animation to go back in time when it reaches it's end. To implement this, I see 2 solutions:&lt;br /&gt;
**double the duration d of the animation (&amp;lt;code&amp;gt;dur&amp;lt;/code&amp;gt; attribute) et apply a scale and a symetry around t=0.5 to the animation function. For example the simple linear interpolation defined by &amp;lt;code&amp;gt;keyTimes=&amp;quot;0; 1&amp;quot;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;keyPoints=&amp;quot;0;1&amp;quot;&amp;lt;/code&amp;gt; becomes &amp;lt;code&amp;gt;keyTimes=&amp;quot;0; 0.5; 1&amp;quot;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;keyPoints=&amp;quot;0;1;0&amp;quot;&amp;lt;/code&amp;gt;. This doesn't work for &amp;lt;code&amp;gt;paced&amp;lt;/code&amp;gt; animation though (which make use of an implicit, user-agent dependent animation function).&lt;br /&gt;
** copy the original animation (call it e.g. &amp;lt;code&amp;gt;motion_forward&amp;lt;/code&amp;gt;) and swap the &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; values in the copy. Then specify &amp;lt;code&amp;gt;begin=&amp;quot;motion_forward.end&amp;quot;&amp;lt;/code&amp;gt; to tell the backward animation to start right at the end of the forward animation. This should work for every animation type.&lt;br /&gt;
&lt;br /&gt;
The question is: what maps best to a UI ?&lt;/div&gt;</summary>
		<author><name>ToF</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=File:Bouncing_ball3.png&amp;diff=23434</id>
		<title>File:Bouncing ball3.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=File:Bouncing_ball3.png&amp;diff=23434"/>
		<updated>2008-03-09T21:49:33Z</updated>

		<summary type="html">&lt;p&gt;ToF: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>ToF</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=File:Bouncing_ball2.png&amp;diff=23424</id>
		<title>File:Bouncing ball2.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=File:Bouncing_ball2.png&amp;diff=23424"/>
		<updated>2008-03-09T21:49:19Z</updated>

		<summary type="html">&lt;p&gt;ToF: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>ToF</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=File:Boucing_ball1.png&amp;diff=23414</id>
		<title>File:Boucing ball1.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=File:Boucing_ball1.png&amp;diff=23414"/>
		<updated>2008-03-09T21:49:03Z</updated>

		<summary type="html">&lt;p&gt;ToF: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>ToF</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation&amp;diff=23404</id>
		<title>SVG Animation</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation&amp;diff=23404"/>
		<updated>2008-03-09T21:45:59Z</updated>

		<summary type="html">&lt;p&gt;ToF: /* Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is a '''work in progress'''. [[User:ToF|ToF]]&lt;br /&gt;
&lt;br /&gt;
== SVG Animation ==&lt;br /&gt;
&lt;br /&gt;
Animation in SVG is defined in the Animation Module of the [http://www.w3.org/TR/SVG11/animate.html SVG specification]. Animation in SVG conforms to the [http://www.w3.org/TR/2001/REC-smil-animation-20010904/ SMIL specification] (Synchronized Multimedia Integration Language) and extends it (SVG is said to be a ''host'' language of SMIL).&lt;br /&gt;
&lt;br /&gt;
Here I only focus on procedural animation and not programmatic animation (using a scripting language manipulating the DOM). &lt;br /&gt;
&lt;br /&gt;
In SMIL an animation is an object which defines the evolution of a given attribute of a given object (here an SVG element - path, rect, group...) over time. Multiple animations can control the evolution of particular attribute: for example, one will tell the object to turn for 1 second starting at t=0 second and another to move across the document for 2 seconds starting at a later time. So we have this relation:&lt;br /&gt;
             1:n&lt;br /&gt;
  Element &amp;lt;-------&amp;gt; Animation&lt;br /&gt;
&lt;br /&gt;
For a given animation the element which is controlled is called the '''target''' element of the animation. The specific attribute/property which is controlled is called the '''target''' attribute/property.&lt;br /&gt;
&lt;br /&gt;
In fact, it's completely legal to have two animations that control the same attribute of the same element, and they can overlap in time: at any particular time there exists a ''stack'' of animations applying to a particular attribute, and SMIL defines the order in which each animation is applied.&lt;br /&gt;
&lt;br /&gt;
== Animation elements ==&lt;br /&gt;
&lt;br /&gt;
SVG defines 5 animation elements:&lt;br /&gt;
* '''animate'''&lt;br /&gt;
This element is used to animate any scalar attribute or property, such as the &amp;lt;code&amp;gt;width&amp;lt;/code&amp;gt; attribute of an svg:rect element or the CCS property &amp;lt;code&amp;gt;opacity&amp;lt;/code&amp;gt;&lt;br /&gt;
* '''animateMotion'''&lt;br /&gt;
This elements only controls the position of a SVG element, by telling it to follow a given path&lt;br /&gt;
* '''animateColor'''&lt;br /&gt;
This element controls the animation of color valued attributes and properties.&lt;br /&gt;
* '''animateTransform'''&lt;br /&gt;
This element controls the transformation which applies to the target element. It replaces or adds up to the &amp;lt;code&amp;gt;transform&amp;lt;/code&amp;gt; attribute of the element.&lt;br /&gt;
* '''set'''&lt;br /&gt;
This element is used to set a particular value for the target attribute during a specified time interval. It is mainly used for animating attributes which do not span a continuous domain, such as boolean values like the &amp;lt;code&amp;gt;visibility&amp;lt;/code&amp;gt; property.&lt;br /&gt;
&lt;br /&gt;
== Specifying the target element and property ==&lt;br /&gt;
&lt;br /&gt;
There are 2 ways to tell which element a given animation will target. The first one is to embed the [[#Animation elements|animation element]] as a child tag of the element to animate. Here is an example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;circle cx=&amp;quot;100px&amp;quot; cy=&amp;quot;100px&amp;quot; r=&amp;quot;20px&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;animate attributeName=&amp;quot;r&amp;quot; attributeType=&amp;quot;XML&amp;quot; begin=&amp;quot;1s&amp;quot; dur=&amp;quot;2s&amp;quot; from=&amp;quot;20px&amp;quot; to=&amp;quot;50px&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/circle&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;animate&amp;lt;/code&amp;gt; element targets the radius (&amp;lt;code&amp;gt;r&amp;lt;/code&amp;gt;) property of the parent &amp;lt;code&amp;gt;circle&amp;lt;/code&amp;gt; element. Starting 1 second after the document start, the radius will grow for 2 seconds from 20 pixels to 50 pixels. When nothing else is specified, the animation only applies in its interval of time, here [1-3] seconds; from 0 to 1 second and then from 3 second and after, the circle's radius is set back to its ''static'' attribute value, here 20 pixels.&lt;br /&gt;
&lt;br /&gt;
The other way to specify the target element is to reference it in via an &amp;lt;code&amp;gt;xlink:href&amp;lt;/code&amp;gt; attribute of the animation element. the previous animation could be written this way:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;circle id=&amp;quot;balloon&amp;quot; cx=&amp;quot;100px&amp;quot; cy=&amp;quot;100px&amp;quot; r=&amp;quot;20px&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;animate xlink:href=&amp;quot;#balloon&amp;quot; attributeName=&amp;quot;r&amp;quot; attributeType=&amp;quot;XML&amp;quot; begin=&amp;quot;1s&amp;quot; dur=&amp;quot;2s&amp;quot; from=&amp;quot;20px&amp;quot; to=&amp;quot;50px&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To specify which property or attribute of the target element is controlled, we use the two attributes &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;attributeType&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; explains itself, it's the name of the controlled attribute. &amp;lt;code&amp;gt;attributeType&amp;lt;/code&amp;gt; tells whether &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; is searched among the SVG attributes of the element (&amp;lt;code&amp;gt;attributeType=&amp;quot;XML&amp;quot;&amp;lt;/code&amp;gt;) or among the CSS properties of the element (&amp;lt;code&amp;gt;attributeType=&amp;quot;CSS&amp;quot;&amp;lt;/code&amp;gt;). [http://www.w3.org/TR/SVG11/animate.html#TargetElement (SPEC)]&lt;br /&gt;
&lt;br /&gt;
== Timing an animation ==&lt;br /&gt;
&lt;br /&gt;
The first thing to stress is that SMIL (and therefore SVG) animation is '''time-based''', as opposed to '''frame-based'''. '''Frame-based''' animation is something traditional animators are used to, because they actually draw each image of the animation on a separate celluloid sheet, and the timing is related to the rate of images per second the camera will capture. When animation is done on a computer, the animator doesn't draw every image but only some ''key'' images (or ''keyframes'') and then the animation software creates all the necessary images for him (the so-called ''in-betweens''). That means the animator can focus back to a (real-)time based timing. Each keyframe is positioned on a timeline with real time values (instead of frame numbers). Of course at the end the animation is discrete and there is a fixed number of images computed inbetween two keyframes, but the neat property of specifying keyframes at time position is that the final animation frame rate is scalable and the animator doesn't have to care about it anymore. He just tells the software to produce 24 images each second if he targets a theatre film or say 10 images per second for low-bandwidth web animation. The animator doesn't need to reposition the keyframes.&lt;br /&gt;
&lt;br /&gt;
=== In-betweening by interpolation ===&lt;br /&gt;
&lt;br /&gt;
Creating the inbetween images on a computer is done by mean of '''interpolation'''. Interpolation is a mathematical tool that can reconstruct a the continuous evolution of a parameter given a set of discrete values of this parameter over time.&lt;br /&gt;
The following image illustrates that. We know that some attribute A must take value A0, A1, A2 and A3 at times t0, t1, t2 and t3. The red curves is one of the possible continuous function that be used to compute inbetween values of A in the interval [t0, t3].&lt;br /&gt;
&lt;br /&gt;
[[Image:interpolation.png]]&lt;br /&gt;
&lt;br /&gt;
* which extent of time ?&lt;br /&gt;
* Which extent of time ?&lt;br /&gt;
The first aspect that characterizes an animation is the interval of time on which it applies: when does it begin, when does it end or how long does it run.&lt;br /&gt;
Any of the above mentioned [[#Animation elements|animation elements] accept the attributes &amp;lt;code&amp;gt;begin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;dur&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
There are many ways to define a particular point in time and this is what makes SMIL a very rich animation framework (see below). The simplest is to specify a clock-value which syntax is quite intuitive [http://www.w3.org/TR/SVG11/animate.html#ClockValueSyntax (SPEC)]. Depending on the combination of those 3 attributes, the interval of time of the animation will be [begin, end], [begin, begin+dur], [end-dur, end], etc.&lt;br /&gt;
&lt;br /&gt;
To specify the values taken over the time interval, one need to tell the value that the parameter must have at the begin and at the end of the interval. here again those values are specified by combinations of three attributes: &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;by&amp;lt;/code&amp;gt;. The attribute &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt; correspond to the begin value, the attribute &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; correspond to the end value. The attribute &amp;lt;code&amp;gt;by&amp;lt;/code&amp;gt; let you define either the initial and final values relative to the other one, that is to = from + by or from = to - by. The following image illusttrate this setup for our hypothetical attribute A&lt;br /&gt;
&lt;br /&gt;
[[Image:time_interval.png]]&lt;br /&gt;
&lt;br /&gt;
The values of A are simply interpolated '''linearly''' in between begin and end. This is the more simple form of '''animation function''' that can defined: by the two extremal pairs of (time, attribute value): (begin, from) and (end, to).&lt;br /&gt;
&lt;br /&gt;
=== More complex timing ===&lt;br /&gt;
&lt;br /&gt;
It's possible to specify a whole set of (keytime, keyvalue) pairs to define the animation function. Each item of the pairs are actually given separately:&lt;br /&gt;
* the set of attribute values (keyvalues) are given by the &amp;lt;code&amp;gt;values&amp;lt;/code&amp;gt; attribute.&lt;br /&gt;
* the set of time values (keytimes) are given by the &amp;lt;code&amp;gt;keyTimes&amp;lt;/code&amp;gt; attribute.&lt;br /&gt;
&lt;br /&gt;
Each set as the form of a semicolon-separated list of values. The thing to notice is that the keytimes are actually '''normalized to [0,1]''', which means that 0 maps to begin and 1 maps to end, and those values must start and end the list of keytimes. The image below illustrates all this:&lt;br /&gt;
&lt;br /&gt;
[[Image:time_interval2.png]]&lt;br /&gt;
&lt;br /&gt;
The keyTimes list can actually be omitted. In this cases the keytimes are evenly in interval [0,1] (equivalently, evenly in the interval [begin, end])&lt;br /&gt;
&lt;br /&gt;
The (keytime, keyvalue) pairs are joined by straight lines in the above graph, which means that we use '''linear interpolation''' for computing the inbetween values. &lt;br /&gt;
&lt;br /&gt;
When applied to the position of an object, linear interpolation results in un-natural robot-like motions (which may the effect wanted). SMIL allows smoother animations by defining '''spline-based interpolation''' between two (keytime, keyvalue) pairs. For each interval (t0, v0) - (t1, v1) a spline can be defined by two control points defining the tangents of the spline at t0 and t1. Those control points are passed in the attribute &amp;lt;code&amp;gt;keySplines&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:spline_interpolation.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Two other interpolation modes are possible:&lt;br /&gt;
* '''discrete''': this is a degenerate form of interpolation, because the resulting animation function is not continuous. For each interval (t0,v0) - (t1, v1), the attribute value is set to v0 for the whole interval. It ''jumps'' to v1 right when t1 is reached and so on.&lt;br /&gt;
* '''paced''': in this interpolation mode, the attribute is interpolated so that its evolution over time has '''constant speed'''. Because the animation function is defined implicitly, the attribute &amp;lt;code&amp;gt;keyTimes&amp;lt;/code&amp;gt; is not taken into account. This mode is mainly useful for the &amp;lt;code&amp;gt;animateMotion&amp;lt;/code&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
=== Other aspects of animation ===&lt;br /&gt;
* repeating&lt;br /&gt;
* chaining animations.&lt;br /&gt;
* event based synchronisation&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
Examples showcasing some of the effects that can be achieved using procedural animation in SVG.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table style=&amp;quot;border: solid black 1px;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt; AAA&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt; BBB&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt; CCC&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Useful tools ==&lt;br /&gt;
&lt;br /&gt;
* [http://xmlgraphics.apache.org/batik/tools/browser.html Squiggle ], as part of [http://xmlgraphics.apache.org/batik/ Batik 1.7] has a nearly complete support for SMIL Animation. The [[#Examples|examples]] were all rendered using Squiggle.&lt;br /&gt;
* Inkscape ! I used the xml editor to manually add the animation elements for my test. It's a bit more cumbersome than editing the svg file in a text editor, but doing that in Inkscape eases the computation of key positions (just move the object around and read the position values).&lt;br /&gt;
&lt;br /&gt;
== Various thoughts ==&lt;br /&gt;
&lt;br /&gt;
* There is no direct way to specify a &amp;lt;b&amp;gt;''ping-pong'' animation&amp;lt;/b&amp;gt; in SVG, that is to tell an animation to go back in time when it reaches it's end. To implement this, I see 2 solutions:&lt;br /&gt;
**double the duration d of the animation (&amp;lt;code&amp;gt;dur&amp;lt;/code&amp;gt; attribute) et apply a scale and a symetry around t=0.5 to the animation function. For example the simple linear interpolation defined by &amp;lt;code&amp;gt;keyTimes=&amp;quot;0; 1&amp;quot;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;keyPoints=&amp;quot;0;1&amp;quot;&amp;lt;/code&amp;gt; becomes &amp;lt;code&amp;gt;keyTimes=&amp;quot;0; 0.5; 1&amp;quot;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;keyPoints=&amp;quot;0;1;0&amp;quot;&amp;lt;/code&amp;gt;. This doesn't work for &amp;lt;code&amp;gt;paced&amp;lt;/code&amp;gt; animation though (which make use of an implicit, user-agent dependent animation function).&lt;br /&gt;
** copy the original animation (call it e.g. &amp;lt;code&amp;gt;motion_forward&amp;lt;/code&amp;gt;) and swap the &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; values in the copy. Then specify &amp;lt;code&amp;gt;begin=&amp;quot;motion_forward.end&amp;quot;&amp;lt;/code&amp;gt; to tell the backward animation to start right at the end of the forward animation. This should work for every animation type.&lt;br /&gt;
&lt;br /&gt;
The question is: what maps best to a UI ?&lt;/div&gt;</summary>
		<author><name>ToF</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation&amp;diff=23274</id>
		<title>SVG Animation</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation&amp;diff=23274"/>
		<updated>2008-03-09T20:49:29Z</updated>

		<summary type="html">&lt;p&gt;ToF: /* More complex timing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is a '''work in progress'''. [[User:ToF|ToF]]&lt;br /&gt;
&lt;br /&gt;
== SVG Animation ==&lt;br /&gt;
&lt;br /&gt;
Animation in SVG is defined in the Animation Module of the [http://www.w3.org/TR/SVG11/animate.html SVG specification]. Animation in SVG conforms to the [http://www.w3.org/TR/2001/REC-smil-animation-20010904/ SMIL specification] (Synchronized Multimedia Integration Language) and extends it (SVG is said to be a ''host'' language of SMIL).&lt;br /&gt;
&lt;br /&gt;
Here I only focus on procedural animation and not programmatic animation (using a scripting language manipulating the DOM). &lt;br /&gt;
&lt;br /&gt;
In SMIL an animation is an object which defines the evolution of a given attribute of a given object (here an SVG element - path, rect, group...) over time. Multiple animations can control the evolution of particular attribute: for example, one will tell the object to turn for 1 second starting at t=0 second and another to move across the document for 2 seconds starting at a later time. So we have this relation:&lt;br /&gt;
             1:n&lt;br /&gt;
  Element &amp;lt;-------&amp;gt; Animation&lt;br /&gt;
&lt;br /&gt;
For a given animation the element which is controlled is called the '''target''' element of the animation. The specific attribute/property which is controlled is called the '''target''' attribute/property.&lt;br /&gt;
&lt;br /&gt;
In fact, it's completely legal to have two animations that control the same attribute of the same element, and they can overlap in time: at any particular time there exists a ''stack'' of animations applying to a particular attribute, and SMIL defines the order in which each animation is applied.&lt;br /&gt;
&lt;br /&gt;
== Animation elements ==&lt;br /&gt;
&lt;br /&gt;
SVG defines 5 animation elements:&lt;br /&gt;
* '''animate'''&lt;br /&gt;
This element is used to animate any scalar attribute or property, such as the &amp;lt;code&amp;gt;width&amp;lt;/code&amp;gt; attribute of an svg:rect element or the CCS property &amp;lt;code&amp;gt;opacity&amp;lt;/code&amp;gt;&lt;br /&gt;
* '''animateMotion'''&lt;br /&gt;
This elements only controls the position of a SVG element, by telling it to follow a given path&lt;br /&gt;
* '''animateColor'''&lt;br /&gt;
This element controls the animation of color valued attributes and properties.&lt;br /&gt;
* '''animateTransform'''&lt;br /&gt;
This element controls the transformation which applies to the target element. It replaces or adds up to the &amp;lt;code&amp;gt;transform&amp;lt;/code&amp;gt; attribute of the element.&lt;br /&gt;
* '''set'''&lt;br /&gt;
This element is used to set a particular value for the target attribute during a specified time interval. It is mainly used for animating attributes which do not span a continuous domain, such as boolean values like the &amp;lt;code&amp;gt;visibility&amp;lt;/code&amp;gt; property.&lt;br /&gt;
&lt;br /&gt;
== Specifying the target element and property ==&lt;br /&gt;
&lt;br /&gt;
There are 2 ways to tell which element a given animation will target. The first one is to embed the [[#Animation elements|animation element]] as a child tag of the element to animate. Here is an example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;circle cx=&amp;quot;100px&amp;quot; cy=&amp;quot;100px&amp;quot; r=&amp;quot;20px&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;animate attributeName=&amp;quot;r&amp;quot; attributeType=&amp;quot;XML&amp;quot; begin=&amp;quot;1s&amp;quot; dur=&amp;quot;2s&amp;quot; from=&amp;quot;20px&amp;quot; to=&amp;quot;50px&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/circle&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;animate&amp;lt;/code&amp;gt; element targets the radius (&amp;lt;code&amp;gt;r&amp;lt;/code&amp;gt;) property of the parent &amp;lt;code&amp;gt;circle&amp;lt;/code&amp;gt; element. Starting 1 second after the document start, the radius will grow for 2 seconds from 20 pixels to 50 pixels. When nothing else is specified, the animation only applies in its interval of time, here [1-3] seconds; from 0 to 1 second and then from 3 second and after, the circle's radius is set back to its ''static'' attribute value, here 20 pixels.&lt;br /&gt;
&lt;br /&gt;
The other way to specify the target element is to reference it in via an &amp;lt;code&amp;gt;xlink:href&amp;lt;/code&amp;gt; attribute of the animation element. the previous animation could be written this way:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;circle id=&amp;quot;balloon&amp;quot; cx=&amp;quot;100px&amp;quot; cy=&amp;quot;100px&amp;quot; r=&amp;quot;20px&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;animate xlink:href=&amp;quot;#balloon&amp;quot; attributeName=&amp;quot;r&amp;quot; attributeType=&amp;quot;XML&amp;quot; begin=&amp;quot;1s&amp;quot; dur=&amp;quot;2s&amp;quot; from=&amp;quot;20px&amp;quot; to=&amp;quot;50px&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To specify which property or attribute of the target element is controlled, we use the two attributes &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;attributeType&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; explains itself, it's the name of the controlled attribute. &amp;lt;code&amp;gt;attributeType&amp;lt;/code&amp;gt; tells whether &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; is searched among the SVG attributes of the element (&amp;lt;code&amp;gt;attributeType=&amp;quot;XML&amp;quot;&amp;lt;/code&amp;gt;) or among the CSS properties of the element (&amp;lt;code&amp;gt;attributeType=&amp;quot;CSS&amp;quot;&amp;lt;/code&amp;gt;). [http://www.w3.org/TR/SVG11/animate.html#TargetElement (SPEC)]&lt;br /&gt;
&lt;br /&gt;
== Timing an animation ==&lt;br /&gt;
&lt;br /&gt;
The first thing to stress is that SMIL (and therefore SVG) animation is '''time-based''', as opposed to '''frame-based'''. '''Frame-based''' animation is something traditional animators are used to, because they actually draw each image of the animation on a separate celluloid sheet, and the timing is related to the rate of images per second the camera will capture. When animation is done on a computer, the animator doesn't draw every image but only some ''key'' images (or ''keyframes'') and then the animation software creates all the necessary images for him (the so-called ''in-betweens''). That means the animator can focus back to a (real-)time based timing. Each keyframe is positioned on a timeline with real time values (instead of frame numbers). Of course at the end the animation is discrete and there is a fixed number of images computed inbetween two keyframes, but the neat property of specifying keyframes at time position is that the final animation frame rate is scalable and the animator doesn't have to care about it anymore. He just tells the software to produce 24 images each second if he targets a theatre film or say 10 images per second for low-bandwidth web animation. The animator doesn't need to reposition the keyframes.&lt;br /&gt;
&lt;br /&gt;
=== In-betweening by interpolation ===&lt;br /&gt;
&lt;br /&gt;
Creating the inbetween images on a computer is done by mean of '''interpolation'''. Interpolation is a mathematical tool that can reconstruct a the continuous evolution of a parameter given a set of discrete values of this parameter over time.&lt;br /&gt;
The following image illustrates that. We know that some attribute A must take value A0, A1, A2 and A3 at times t0, t1, t2 and t3. The red curves is one of the possible continuous function that be used to compute inbetween values of A in the interval [t0, t3].&lt;br /&gt;
&lt;br /&gt;
[[Image:interpolation.png]]&lt;br /&gt;
&lt;br /&gt;
* which extent of time ?&lt;br /&gt;
* Which extent of time ?&lt;br /&gt;
The first aspect that characterizes an animation is the interval of time on which it applies: when does it begin, when does it end or how long does it run.&lt;br /&gt;
Any of the above mentioned [[#Animation elements|animation elements] accept the attributes &amp;lt;code&amp;gt;begin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;dur&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
There are many ways to define a particular point in time and this is what makes SMIL a very rich animation framework (see below). The simplest is to specify a clock-value which syntax is quite intuitive [http://www.w3.org/TR/SVG11/animate.html#ClockValueSyntax (SPEC)]. Depending on the combination of those 3 attributes, the interval of time of the animation will be [begin, end], [begin, begin+dur], [end-dur, end], etc.&lt;br /&gt;
&lt;br /&gt;
To specify the values taken over the time interval, one need to tell the value that the parameter must have at the begin and at the end of the interval. here again those values are specified by combinations of three attributes: &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;by&amp;lt;/code&amp;gt;. The attribute &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt; correspond to the begin value, the attribute &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; correspond to the end value. The attribute &amp;lt;code&amp;gt;by&amp;lt;/code&amp;gt; let you define either the initial and final values relative to the other one, that is to = from + by or from = to - by. The following image illusttrate this setup for our hypothetical attribute A&lt;br /&gt;
&lt;br /&gt;
[[Image:time_interval.png]]&lt;br /&gt;
&lt;br /&gt;
The values of A are simply interpolated '''linearly''' in between begin and end. This is the more simple form of '''animation function''' that can defined: by the two extremal pairs of (time, attribute value): (begin, from) and (end, to).&lt;br /&gt;
&lt;br /&gt;
=== More complex timing ===&lt;br /&gt;
&lt;br /&gt;
It's possible to specify a whole set of (keytime, keyvalue) pairs to define the animation function. Each item of the pairs are actually given separately:&lt;br /&gt;
* the set of attribute values (keyvalues) are given by the &amp;lt;code&amp;gt;values&amp;lt;/code&amp;gt; attribute.&lt;br /&gt;
* the set of time values (keytimes) are given by the &amp;lt;code&amp;gt;keyTimes&amp;lt;/code&amp;gt; attribute.&lt;br /&gt;
&lt;br /&gt;
Each set as the form of a semicolon-separated list of values. The thing to notice is that the keytimes are actually '''normalized to [0,1]''', which means that 0 maps to begin and 1 maps to end, and those values must start and end the list of keytimes. The image below illustrates all this:&lt;br /&gt;
&lt;br /&gt;
[[Image:time_interval2.png]]&lt;br /&gt;
&lt;br /&gt;
The keyTimes list can actually be omitted. In this cases the keytimes are evenly in interval [0,1] (equivalently, evenly in the interval [begin, end])&lt;br /&gt;
&lt;br /&gt;
The (keytime, keyvalue) pairs are joined by straight lines in the above graph, which means that we use '''linear interpolation''' for computing the inbetween values. &lt;br /&gt;
&lt;br /&gt;
When applied to the position of an object, linear interpolation results in un-natural robot-like motions (which may the effect wanted). SMIL allows smoother animations by defining '''spline-based interpolation''' between two (keytime, keyvalue) pairs. For each interval (t0, v0) - (t1, v1) a spline can be defined by two control points defining the tangents of the spline at t0 and t1. Those control points are passed in the attribute &amp;lt;code&amp;gt;keySplines&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:spline_interpolation.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Two other interpolation modes are possible:&lt;br /&gt;
* '''discrete''': this is a degenerate form of interpolation, because the resulting animation function is not continuous. For each interval (t0,v0) - (t1, v1), the attribute value is set to v0 for the whole interval. It ''jumps'' to v1 right when t1 is reached and so on.&lt;br /&gt;
* '''paced''': in this interpolation mode, the attribute is interpolated so that its evolution over time has '''constant speed'''. Because the animation function is defined implicitly, the attribute &amp;lt;code&amp;gt;keyTimes&amp;lt;/code&amp;gt; is not taken into account. This mode is mainly useful for the &amp;lt;code&amp;gt;animateMotion&amp;lt;/code&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
=== Other aspects of animation ===&lt;br /&gt;
* repeating&lt;br /&gt;
* chaining animations.&lt;br /&gt;
* event based synchronisation&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
Examples showcasing some of the effects that can be achieved using procedural animation in SVG.&lt;br /&gt;
&lt;br /&gt;
== Useful tools ==&lt;br /&gt;
&lt;br /&gt;
* [http://xmlgraphics.apache.org/batik/tools/browser.html Squiggle ], as part of [http://xmlgraphics.apache.org/batik/ Batik 1.7] has a nearly complete support for SMIL Animation. The [[#Examples|examples]] were all rendered using Squiggle.&lt;br /&gt;
* Inkscape ! I used the xml editor to manually add the animation elements for my test. It's a bit more cumbersome than editing the svg file in a text editor, but doing that in Inkscape eases the computation of key positions (just move the object around and read the position values).&lt;br /&gt;
&lt;br /&gt;
== Various thoughts ==&lt;br /&gt;
&lt;br /&gt;
* There is no direct way to specify a &amp;lt;b&amp;gt;''ping-pong'' animation&amp;lt;/b&amp;gt; in SVG, that is to tell an animation to go back in time when it reaches it's end. To implement this, I see 2 solutions:&lt;br /&gt;
**double the duration d of the animation (&amp;lt;code&amp;gt;dur&amp;lt;/code&amp;gt; attribute) et apply a scale and a symetry around t=0.5 to the animation function. For example the simple linear interpolation defined by &amp;lt;code&amp;gt;keyTimes=&amp;quot;0; 1&amp;quot;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;keyPoints=&amp;quot;0;1&amp;quot;&amp;lt;/code&amp;gt; becomes &amp;lt;code&amp;gt;keyTimes=&amp;quot;0; 0.5; 1&amp;quot;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;keyPoints=&amp;quot;0;1;0&amp;quot;&amp;lt;/code&amp;gt;. This doesn't work for &amp;lt;code&amp;gt;paced&amp;lt;/code&amp;gt; animation though (which make use of an implicit, user-agent dependent animation function).&lt;br /&gt;
** copy the original animation (call it e.g. &amp;lt;code&amp;gt;motion_forward&amp;lt;/code&amp;gt;) and swap the &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; values in the copy. Then specify &amp;lt;code&amp;gt;begin=&amp;quot;motion_forward.end&amp;quot;&amp;lt;/code&amp;gt; to tell the backward animation to start right at the end of the forward animation. This should work for every animation type.&lt;br /&gt;
&lt;br /&gt;
The question is: what maps best to a UI ?&lt;/div&gt;</summary>
		<author><name>ToF</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation&amp;diff=23264</id>
		<title>SVG Animation</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation&amp;diff=23264"/>
		<updated>2008-03-09T20:39:35Z</updated>

		<summary type="html">&lt;p&gt;ToF: /* Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is a '''work in progress'''. [[User:ToF|ToF]]&lt;br /&gt;
&lt;br /&gt;
== SVG Animation ==&lt;br /&gt;
&lt;br /&gt;
Animation in SVG is defined in the Animation Module of the [http://www.w3.org/TR/SVG11/animate.html SVG specification]. Animation in SVG conforms to the [http://www.w3.org/TR/2001/REC-smil-animation-20010904/ SMIL specification] (Synchronized Multimedia Integration Language) and extends it (SVG is said to be a ''host'' language of SMIL).&lt;br /&gt;
&lt;br /&gt;
Here I only focus on procedural animation and not programmatic animation (using a scripting language manipulating the DOM). &lt;br /&gt;
&lt;br /&gt;
In SMIL an animation is an object which defines the evolution of a given attribute of a given object (here an SVG element - path, rect, group...) over time. Multiple animations can control the evolution of particular attribute: for example, one will tell the object to turn for 1 second starting at t=0 second and another to move across the document for 2 seconds starting at a later time. So we have this relation:&lt;br /&gt;
             1:n&lt;br /&gt;
  Element &amp;lt;-------&amp;gt; Animation&lt;br /&gt;
&lt;br /&gt;
For a given animation the element which is controlled is called the '''target''' element of the animation. The specific attribute/property which is controlled is called the '''target''' attribute/property.&lt;br /&gt;
&lt;br /&gt;
In fact, it's completely legal to have two animations that control the same attribute of the same element, and they can overlap in time: at any particular time there exists a ''stack'' of animations applying to a particular attribute, and SMIL defines the order in which each animation is applied.&lt;br /&gt;
&lt;br /&gt;
== Animation elements ==&lt;br /&gt;
&lt;br /&gt;
SVG defines 5 animation elements:&lt;br /&gt;
* '''animate'''&lt;br /&gt;
This element is used to animate any scalar attribute or property, such as the &amp;lt;code&amp;gt;width&amp;lt;/code&amp;gt; attribute of an svg:rect element or the CCS property &amp;lt;code&amp;gt;opacity&amp;lt;/code&amp;gt;&lt;br /&gt;
* '''animateMotion'''&lt;br /&gt;
This elements only controls the position of a SVG element, by telling it to follow a given path&lt;br /&gt;
* '''animateColor'''&lt;br /&gt;
This element controls the animation of color valued attributes and properties.&lt;br /&gt;
* '''animateTransform'''&lt;br /&gt;
This element controls the transformation which applies to the target element. It replaces or adds up to the &amp;lt;code&amp;gt;transform&amp;lt;/code&amp;gt; attribute of the element.&lt;br /&gt;
* '''set'''&lt;br /&gt;
This element is used to set a particular value for the target attribute during a specified time interval. It is mainly used for animating attributes which do not span a continuous domain, such as boolean values like the &amp;lt;code&amp;gt;visibility&amp;lt;/code&amp;gt; property.&lt;br /&gt;
&lt;br /&gt;
== Specifying the target element and property ==&lt;br /&gt;
&lt;br /&gt;
There are 2 ways to tell which element a given animation will target. The first one is to embed the [[#Animation elements|animation element]] as a child tag of the element to animate. Here is an example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;circle cx=&amp;quot;100px&amp;quot; cy=&amp;quot;100px&amp;quot; r=&amp;quot;20px&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;animate attributeName=&amp;quot;r&amp;quot; attributeType=&amp;quot;XML&amp;quot; begin=&amp;quot;1s&amp;quot; dur=&amp;quot;2s&amp;quot; from=&amp;quot;20px&amp;quot; to=&amp;quot;50px&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/circle&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;animate&amp;lt;/code&amp;gt; element targets the radius (&amp;lt;code&amp;gt;r&amp;lt;/code&amp;gt;) property of the parent &amp;lt;code&amp;gt;circle&amp;lt;/code&amp;gt; element. Starting 1 second after the document start, the radius will grow for 2 seconds from 20 pixels to 50 pixels. When nothing else is specified, the animation only applies in its interval of time, here [1-3] seconds; from 0 to 1 second and then from 3 second and after, the circle's radius is set back to its ''static'' attribute value, here 20 pixels.&lt;br /&gt;
&lt;br /&gt;
The other way to specify the target element is to reference it in via an &amp;lt;code&amp;gt;xlink:href&amp;lt;/code&amp;gt; attribute of the animation element. the previous animation could be written this way:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;circle id=&amp;quot;balloon&amp;quot; cx=&amp;quot;100px&amp;quot; cy=&amp;quot;100px&amp;quot; r=&amp;quot;20px&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;animate xlink:href=&amp;quot;#balloon&amp;quot; attributeName=&amp;quot;r&amp;quot; attributeType=&amp;quot;XML&amp;quot; begin=&amp;quot;1s&amp;quot; dur=&amp;quot;2s&amp;quot; from=&amp;quot;20px&amp;quot; to=&amp;quot;50px&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To specify which property or attribute of the target element is controlled, we use the two attributes &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;attributeType&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; explains itself, it's the name of the controlled attribute. &amp;lt;code&amp;gt;attributeType&amp;lt;/code&amp;gt; tells whether &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; is searched among the SVG attributes of the element (&amp;lt;code&amp;gt;attributeType=&amp;quot;XML&amp;quot;&amp;lt;/code&amp;gt;) or among the CSS properties of the element (&amp;lt;code&amp;gt;attributeType=&amp;quot;CSS&amp;quot;&amp;lt;/code&amp;gt;). [http://www.w3.org/TR/SVG11/animate.html#TargetElement (SPEC)]&lt;br /&gt;
&lt;br /&gt;
== Timing an animation ==&lt;br /&gt;
&lt;br /&gt;
The first thing to stress is that SMIL (and therefore SVG) animation is '''time-based''', as opposed to '''frame-based'''. '''Frame-based''' animation is something traditional animators are used to, because they actually draw each image of the animation on a separate celluloid sheet, and the timing is related to the rate of images per second the camera will capture. When animation is done on a computer, the animator doesn't draw every image but only some ''key'' images (or ''keyframes'') and then the animation software creates all the necessary images for him (the so-called ''in-betweens''). That means the animator can focus back to a (real-)time based timing. Each keyframe is positioned on a timeline with real time values (instead of frame numbers). Of course at the end the animation is discrete and there is a fixed number of images computed inbetween two keyframes, but the neat property of specifying keyframes at time position is that the final animation frame rate is scalable and the animator doesn't have to care about it anymore. He just tells the software to produce 24 images each second if he targets a theatre film or say 10 images per second for low-bandwidth web animation. The animator doesn't need to reposition the keyframes.&lt;br /&gt;
&lt;br /&gt;
=== In-betweening by interpolation ===&lt;br /&gt;
&lt;br /&gt;
Creating the inbetween images on a computer is done by mean of '''interpolation'''. Interpolation is a mathematical tool that can reconstruct a the continuous evolution of a parameter given a set of discrete values of this parameter over time.&lt;br /&gt;
The following image illustrates that. We know that some attribute A must take value A0, A1, A2 and A3 at times t0, t1, t2 and t3. The red curves is one of the possible continuous function that be used to compute inbetween values of A in the interval [t0, t3].&lt;br /&gt;
&lt;br /&gt;
[[Image:interpolation.png]]&lt;br /&gt;
&lt;br /&gt;
* which extent of time ?&lt;br /&gt;
* Which extent of time ?&lt;br /&gt;
The first aspect that characterizes an animation is the interval of time on which it applies: when does it begin, when does it end or how long does it run.&lt;br /&gt;
Any of the above mentioned [[#Animation elements|animation elements] accept the attributes &amp;lt;code&amp;gt;begin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;dur&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
There are many ways to define a particular point in time and this is what makes SMIL a very rich animation framework (see below). The simplest is to specify a clock-value which syntax is quite intuitive [http://www.w3.org/TR/SVG11/animate.html#ClockValueSyntax (SPEC)]. Depending on the combination of those 3 attributes, the interval of time of the animation will be [begin, end], [begin, begin+dur], [end-dur, end], etc.&lt;br /&gt;
&lt;br /&gt;
To specify the values taken over the time interval, one need to tell the value that the parameter must have at the begin and at the end of the interval. here again those values are specified by combinations of three attributes: &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;by&amp;lt;/code&amp;gt;. The attribute &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt; correspond to the begin value, the attribute &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; correspond to the end value. The attribute &amp;lt;code&amp;gt;by&amp;lt;/code&amp;gt; let you define either the initial and final values relative to the other one, that is to = from + by or from = to - by. The following image illusttrate this setup for our hypothetical attribute A&lt;br /&gt;
&lt;br /&gt;
[[Image:time_interval.png]]&lt;br /&gt;
&lt;br /&gt;
The values of A are simply interpolated '''linearly''' in between begin and end. This is the more simple form of '''animation function''' that can defined: by the two extremal pairs of (time, attribute value): (begin, from) and (end, to).&lt;br /&gt;
&lt;br /&gt;
=== More complex timing ===&lt;br /&gt;
&lt;br /&gt;
It's possible to specify a whole set of (keytime, keyvalue) pairs to define the animation function. Each item of the pairs are actually given separately:&lt;br /&gt;
* the set of attribute values (keyvalues) are given by the &amp;lt;code&amp;gt;values&amp;lt;/code&amp;gt; attribute.&lt;br /&gt;
* the set of time values (keytimes) are given by the &amp;lt;code&amp;gt;keyTimes&amp;lt;/code&amp;gt; attribute.&lt;br /&gt;
&lt;br /&gt;
Each set as the form of a semicolon-separated list of values. The thing to notice is that the keytimes are actually '''normalized to [0,1]''', which means that 0 maps to begin and 1 maps to end, and those values must start and end the list of keytimes. The image below illustrates all this:&lt;br /&gt;
&lt;br /&gt;
[[Image:time_interval2.png]]&lt;br /&gt;
&lt;br /&gt;
The keyTimes list can actually be omitted. In this cases the keytimes are evenly in interval [0,1] (equivalently, evenly in the interval [begin, end])&lt;br /&gt;
&lt;br /&gt;
The (keytime, keyvalue) pairs are joined by straight lines in the above graph, which means that we use '''linear interpolation''' for computing the inbetween values. &lt;br /&gt;
&lt;br /&gt;
When applied to the position of an object, linear interpolation results in un-natural robot-like motions (which may the effect wanted). SMIL allows smoother animations by defining '''spline-based interpolation''' between two (keytime, keyvalue) pairs. For each interval (t0, v0) - (t1, v1) a spline can be defined by two control points defining the tangents of the spline at t0 and t1. Those control points are passed in the attribute &amp;lt;code&amp;gt;keySplines&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:spline_interpolation.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Two other interpolation modes are possible:&lt;br /&gt;
* '''discrete''': this is a degenerate form of interpolation, because the resulting animation function is not continuous. For each interval (keytime_1, keyvalue_1) - (keytime_2, keyvalue_2), the attribute value is set to keyvalue_1. It ''jumps'' to keyvalue_2 right after keytime_2 and so on.&lt;br /&gt;
* '''paced''': in this interpolation mode, the attribute is interpolated so that its evolution over time has '''constant speed'''. Because the animation function is defined implicitly, the attribute &amp;lt;code&amp;gt;keyTimes&amp;lt;/code&amp;gt; is not taken into account. This mode is mainly useful for the &amp;lt;code&amp;gt;animateMotion&amp;lt;/code&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
=== Other aspects of animation ===&lt;br /&gt;
* repeating&lt;br /&gt;
* chaining animations.&lt;br /&gt;
* event based synchronisation&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
Examples showcasing some of the effects that can be achieved using procedural animation in SVG.&lt;br /&gt;
&lt;br /&gt;
== Useful tools ==&lt;br /&gt;
&lt;br /&gt;
* [http://xmlgraphics.apache.org/batik/tools/browser.html Squiggle ], as part of [http://xmlgraphics.apache.org/batik/ Batik 1.7] has a nearly complete support for SMIL Animation. The [[#Examples|examples]] were all rendered using Squiggle.&lt;br /&gt;
* Inkscape ! I used the xml editor to manually add the animation elements for my test. It's a bit more cumbersome than editing the svg file in a text editor, but doing that in Inkscape eases the computation of key positions (just move the object around and read the position values).&lt;br /&gt;
&lt;br /&gt;
== Various thoughts ==&lt;br /&gt;
&lt;br /&gt;
* There is no direct way to specify a &amp;lt;b&amp;gt;''ping-pong'' animation&amp;lt;/b&amp;gt; in SVG, that is to tell an animation to go back in time when it reaches it's end. To implement this, I see 2 solutions:&lt;br /&gt;
**double the duration d of the animation (&amp;lt;code&amp;gt;dur&amp;lt;/code&amp;gt; attribute) et apply a scale and a symetry around t=0.5 to the animation function. For example the simple linear interpolation defined by &amp;lt;code&amp;gt;keyTimes=&amp;quot;0; 1&amp;quot;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;keyPoints=&amp;quot;0;1&amp;quot;&amp;lt;/code&amp;gt; becomes &amp;lt;code&amp;gt;keyTimes=&amp;quot;0; 0.5; 1&amp;quot;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;keyPoints=&amp;quot;0;1;0&amp;quot;&amp;lt;/code&amp;gt;. This doesn't work for &amp;lt;code&amp;gt;paced&amp;lt;/code&amp;gt; animation though (which make use of an implicit, user-agent dependent animation function).&lt;br /&gt;
** copy the original animation (call it e.g. &amp;lt;code&amp;gt;motion_forward&amp;lt;/code&amp;gt;) and swap the &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; values in the copy. Then specify &amp;lt;code&amp;gt;begin=&amp;quot;motion_forward.end&amp;quot;&amp;lt;/code&amp;gt; to tell the backward animation to start right at the end of the forward animation. This should work for every animation type.&lt;br /&gt;
&lt;br /&gt;
The question is: what maps best to a UI ?&lt;/div&gt;</summary>
		<author><name>ToF</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation&amp;diff=23254</id>
		<title>SVG Animation</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation&amp;diff=23254"/>
		<updated>2008-03-09T20:28:34Z</updated>

		<summary type="html">&lt;p&gt;ToF: /* Timing an animation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is a '''work in progress'''. [[User:ToF|ToF]]&lt;br /&gt;
&lt;br /&gt;
== SVG Animation ==&lt;br /&gt;
&lt;br /&gt;
Animation in SVG is defined in the Animation Module of the [http://www.w3.org/TR/SVG11/animate.html SVG specification]. Animation in SVG conforms to the [http://www.w3.org/TR/2001/REC-smil-animation-20010904/ SMIL specification] (Synchronized Multimedia Integration Language) and extends it (SVG is said to be a ''host'' language of SMIL).&lt;br /&gt;
&lt;br /&gt;
Here I only focus on procedural animation and not programmatic animation (using a scripting language manipulating the DOM). &lt;br /&gt;
&lt;br /&gt;
In SMIL an animation is an object which defines the evolution of a given attribute of a given object (here an SVG element - path, rect, group...) over time. Multiple animations can control the evolution of particular attribute: for example, one will tell the object to turn for 1 second starting at t=0 second and another to move across the document for 2 seconds starting at a later time. So we have this relation:&lt;br /&gt;
             1:n&lt;br /&gt;
  Element &amp;lt;-------&amp;gt; Animation&lt;br /&gt;
&lt;br /&gt;
For a given animation the element which is controlled is called the '''target''' element of the animation. The specific attribute/property which is controlled is called the '''target''' attribute/property.&lt;br /&gt;
&lt;br /&gt;
In fact, it's completely legal to have two animations that control the same attribute of the same element, and they can overlap in time: at any particular time there exists a ''stack'' of animations applying to a particular attribute, and SMIL defines the order in which each animation is applied.&lt;br /&gt;
&lt;br /&gt;
== Animation elements ==&lt;br /&gt;
&lt;br /&gt;
SVG defines 5 animation elements:&lt;br /&gt;
* '''animate'''&lt;br /&gt;
This element is used to animate any scalar attribute or property, such as the &amp;lt;code&amp;gt;width&amp;lt;/code&amp;gt; attribute of an svg:rect element or the CCS property &amp;lt;code&amp;gt;opacity&amp;lt;/code&amp;gt;&lt;br /&gt;
* '''animateMotion'''&lt;br /&gt;
This elements only controls the position of a SVG element, by telling it to follow a given path&lt;br /&gt;
* '''animateColor'''&lt;br /&gt;
This element controls the animation of color valued attributes and properties.&lt;br /&gt;
* '''animateTransform'''&lt;br /&gt;
This element controls the transformation which applies to the target element. It replaces or adds up to the &amp;lt;code&amp;gt;transform&amp;lt;/code&amp;gt; attribute of the element.&lt;br /&gt;
* '''set'''&lt;br /&gt;
This element is used to set a particular value for the target attribute during a specified time interval. It is mainly used for animating attributes which do not span a continuous domain, such as boolean values like the &amp;lt;code&amp;gt;visibility&amp;lt;/code&amp;gt; property.&lt;br /&gt;
&lt;br /&gt;
== Specifying the target element and property ==&lt;br /&gt;
&lt;br /&gt;
There are 2 ways to tell which element a given animation will target. The first one is to embed the [[#Animation elements|animation element]] as a child tag of the element to animate. Here is an example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;circle cx=&amp;quot;100px&amp;quot; cy=&amp;quot;100px&amp;quot; r=&amp;quot;20px&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;animate attributeName=&amp;quot;r&amp;quot; attributeType=&amp;quot;XML&amp;quot; begin=&amp;quot;1s&amp;quot; dur=&amp;quot;2s&amp;quot; from=&amp;quot;20px&amp;quot; to=&amp;quot;50px&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/circle&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;animate&amp;lt;/code&amp;gt; element targets the radius (&amp;lt;code&amp;gt;r&amp;lt;/code&amp;gt;) property of the parent &amp;lt;code&amp;gt;circle&amp;lt;/code&amp;gt; element. Starting 1 second after the document start, the radius will grow for 2 seconds from 20 pixels to 50 pixels. When nothing else is specified, the animation only applies in its interval of time, here [1-3] seconds; from 0 to 1 second and then from 3 second and after, the circle's radius is set back to its ''static'' attribute value, here 20 pixels.&lt;br /&gt;
&lt;br /&gt;
The other way to specify the target element is to reference it in via an &amp;lt;code&amp;gt;xlink:href&amp;lt;/code&amp;gt; attribute of the animation element. the previous animation could be written this way:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;circle id=&amp;quot;balloon&amp;quot; cx=&amp;quot;100px&amp;quot; cy=&amp;quot;100px&amp;quot; r=&amp;quot;20px&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;animate xlink:href=&amp;quot;#balloon&amp;quot; attributeName=&amp;quot;r&amp;quot; attributeType=&amp;quot;XML&amp;quot; begin=&amp;quot;1s&amp;quot; dur=&amp;quot;2s&amp;quot; from=&amp;quot;20px&amp;quot; to=&amp;quot;50px&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To specify which property or attribute of the target element is controlled, we use the two attributes &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;attributeType&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; explains itself, it's the name of the controlled attribute. &amp;lt;code&amp;gt;attributeType&amp;lt;/code&amp;gt; tells whether &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; is searched among the SVG attributes of the element (&amp;lt;code&amp;gt;attributeType=&amp;quot;XML&amp;quot;&amp;lt;/code&amp;gt;) or among the CSS properties of the element (&amp;lt;code&amp;gt;attributeType=&amp;quot;CSS&amp;quot;&amp;lt;/code&amp;gt;). [http://www.w3.org/TR/SVG11/animate.html#TargetElement (SPEC)]&lt;br /&gt;
&lt;br /&gt;
== Timing an animation ==&lt;br /&gt;
&lt;br /&gt;
The first thing to stress is that SMIL (and therefore SVG) animation is '''time-based''', as opposed to '''frame-based'''. '''Frame-based''' animation is something traditional animators are used to, because they actually draw each image of the animation on a separate celluloid sheet, and the timing is related to the rate of images per second the camera will capture. When animation is done on a computer, the animator doesn't draw every image but only some ''key'' images (or ''keyframes'') and then the animation software creates all the necessary images for him (the so-called ''in-betweens''). That means the animator can focus back to a (real-)time based timing. Each keyframe is positioned on a timeline with real time values (instead of frame numbers). Of course at the end the animation is discrete and there is a fixed number of images computed inbetween two keyframes, but the neat property of specifying keyframes at time position is that the final animation frame rate is scalable and the animator doesn't have to care about it anymore. He just tells the software to produce 24 images each second if he targets a theatre film or say 10 images per second for low-bandwidth web animation. The animator doesn't need to reposition the keyframes.&lt;br /&gt;
&lt;br /&gt;
=== In-betweening by interpolation ===&lt;br /&gt;
&lt;br /&gt;
Creating the inbetween images on a computer is done by mean of '''interpolation'''. Interpolation is a mathematical tool that can reconstruct a the continuous evolution of a parameter given a set of discrete values of this parameter over time.&lt;br /&gt;
The following image illustrates that. We know that some attribute A must take value A0, A1, A2 and A3 at times t0, t1, t2 and t3. The red curves is one of the possible continuous function that be used to compute inbetween values of A in the interval [t0, t3].&lt;br /&gt;
&lt;br /&gt;
[[Image:interpolation.png]]&lt;br /&gt;
&lt;br /&gt;
* which extent of time ?&lt;br /&gt;
* Which extent of time ?&lt;br /&gt;
The first aspect that characterizes an animation is the interval of time on which it applies: when does it begin, when does it end or how long does it run.&lt;br /&gt;
Any of the above mentioned [[#Animation elements|animation elements] accept the attributes &amp;lt;code&amp;gt;begin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;dur&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
There are many ways to define a particular point in time and this is what makes SMIL a very rich animation framework (see below). The simplest is to specify a clock-value which syntax is quite intuitive [http://www.w3.org/TR/SVG11/animate.html#ClockValueSyntax (SPEC)]. Depending on the combination of those 3 attributes, the interval of time of the animation will be [begin, end], [begin, begin+dur], [end-dur, end], etc.&lt;br /&gt;
&lt;br /&gt;
To specify the values taken over the time interval, one need to tell the value that the parameter must have at the begin and at the end of the interval. here again those values are specified by combinations of three attributes: &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;by&amp;lt;/code&amp;gt;. The attribute &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt; correspond to the begin value, the attribute &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; correspond to the end value. The attribute &amp;lt;code&amp;gt;by&amp;lt;/code&amp;gt; let you define either the initial and final values relative to the other one, that is to = from + by or from = to - by. The following image illusttrate this setup for our hypothetical attribute A&lt;br /&gt;
&lt;br /&gt;
[[Image:time_interval.png]]&lt;br /&gt;
&lt;br /&gt;
The values of A are simply interpolated '''linearly''' in between begin and end. This is the more simple form of '''animation function''' that can defined: by the two extremal pairs of (time, attribute value): (begin, from) and (end, to).&lt;br /&gt;
&lt;br /&gt;
=== More complex timing ===&lt;br /&gt;
&lt;br /&gt;
It's possible to specify a whole set of (keytime, keyvalue) pairs to define the animation function. Each item of the pairs are actually given separately:&lt;br /&gt;
* the set of attribute values (keyvalues) are given by the &amp;lt;code&amp;gt;values&amp;lt;/code&amp;gt; attribute.&lt;br /&gt;
* the set of time values (keytimes) are given by the &amp;lt;code&amp;gt;keyTimes&amp;lt;/code&amp;gt; attribute.&lt;br /&gt;
&lt;br /&gt;
Each set as the form of a semicolon-separated list of values. The thing to notice is that the keytimes are actually '''normalized to [0,1]''', which means that 0 maps to begin and 1 maps to end, and those values must start and end the list of keytimes. The image below illustrates all this:&lt;br /&gt;
&lt;br /&gt;
[[Image:time_interval2.png]]&lt;br /&gt;
&lt;br /&gt;
The keyTimes list can actually be omitted. In this cases the keytimes are evenly in interval [0,1] (equivalently, evenly in the interval [begin, end])&lt;br /&gt;
&lt;br /&gt;
The (keytime, keyvalue) pairs are joined by straight lines in the above graph, which means that we use '''linear interpolation''' for computing the inbetween values. &lt;br /&gt;
&lt;br /&gt;
When applied to the position of an object, linear interpolation results in un-natural robot-like motions (which may the effect wanted). SMIL allows smoother animations by defining '''spline-based interpolation''' between two (keytime, keyvalue) pairs. For each interval (t0, v0) - (t1, v1) a spline can be defined by two control points defining the tangents of the spline at t0 and t1. Those control points are passed in the attribute &amp;lt;code&amp;gt;keySplines&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:spline_interpolation.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Two other interpolation modes are possible:&lt;br /&gt;
* '''discrete''': this is a degenerate form of interpolation, because the resulting animation function is not continuous. For each interval (keytime_1, keyvalue_1) - (keytime_2, keyvalue_2), the attribute value is set to keyvalue_1. It ''jumps'' to keyvalue_2 right after keytime_2 and so on.&lt;br /&gt;
* '''paced''': in this interpolation mode, the attribute is interpolated so that its evolution over time has '''constant speed'''. Because the animation function is defined implicitly, the attribute &amp;lt;code&amp;gt;keyTimes&amp;lt;/code&amp;gt; is not taken into account. This mode is mainly useful for the &amp;lt;code&amp;gt;animateMotion&amp;lt;/code&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
=== Other aspects of animation ===&lt;br /&gt;
* repeating&lt;br /&gt;
* chaining animations.&lt;br /&gt;
* event based synchronisation&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
The following examples showcase some of the effects that can be achieved using procedural animation in SVG.&lt;br /&gt;
&lt;br /&gt;
== Useful tools ==&lt;br /&gt;
&lt;br /&gt;
* [http://xmlgraphics.apache.org/batik/tools/browser.html Squiggle ], as part of [http://xmlgraphics.apache.org/batik/ Batik 1.7] has a nearly complete support for SMIL Animation. The [[#Examples|examples]] were all rendered using Squiggle.&lt;br /&gt;
* Inkscape ! I used the xml editor to manually add the animation elements for my test. It's a bit more cumbersome than editing the svg file in a text editor, but doing that in Inkscape eases the computation of key positions (just move the object around and read the position values).&lt;br /&gt;
&lt;br /&gt;
== Various thoughts ==&lt;br /&gt;
&lt;br /&gt;
* There is no direct way to specify a &amp;lt;b&amp;gt;''ping-pong'' animation&amp;lt;/b&amp;gt; in SVG, that is to tell an animation to go back in time when it reaches it's end. To implement this, I see 2 solutions:&lt;br /&gt;
**double the duration d of the animation (&amp;lt;code&amp;gt;dur&amp;lt;/code&amp;gt; attribute) et apply a scale and a symetry around t=0.5 to the animation function. For example the simple linear interpolation defined by &amp;lt;code&amp;gt;keyTimes=&amp;quot;0; 1&amp;quot;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;keyPoints=&amp;quot;0;1&amp;quot;&amp;lt;/code&amp;gt; becomes &amp;lt;code&amp;gt;keyTimes=&amp;quot;0; 0.5; 1&amp;quot;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;keyPoints=&amp;quot;0;1;0&amp;quot;&amp;lt;/code&amp;gt;. This doesn't work for &amp;lt;code&amp;gt;paced&amp;lt;/code&amp;gt; animation though (which make use of an implicit, user-agent dependent animation function).&lt;br /&gt;
** copy the original animation (call it e.g. &amp;lt;code&amp;gt;motion_forward&amp;lt;/code&amp;gt;) and swap the &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; values in the copy. Then specify &amp;lt;code&amp;gt;begin=&amp;quot;motion_forward.end&amp;quot;&amp;lt;/code&amp;gt; to tell the backward animation to start right at the end of the forward animation. This should work for every animation type.&lt;br /&gt;
&lt;br /&gt;
The question is: what maps best to a UI ?&lt;/div&gt;</summary>
		<author><name>ToF</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation&amp;diff=23244</id>
		<title>SVG Animation</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=SVG_Animation&amp;diff=23244"/>
		<updated>2008-03-09T20:24:23Z</updated>

		<summary type="html">&lt;p&gt;ToF: /* More complex timing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is a '''work in progress'''. [[User:ToF|ToF]]&lt;br /&gt;
&lt;br /&gt;
== SVG Animation ==&lt;br /&gt;
&lt;br /&gt;
Animation in SVG is defined in the Animation Module of the [http://www.w3.org/TR/SVG11/animate.html SVG specification]. Animation in SVG conforms to the [http://www.w3.org/TR/2001/REC-smil-animation-20010904/ SMIL specification] (Synchronized Multimedia Integration Language) and extends it (SVG is said to be a ''host'' language of SMIL).&lt;br /&gt;
&lt;br /&gt;
Here I only focus on procedural animation and not programmatic animation (using a scripting language manipulating the DOM). &lt;br /&gt;
&lt;br /&gt;
In SMIL an animation is an object which defines the evolution of a given attribute of a given object (here an SVG element - path, rect, group...) over time. Multiple animations can control the evolution of particular attribute: for example, one will tell the object to turn for 1 second starting at t=0 second and another to move across the document for 2 seconds starting at a later time. So we have this relation:&lt;br /&gt;
             1:n&lt;br /&gt;
  Element &amp;lt;-------&amp;gt; Animation&lt;br /&gt;
&lt;br /&gt;
For a given animation the element which is controlled is called the '''target''' element of the animation. The specific attribute/property which is controlled is called the '''target''' attribute/property.&lt;br /&gt;
&lt;br /&gt;
In fact, it's completely legal to have two animations that control the same attribute of the same element, and they can overlap in time: at any particular time there exists a ''stack'' of animations applying to a particular attribute, and SMIL defines the order in which each animation is applied.&lt;br /&gt;
&lt;br /&gt;
== Animation elements ==&lt;br /&gt;
&lt;br /&gt;
SVG defines 5 animation elements:&lt;br /&gt;
* '''animate'''&lt;br /&gt;
This element is used to animate any scalar attribute or property, such as the &amp;lt;code&amp;gt;width&amp;lt;/code&amp;gt; attribute of an svg:rect element or the CCS property &amp;lt;code&amp;gt;opacity&amp;lt;/code&amp;gt;&lt;br /&gt;
* '''animateMotion'''&lt;br /&gt;
This elements only controls the position of a SVG element, by telling it to follow a given path&lt;br /&gt;
* '''animateColor'''&lt;br /&gt;
This element controls the animation of color valued attributes and properties.&lt;br /&gt;
* '''animateTransform'''&lt;br /&gt;
This element controls the transformation which applies to the target element. It replaces or adds up to the &amp;lt;code&amp;gt;transform&amp;lt;/code&amp;gt; attribute of the element.&lt;br /&gt;
* '''set'''&lt;br /&gt;
This element is used to set a particular value for the target attribute during a specified time interval. It is mainly used for animating attributes which do not span a continuous domain, such as boolean values like the &amp;lt;code&amp;gt;visibility&amp;lt;/code&amp;gt; property.&lt;br /&gt;
&lt;br /&gt;
== Specifying the target element and property ==&lt;br /&gt;
&lt;br /&gt;
There are 2 ways to tell which element a given animation will target. The first one is to embed the [[#Animation elements|animation element]] as a child tag of the element to animate. Here is an example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;circle cx=&amp;quot;100px&amp;quot; cy=&amp;quot;100px&amp;quot; r=&amp;quot;20px&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;animate attributeName=&amp;quot;r&amp;quot; attributeType=&amp;quot;XML&amp;quot; begin=&amp;quot;1s&amp;quot; dur=&amp;quot;2s&amp;quot; from=&amp;quot;20px&amp;quot; to=&amp;quot;50px&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/circle&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;animate&amp;lt;/code&amp;gt; element targets the radius (&amp;lt;code&amp;gt;r&amp;lt;/code&amp;gt;) property of the parent &amp;lt;code&amp;gt;circle&amp;lt;/code&amp;gt; element. Starting 1 second after the document start, the radius will grow for 2 seconds from 20 pixels to 50 pixels. When nothing else is specified, the animation only applies in its interval of time, here [1-3] seconds; from 0 to 1 second and then from 3 second and after, the circle's radius is set back to its ''static'' attribute value, here 20 pixels.&lt;br /&gt;
&lt;br /&gt;
The other way to specify the target element is to reference it in via an &amp;lt;code&amp;gt;xlink:href&amp;lt;/code&amp;gt; attribute of the animation element. the previous animation could be written this way:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;circle id=&amp;quot;balloon&amp;quot; cx=&amp;quot;100px&amp;quot; cy=&amp;quot;100px&amp;quot; r=&amp;quot;20px&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;animate xlink:href=&amp;quot;#balloon&amp;quot; attributeName=&amp;quot;r&amp;quot; attributeType=&amp;quot;XML&amp;quot; begin=&amp;quot;1s&amp;quot; dur=&amp;quot;2s&amp;quot; from=&amp;quot;20px&amp;quot; to=&amp;quot;50px&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To specify which property or attribute of the target element is controlled, we use the two attributes &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;attributeType&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; explains itself, it's the name of the controlled attribute. &amp;lt;code&amp;gt;attributeType&amp;lt;/code&amp;gt; tells whether &amp;lt;code&amp;gt;attributeName&amp;lt;/code&amp;gt; is searched among the SVG attributes of the element (&amp;lt;code&amp;gt;attributeType=&amp;quot;XML&amp;quot;&amp;lt;/code&amp;gt;) or among the CSS properties of the element (&amp;lt;code&amp;gt;attributeType=&amp;quot;CSS&amp;quot;&amp;lt;/code&amp;gt;). [http://www.w3.org/TR/SVG11/animate.html#TargetElement (SPEC)]&lt;br /&gt;
&lt;br /&gt;
== Timing an animation ==&lt;br /&gt;
&lt;br /&gt;
The first thing to stress is that SMIL (and therefore SVG) animation is '''time-based''', as opposed to '''frame-based'''. '''Frame-based''' animation is something traditional animators are used to, because they actually draw each image of the animation on a separate celluloid sheet, and the timing is related to the rate of images per second the camera will capture. When animation is done on a computer, the animator doesn't draw every image but only some ''key'' images (or ''keyframes'') and then the animation software creates all the necessary images for him (the so-called ''in-betweens''). That means the animator can focus back to a (real-)time based timing. Each keyframe is positioned on a timeline with real time values (instead of frame numbers). Of course at the end the animation is discrete and there is a fixed number of images computed inbetween two keyframes, but the neat property of specifying keyframes at time position is that the final animation frame rate is scalable and the animator doesn't have to care about it anymore. He just tells the software to produce 24 images each second if he targets a theatre film or say 10 images per second for low-bandwidth web animation. The animator doesn't need to reposition the keyframes.&lt;br /&gt;
&lt;br /&gt;
The concepts:&lt;br /&gt;
* Interpolation&lt;br /&gt;
Creating the inbetween images on a computer is done by mean of '''interpolation'''. Interpolation is a mathematical tool that can reconstruct a the continuous evolution of a parameter given a set of discrete values of this parameter over time.&lt;br /&gt;
The following image illustrates that. We know that some attribute A must take value A0, A1, A2 and A3 at times t0, t1, t2 and t3. The red curves is one of the possible continuous function that be used to compute inbetween values of A in the interval [t0, t3].&lt;br /&gt;
&lt;br /&gt;
[[Image:interpolation.png]]&lt;br /&gt;
&lt;br /&gt;
* which extent of time ?&lt;br /&gt;
* Which extent of time ?&lt;br /&gt;
The first aspect that characterizes an animation is the interval of time on which it applies: when does it begin, when does it end or how long does it run.&lt;br /&gt;
Any of the above mentioned [[#Animation elements|animation elements] accept the attributes &amp;lt;code&amp;gt;begin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;dur&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
There are many ways to define a particular point in time and this is what makes SMIL a very rich animation framework (see below). The simplest is to specify a clock-value which syntax is quite intuitive [http://www.w3.org/TR/SVG11/animate.html#ClockValueSyntax (SPEC)]. Depending on the combination of those 3 attributes, the interval of time of the animation will be [begin, end], [begin, begin+dur], [end-dur, end], etc.&lt;br /&gt;
&lt;br /&gt;
To specify the values taken over the time interval, one need to tell the value that the parameter must have at the begin and at the end of the interval. here again those values are specified by combinations of three attributes: &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;by&amp;lt;/code&amp;gt;. The attribute &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt; correspond to the begin value, the attribute &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; correspond to the end value. The attribute &amp;lt;code&amp;gt;by&amp;lt;/code&amp;gt; let you define either the initial and final values relative to the other one, that is to = from + by or from = to - by. The following image illusttrate this setup for our hypothetical attribute A&lt;br /&gt;
&lt;br /&gt;
[[Image:time_interval.png]]&lt;br /&gt;
&lt;br /&gt;
The values of A are simply interpolated '''linearly''' in between begin and end. This is the more simple form of '''animation function''' that can defined: by the two extremal pairs of (time, attribute value): (begin, from) and (end, to).&lt;br /&gt;
&lt;br /&gt;
=== More complex timing ===&lt;br /&gt;
&lt;br /&gt;
It's possible to specify a whole set of (keytime, keyvalue) pairs to define the animation function. Each item of the pairs are actually given separately:&lt;br /&gt;
* the set of attribute values (keyvalues) are given by the &amp;lt;code&amp;gt;values&amp;lt;/code&amp;gt; attribute.&lt;br /&gt;
* the set of time values (keytimes) are given by the &amp;lt;code&amp;gt;keyTimes&amp;lt;/code&amp;gt; attribute.&lt;br /&gt;
&lt;br /&gt;
Each set as the form of a semicolon-separated list of values. The thing to notice is that the keytimes are actually '''normalized to [0,1]''', which means that 0 maps to begin and 1 maps to end, and those values must start and end the list of keytimes. The image below illustrates all this:&lt;br /&gt;
&lt;br /&gt;
[[Image:time_interval2.png]]&lt;br /&gt;
&lt;br /&gt;
The keyTimes list can actually be omitted. In this cases the keytimes are evenly in interval [0,1] (equivalently, evenly in the interval [begin, end])&lt;br /&gt;
&lt;br /&gt;
The (keytime, keyvalue) pairs are joined by straight lines in the above graph, which means that we use '''linear interpolation''' for computing the inbetween values. &lt;br /&gt;
&lt;br /&gt;
When applied to the position of an object, linear interpolation results in un-natural robot-like motions (which may the effect wanted). SMIL allows smoother animations by defining '''spline-based interpolation''' between two (keytime, keyvalue) pairs. For each interval (t0, v0) - (t1, v1) a spline can be defined by two control points defining the tangents of the spline at t0 and t1. Those control points are passed in the attribute &amp;lt;code&amp;gt;keySplines&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:spline_interpolation.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Two other interpolation modes are possible:&lt;br /&gt;
* '''discrete''': this is a degenerate form of interpolation, because the resulting animation function is not continuous. For each interval (keytime_1, keyvalue_1) - (keytime_2, keyvalue_2), the attribute value is set to keyvalue_1. It ''jumps'' to keyvalue_2 right after keytime_2 and so on.&lt;br /&gt;
* '''paced''': in this interpolation mode, the attribute is interpolated so that its evolution over time has '''constant speed'''. Because the animation function is defined implicitly, the attribute &amp;lt;code&amp;gt;keyTimes&amp;lt;/code&amp;gt; is not taken into account. This mode is mainly useful for the &amp;lt;code&amp;gt;animateMotion&amp;lt;/code&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
=== Other aspects of animation ===&lt;br /&gt;
* repeating&lt;br /&gt;
* chaining animations.&lt;br /&gt;
* event based synchronisation&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
The following examples showcase some of the effects that can be achieved using procedural animation in SVG.&lt;br /&gt;
&lt;br /&gt;
== Useful tools ==&lt;br /&gt;
&lt;br /&gt;
* [http://xmlgraphics.apache.org/batik/tools/browser.html Squiggle ], as part of [http://xmlgraphics.apache.org/batik/ Batik 1.7] has a nearly complete support for SMIL Animation. The [[#Examples|examples]] were all rendered using Squiggle.&lt;br /&gt;
* Inkscape ! I used the xml editor to manually add the animation elements for my test. It's a bit more cumbersome than editing the svg file in a text editor, but doing that in Inkscape eases the computation of key positions (just move the object around and read the position values).&lt;br /&gt;
&lt;br /&gt;
== Various thoughts ==&lt;br /&gt;
&lt;br /&gt;
* There is no direct way to specify a &amp;lt;b&amp;gt;''ping-pong'' animation&amp;lt;/b&amp;gt; in SVG, that is to tell an animation to go back in time when it reaches it's end. To implement this, I see 2 solutions:&lt;br /&gt;
**double the duration d of the animation (&amp;lt;code&amp;gt;dur&amp;lt;/code&amp;gt; attribute) et apply a scale and a symetry around t=0.5 to the animation function. For example the simple linear interpolation defined by &amp;lt;code&amp;gt;keyTimes=&amp;quot;0; 1&amp;quot;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;keyPoints=&amp;quot;0;1&amp;quot;&amp;lt;/code&amp;gt; becomes &amp;lt;code&amp;gt;keyTimes=&amp;quot;0; 0.5; 1&amp;quot;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;keyPoints=&amp;quot;0;1;0&amp;quot;&amp;lt;/code&amp;gt;. This doesn't work for &amp;lt;code&amp;gt;paced&amp;lt;/code&amp;gt; animation though (which make use of an implicit, user-agent dependent animation function).&lt;br /&gt;
** copy the original animation (call it e.g. &amp;lt;code&amp;gt;motion_forward&amp;lt;/code&amp;gt;) and swap the &amp;lt;code&amp;gt;from&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;to&amp;lt;/code&amp;gt; values in the copy. Then specify &amp;lt;code&amp;gt;begin=&amp;quot;motion_forward.end&amp;quot;&amp;lt;/code&amp;gt; to tell the backward animation to start right at the end of the forward animation. This should work for every animation type.&lt;br /&gt;
&lt;br /&gt;
The question is: what maps best to a UI ?&lt;/div&gt;</summary>
		<author><name>ToF</name></author>
	</entry>
</feed>