The <animate> element allows changes to
be made to scalar SVG attributes or to CSS properties over
time.
This element designates a specific property (via the attributeName
attribute) whose value is changed from the value designated
as the from attribute to the value designated as
the to attribute over the amount of time specified
in the dur attribute. The repeatCount
attribute designates how many times the animation takes
place. To make the animation run indefinitely, set the value
of repeatCount to indefinite.
Example
1 - Animating Motoion
SVG Image
<?xml version="1.0"
standalone="no"?>
Right-click
on the image to open the SVG viewer pop-up menu. Click
'view SVG' to display the image in a new, full window
to zoom & pan the image.
(SVG Viewer Tips)
<!DOCTYPE svg PUBLIC "-//W3C//DTD
SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
We can animate the square horizontally
by animating the x attribute The square then moves
from the initial position 0 to position 90 along the
x-axis in 10 seconds (dur="10s")
and start over again and again (repeatCount="indefinite").
Similarily,we animate the square vertically by animating
the y attribute. When we animate simultaneously both
the x and y attributes, the square moves diagonally
across the screen.
This example creates a square with
a stroke-width that gradually thickens to 50 pixels,
then goes back to 1 and starts again. Note that the
attributeType attribute, which differentiates
whether the target is XML (this is the default) or
CSS. To animate a property, the attributeType
is given the value 'CSS' and the CSS name
is defined by the attributeName attribute.
We can animate more than the simple
elements like size. In this example, the blue gradient's
stop offset property grows during the 4 seconds,
causing the white gradient to grow outwards and produce
an explosion effect.