1
|
<svg width="100%" height="100%" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" onload="Init(evt)">
|
2
|
<title>Animated Values Test</title>
|
3
|
|
4
|
<desc>
|
5
|
Click on a shape, and the other shape will move to its animated value.
|
6
|
Written by Doug Schepers [doug@schepers.cc], January 2004.
|
7
|
</desc>
|
8
|
|
9
|
|
10
|
<script><![CDATA[
|
11
|
var SVGDocument = null;
|
12
|
var SVGRoot = null;
|
13
|
var planetPeru = null;
|
14
|
var planetCornflowerblue = null;
|
15
|
var planetTomato = null;
|
16
|
var planetBurlywood = null;
|
17
|
var flightPath = null;
|
18
|
|
19
|
function Init(evt)
|
20
|
{
|
21
|
SVGDocument = evt.target.ownerDocument;
|
22
|
SVGRoot = SVGDocument.documentElement;
|
23
|
|
24
|
planetPeru = SVGDocument.getElementById('planetPeru');
|
25
|
planetCornflowerblue = SVGDocument.getElementById('planetCornflowerblue');
|
26
|
planetTomato = SVGDocument.getElementById('planetTomato');
|
27
|
planetBurlywood = SVGDocument.getElementById('planetBurlywood');
|
28
|
flightPath = SVGDocument.getElementById('flightPath');
|
29
|
|
30
|
//window.setTimeout('SetEndpoint()', 20)
|
31
|
|
32
|
}
|
33
|
|
34
|
function SetEndpoint(evt)
|
35
|
{
|
36
|
var matrixPeru = planetPeru.getCTM();
|
37
|
var matrixCornflowerblue = planetCornflowerblue.getCTM();
|
38
|
var matrixTomato = planetTomato.getCTM();
|
39
|
var matrixBurlywood = planetBurlywood.getCTM();
|
40
|
|
41
|
var newPoints = matrixPeru.e + ',' + matrixPeru.f
|
42
|
newPoints += ' ' + matrixCornflowerblue.e + ',' + matrixCornflowerblue.f;
|
43
|
newPoints += ' ' + matrixTomato.e + ',' + matrixTomato.f;
|
44
|
newPoints += ' ' + matrixBurlywood.e + ',' + matrixBurlywood.f;
|
45
|
|
46
|
flightPath.setAttributeNS(null, 'points', newPoints);
|
47
|
|
48
|
window.setTimeout('SetEndpoint()', 20);
|
49
|
}
|
50
|
|
51
|
]]></script>
|
52
|
<defs>
|
53
|
<radialGradient id="gradientGhostwhite" cx="48%" cy="30%" fx="54%" fy="32%" r="74%" gradientUnits="objectBoundingBox" spreadMethod="pad">
|
54
|
<stop id="radial0-Stop1" offset="0%" style="stop-color:ghostwhite; stop-opacity:0.3;"/>
|
55
|
<stop id="radial0-Stop2" offset="100%" style="stop-color:black; stop-opacity:0;"/>
|
56
|
</radialGradient>
|
57
|
</defs>
|
58
|
|
59
|
<rect x="0" y="0" width="100%" height="100%" style="fill:black; "/>
|
60
|
<path id="nebulaGhostwhite" fill="url(#gradientGhostwhite)" d="M720,0 H520 C450,490 275,350 220,330 S210,440 475,500 S524,600 875,690 S798,432 720,0"/>
|
61
|
|
62
|
<circle id="sunGold" cx="250" cy="250" r="10" fill="gold"/>
|
63
|
|
64
|
<path id="orbitPeru" d="M250,283 A33,33 0 1 1 251,283 z" fill="none" stroke="peru"/>
|
65
|
<path id="orbitCornflowerblue" d="M250,320 A80,70 20 1 1 251,320 z" fill="none" stroke="cornflowerblue"/>
|
66
|
<path id="orbitTomato" d="M250,350 A100,120 0 1 1 251,350 z" fill="none" stroke="tomato"/>
|
67
|
<path id="orbitBurlywood" d="M230,380 A130,150 50 1 1 231,380 z" fill="none" stroke="burlywood"/>
|
68
|
|
69
|
|
70
|
<!--<polyline id="flightPath" points="278.65179443359375,267.1402893066406 287.6238098144531,311.1416015625 341.5194396972656,279.6657409667969 258.54888916015625,103.27886962890625" style="stroke:green; fill:none; "/>
|
71
|
-->
|
72
|
<circle id="planetPeru" cx="0" cy="0" r="3" fill="peru" onclick="SetEndpoint(evt)">
|
73
|
<animateMotion dur="12s" repeatCount="indefinite" rotate="auto">
|
74
|
<mpath xlink:href="#orbitPeru"/>
|
75
|
</animateMotion>
|
76
|
</circle>
|
77
|
|
78
|
<circle id="planetCornflowerblue" cx="0" cy="0" r="6" fill="cornflowerblue">
|
79
|
<animateMotion dur="24s" repeatCount="indefinite" rotate="auto">
|
80
|
<mpath xlink:href="#orbitCornflowerblue"/>
|
81
|
</animateMotion>
|
82
|
</circle>
|
83
|
|
84
|
<circle id="planetTomato" cx="0" cy="0" r="8" fill="tomato" onclick="SetEndpoint(evt)">
|
85
|
<animateMotion dur="45s" repeatCount="indefinite" rotate="auto">
|
86
|
<mpath xlink:href="#orbitTomato"/>
|
87
|
</animateMotion>
|
88
|
</circle>
|
89
|
|
90
|
<circle id="planetBurlywood" cx="0" cy="0" r="5" fill="burlywood" onclick="SetEndpoint(evt)">
|
91
|
<animateMotion dur="5s" repeatCount="indefinite" rotate="auto">
|
92
|
<mpath xlink:href="#orbitBurlywood"/>
|
93
|
</animateMotion>
|
94
|
</circle>
|
95
|
|
96
|
</svg>
|