Sources :
http://www.w3.org/2002/Talks/0328-Amsterdam-IH/directoryslide.svgz
http://www.kevlindev.com/tutorials/javascript/inheritance/index.htm
http://www.yoyodesign.org/doc/w3c/svg1/animate.html
Livre SVG essential.O'Reilly
L'exemple ci-dessus utilisait la balise animate :
<rect x="10" y="10" width="200" height="20" style="stroke: black; fill: none;">
<animate
attributeName="width"
attributeType="XML"
from="200" to="20"
begin="0s" dur="5s"
repeatCount="indefinite"
fill="freeze" />
</rect>
Un autre exemple:
<svg width="300" height="250" viewBox="0 0 300 250"> <title>Multiple Animations on a Single Object</title> <rect x="10" y="10" width="20" height="20" style="stroke: black; fill: green; style: fill-opacity: 0.25;"> <animate attributeName="width" attributeType="XML" <animate attributeName="height" attributeType="XML" <animate attributeName="fill-opacity" attributeType="CSS" <animate attributeName="fill-opacity" attributeType="CSS" </rect> </svg> |
<svg width="300" height="200" viewBox="0 0 300 200"> <title>Example of set element</title> <circle cx="60" cy="60" r="30" style="fill: #ff9; stroke: gray;"> <animate id="c1" attributeName="r" attributeType="XML" </circle> <text text-anchor="middle" x="60" y="60" style="visibility: hidden;"> <set attributeName="visibility" attributeType="CSS" </svg> |
Nb: ici pas besoin de "from"
L'attribut path...
<svg width="300" height="200" viewBox="0 0 300 200"> <title>Animation Along a Complex Path</title> <!-- show the path along which the triangle will move --> <path d="M50,125 C 100,25 150,225, 200, 125" style="fill: none; stroke: blue;"/> <!-- Triangle to be moved along the motion path. It is defined with an upright orientation with the base of the triangle centered horizontally just above the origin. --> <path d="M-10,-3 L10,-3 L0,-25z" style="fill: yellow; stroke: red;"> <animateMotion path="M50,125 C 100,25 150,225, 200, 125" dur="6s" fill="freeze" repeatCount="indefinite"/> </path> </svg> |
L'attribut rotate et l'élément <mpath>...
<svg width="300" height="200" viewBox="0 0 300 200"> <title>Motion Along a Complex Path Using mpath</title> <path id="cubicCurve" d="M50,125 C 100,25 150,225, 200, 125" style="fill: none; stroke: blue;"/> <path d="M-10,-3 L10,-3 L0,-25z" style="fill: yellow; stroke: red;" > <animateMotion dur="6s" rotate="auto" fill="freeze" repeatCount="indefinite"> <mpath xlink:href="#cubicCurve"/> </animateMotion> </path> </svg> |
<svg width="300" height="200" viewBox="0 0 300 200"> <title>Example of animateColor</title> <circle cx="60" cy="60" r="30" style="fill: #ff9; stroke: gray; stroke-width:10;"> <animateColor attributeName="fill" begin="2s" dur="4s" from="#ff9" to="red" fill="freeze" repeatCount="indefinite"/> <animateColor attributeName="stroke" begin="2s" dur="4s" from="gray" to="blue" fill="freeze" repeatCount="indefinite"/> </circle> </svg> |
<svg width="300" height="200" viewBox="0 0 300 200"> <title>Example of Multiple animateTransform elements</title> <g transform="translate(120,60)"> <rect x="-10" y="-10" width="20" height="20" style="fill: #ff9; stroke: black;"> <animateTransform attributeName="transform" attributeType="XML" type="scale" from="1" to="4 2" additive="sum" begin="0s" dur="4s" fill="freeze" repeatCount="indefinite"/> <animateTransform attributeName="transform" attributeType="XML" type="rotate" from="0" to="45" additive="sum" begin="0s" dur="4s" fill="freeze" repeatCount="indefinite"/> </rect> </g> </svg> |
noter: additive="sum"...pour que les transformations s'additionnent.
Comment se réalise l'animation dans le temps ?
Ou encore : quels sont les attributs qui définissent les valeur d'animation au cours du temps ?
http://www.yoyodesign.org/doc/w3c/svg1/animate.html#ValueAttributes
http://www.w3.org/2002/Talks/0328-Amsterdam-IH/SVGAnimationHowslide.svgz
Comment synchroniser des animations ?
Voir :
http://www.w3.org/2002/Talks/0328-Amsterdam-IH/syncslide.svgz
Exemple:
<svg width="250" height="200" viewBox="0 0 250 200"> <title>Synchronization of Animations</title> <circle cx="60" cy="60" r="30" style="fill: #f9f; stroke: gray;"> <animate id="c1" attributeName="r" attributeType="XML" begin="0s" dur="4s" from="30" to="10" fill="freeze" repeatCount="indefinite"/> </circle> <circle cx="120" cy="60" r="10" style="fill: #9f9; stroke: gray;"> <animate attributeName="r" attributeType="XML" begin="c1.end" dur="4s" from="10" to="30" fill="freeze" repeatCount="indefinite"/> </circle> </svg> |