mozilla

Revision 95104 of animateMotion

  • Revision slug: SVG/Element/animateMotion
  • Revision title: animateMotion
  • Revision id: 95104
  • Created:
  • Creator: Jeremie
  • Is current revision? No
  • Comment page created, 253 words added

Revision Content

{{ SVGRefElem() }}

The animateMotion element causes a referenced element to move along a motion path.

Usage context

Categories Animation element
Normative document SVG 1.1 (2nd Edition)

Example

<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" 
  "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="5cm" height="3cm"  viewBox="0 0 500 300"
     xmlns="http://www.w3.org/2000/svg" version="1.1"
     xmlns:xlink="http://www.w3.org/1999/xlink" >

  <rect x="1" y="1" width="498" height="298"
        fill="none" stroke="blue" stroke-width="2" />

  <!-- Draw the outline of the motion path in blue, along
          with three small circles at the start, middle and end. -->
  <path id="path1" d="M100,250 C 100,50 400,50 400,250"
        fill="none" stroke="blue" stroke-width="7.06"  />
  <circle cx="100" cy="250" r="17.64" fill="blue"  />
  <circle cx="250" cy="100" r="17.64" fill="blue"  />
  <circle cx="400" cy="250" r="17.64" fill="blue"  />

  <!-- Here is a triangle which will be moved about 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-25,-12.5 L25,-12.5 L 0,-87.5 z"
        fill="yellow" stroke="red" stroke-width="7.06"  >

    <!-- Define the motion path animation -->
    <animateMotion dur="6s" repeatCount="indefinite" rotate="auto" >
       <mpath xlink:href="#path1"/>
    </animateMotion>
  </path>
</svg>

Attributes

{{ SVGGraphicsElementEventAttr() }} {{ SVGLangSpaceAttrs() }} {{ SVGStndAttr() }}

{{ SVGAttr("calcMode") }}
{{ SVGAttr("path") }}
{{ SVGAttr("keyPoints") }}
{{ SVGAttr("rotate") }}
{{ SVGAttr("origin") }}

DOM Interface

This element implements the SVGAnimateMotionElement interface.

Related

  • {{ SVGElement("mpath") }}

Revision Source

<p>{{ SVGRefElem() }}</p>
<p>The <code>animateMotion</code> element causes a referenced element to move along a motion path.</p>
<h2>Usage context</h2>
<table class="standard-table"> <tbody> <tr> <td>Categories</td> <td>Animation element</td> </tr> <tr> <td>Normative document</td> <td><a class="external" href="http://www.w3.org/TR/SVG/animate.html#AnimateMotionElement" title="http://www.w3.org/TR/SVG/animate.html#AnimateMotionElement">SVG 1.1 (2nd Edition)</a></td> </tr> </tbody>
</table>
<h2>Example</h2>
<pre>&lt;?xml version="1.0" standalone="no"?&gt;
&lt;!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" 
  "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"&gt;
&lt;svg width="5cm" height="3cm"  viewBox="0 0 500 300"
     xmlns="http://www.w3.org/2000/svg" version="1.1"
     xmlns:xlink="http://www.w3.org/1999/xlink" &gt;

  &lt;rect x="1" y="1" width="498" height="298"
        fill="none" stroke="blue" stroke-width="2" /&gt;

  &lt;!-- Draw the outline of the motion path in blue, along
          with three small circles at the start, middle and end. --&gt;
  &lt;path id="path1" d="M100,250 C 100,50 400,50 400,250"
        fill="none" stroke="blue" stroke-width="7.06"  /&gt;
  &lt;circle cx="100" cy="250" r="17.64" fill="blue"  /&gt;
  &lt;circle cx="250" cy="100" r="17.64" fill="blue"  /&gt;
  &lt;circle cx="400" cy="250" r="17.64" fill="blue"  /&gt;

  &lt;!-- Here is a triangle which will be moved about the motion path.
       It is defined with an upright orientation with the base of
       the triangle centered horizontally just above the origin. --&gt;
  &lt;path d="M-25,-12.5 L25,-12.5 L 0,-87.5 z"
        fill="yellow" stroke="red" stroke-width="7.06"  &gt;

    &lt;!-- Define the motion path animation --&gt;
    &lt;animateMotion dur="6s" repeatCount="indefinite" rotate="auto" &gt;
       &lt;mpath xlink:href="#path1"/&gt;
    &lt;/animateMotion&gt;
  &lt;/path&gt;
&lt;/svg&gt;
</pre>
<h2>Attributes</h2>
<p>{{ SVGGraphicsElementEventAttr() }} {{ SVGLangSpaceAttrs() }} {{ SVGStndAttr() }}</p>
<div>{{ SVGAttr("calcMode") }}</div>
<div>{{ SVGAttr("path") }}</div>
<div>{{ SVGAttr("keyPoints") }}</div>
<div>{{ SVGAttr("rotate") }}</div>
<div>{{ SVGAttr("origin") }}</div>
<h2>DOM Interface</h2>
<p>This element implements the <code><a href="/en/DOM/SVGAnimateMotionElement" title="en/DOM/SVGAnimateMotionElement">SVGAnimateMotionElement</a></code> interface.</p>
<h2>Related</h2>
<ul> <li>{{ SVGElement("mpath") }}</li>
</ul>
Revert to this revision