XML technologies / SVG / Using animations / Solutions

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

  1. Create the square with the instruction <rect x="0" y="0" width="4" height="4"/>.

  2. To fill it red, add to that tag style="fill:red".

  3. Add animation by placing the <animateColor> tag inside the <rect> tag.

<rect x="0" y="0" width="4" height="4" style="fill:red">
  <animateColor dur="10s" from="red" to="black" attributeName="fill" fill="freeze"/>
</rect>

  1. Since both height and width must change, add two more <animate> tags to the <rect> tag.

<animate dur="5s" begin="10s" from="4" to="8" attributeName="width" fill="freeze"/>
<animate dur="5s" begin="10s" from="4" to="8" attributeName="height" fill="freeze"/>

  1. Create the line with <line x1="0" y1="0" x2="75" y2="10"/>.

  2. The line cannot serve directly as an animation path, so also use the <animateMotion> tag’s path attribute:

<animateMotion path="M0 0 L75 10" dur="8s" fill="freeze"/>

   

 

 

 

back to top