XML technologies / SVG / Using animations / The SVG tags for animations
(Excerpt from “Das Einsteigerseminar SVG — Webgrafiken mit XML” by Helma Spona)
SVG provides several animation tags. An overview comes first, followed by examples of the main tags; details follow at the chapter’s end.
Which tags define animations?
<animate>dynamically changes individual attributes. Insert it inside the target element. Any animatable attribute can be changed; the W3C SVG documentation identifies each withanimatable:nooranimatable:yes. The latter means the attribute can be changed dynamically with the<animate>tag.<animateMotion>moves an element along a path.<animateColor>changes an element’s color.<animateTransform>changes transformation instructions set with thetransformattribute.<mpath>defines an additional child path for the tag<animateMotion>.
Some other attributes also matter for animation and are explained in detail later. First, the animation basics follow.
Assigning an animation to an SVG element
To animate an element of an SVG graphic, define the animation. Separate animation tags may at first seem problematic because they do not define the graphic elements themselves. The solution is simple: insert the tags <animateMotion>, <animateColor>, <animateTransform> and <animate> as children of those elements. For example, to move an element along a path, put the tag <animateMotion> inside its tag:
<rect …>
<animateMotion … />
</rect>
This specifies that the <rect> element should move. The attributes of the <animateMotion> tag supply the details.
Note:
The animated element therefore needs a separate closing tag rather than ending with /> in its opening tag. Any tag can be written this way, for example replacing <rect/> with <rect></rect>.
Copyright © verlag moderne industrie GmbH 2001
You may print the online version for your private use.
Otherwise, this chapter from “Das Einsteigerseminar SVG — Webgrafiken mit XML” is subject to the same conditions as the bound edition. The work, including all its parts, is protected by copyright. All rights reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
verlag moderne industrie GmbH, Justus-von-Liebig-Straße 1, D-86899 Landsberg/Lech, fon ++49 (0) 81 91 / 125 – 0, leserservice(at)mi-verlag.de