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 11/04 - 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,c=0,d=20;
22:
23:
24: function getSVGDoc(load_evt)
25: {
26: svgdoc=load_evt.target.ownerDocument;
27: }
28:
29:
30: function Beschleunigen(repeat_evt)
31: {
32: c++;
33:
34: d=parseFloat(repeat_evt.target.getAttribute('dur'))/2;
35: repeat_evt.target.setAttribute('dur',d);
36:
37: svgdoc.getElementById('counter').firstChild.data=c;
38: svgdoc.getElementById('duration').firstChild.data=d;
39: }
40:
41: ]]>
42: </script>
43:
44: </defs>
45:
46: <text x="20" y="30" style="fill: #000; font-size: 24px">
47: Rotierende Linie mit Beschleunigung</text>
48:
49: <!-- Linie mit animierter Transformation -->
50: <line x1="180" y1="100" x2="280" y2="200" style="stroke: #F00">
51:
52: <animateTransform attributeName="transform" attributeType="XML"
53: type="rotate" from="0,230,150" to="360,230,150" begin="0s" dur="20s"
54: repeatDur="indefinite" fill="freeze" onrepeat="Beschleunigen(evt)"/>
55:
56: </line>
57:
58: <!-- Markierung des Drehpunktes und des Außenkreises -->
59: <circle cx="230" cy="150" r="1.5" style="fill: #00C"/>
60: <circle cx="230" cy="150" r="70.71" style="fill: none; stroke: #CCC"/>
61:
62: <!-- Textbereich zur Ausgabe der Umdrehungen und des aktuellen dur-Wertes -->
63: <text x="20" y="60" style="fill: #000">
64: Umdrehungen: <tspan id="counter" style="fill: #00C">0</tspan> |
65: dur = <tspan id="duration" style="fill: #00C">20</tspan> s
66: (Wert wird nach jedem Durchlauf halbiert)</text>
67:
68: </svg>
[zum Anfang]