XML technologies / SVG / Using animations / Changing colors

(Excerpt from “Das Einsteigerseminar SVG — Webgrafiken mit XML” by Helma Spona)

Element colors can be changed with the tag <animateColor>. The next example uses it to change the color of the circle previously animated. Below the tag <animateMotion>, insert the tag <animateColor>:

<animateColor dur="6s" from="red" to="yellow" attributeName="fill" />

Again, dur sets the duration, from the starting color, and to the final color. The attribute attributeName determines whether the fill or border color should change. Thus, fill changes the fill, leaving the border color unchanged.

Here the color changes from red to yellow. The final color is reached when the circle reaches its destination, since this animation lasts as long as the movement animation.

Note:
Both tags, <animateMotion> and <animateColor>, have additional attributes explained in more detail under Ways to implement animations.

   

back to top