SVG – Learning by Coding
1:
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
2:
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
3:
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd" [
4:
<!ATTLIST svg xmlns:xlink CDATA #FIXED "http://www.w3.org/1999/xlink">
5:
]>
6: 7:
<!-- SVG - Learning by Coding - http://www.datenverdrahten.de/svglbc/ -->
8:
<!-- Author: Dr. Thomas Meinike 03/03 - thomas@handmadecode.de -->
9: 10:
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
11:
onload="getSVGDoc(evt)">
12: 13:
<title>SVG - Learning by Coding</title>
14:
<desc>SVG-Spezifikation in Beispielen</desc>
15: 16:
<defs>
17: 18:
<script type="text/javascript">
19:
<![CDATA[
20: 21:
var svgdoc,svgroot;
22: 23: 24:
function getSVGDoc(load_evt)
25:
{
26:
svgdoc=load_evt.target.ownerDocument;
27:
svgroot=svgdoc.documentElement;
28:
}
29: 30: 31:
function Pause()
32:
{
33:
svgroot.pauseAnimations();
34:
}
35: 36: 37:
function Weiter()
38:
{
39:
svgroot.unpauseAnimations();
40:
}
41: 42: 43:
function PauseTest()
44:
{
45:
if(svgroot.animationsPaused())
46:
alert("Animationen wurden unterbrochen.");
47:
else alert("Animationen laufen noch.");
48:
}
49: 50:
]]>
51:
</script>
52: 53:
</defs>
54: 55:
<text x="20" y="30" style="fill: #000; font-size: 24px">
56:
Animationen unterbrechen</text>
57: 58:
<!-- Animationen wie im Beispiel animateMotion.svg -->
59: 60:
<path d="M 100,100 L 300,50 A 100,100 0 0,1 300,200 Z"
61:
style="fill: none; stroke: #CCC; stroke-width: 1px"/>
62:
<path id="einpfad" d="M 100,250 L 300,250 L 300,350 L 100,350 Z"
63:
style="fill: none; stroke: #CCC; stroke-width: 1px"/>
64: 65:
<!-- ohne mpath -->
66:
<circle cx="0" cy="0" r="5" style="fill: #F00">
67:
<animateMotion begin="0s" dur="5s" repeatDur="indefinite"
68:
path="M 100,100 L 300,50 A 100,100 0 0,1 300,200 Z"/>
69:
</circle>
70: 71:
<!-- mit mpath -->
72:
<rect x="-5" y="-5" width="11" height="11" style="fill: #00C">
73:
<animateMotion begin="0s" dur="10s" repeatDur="indefinite">
74:
<mpath xlink:href="#einpfad"/>
75:
</animateMotion>
76:
</rect>
77: 78:
<!-- Funktionen Pause() bzw. Weiter() aufrufen -->
79: 80:
<a xlink:href="" cursor="pointer" onclick="return false">
81:
<text x="100" y="400" style="fill: #F00" onclick="Pause()">Pause</text>
82:
</a>
83: 84:
<a xlink:href="" cursor="pointer" onclick="return false">
85:
<text x="200" y="400" style="fill: #00C" onclick="Weiter()">Weiter</text>
86:
</a>
87: 88:
<a xlink:href="" cursor="pointer" onclick="return false">
89:
<text x="300" y="400" style="fill: #090" onclick="PauseTest()">Test</text>
90:
</a>
91: 92:
</svg>
[zum Anfang]