forked from Ermentrout/xppaut
-
Notifications
You must be signed in to change notification settings - Fork 1
/
animsvgwww
executable file
·107 lines (97 loc) · 2.78 KB
/
animsvgwww
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/sh
#Create a flipbook animation of several svg files.
#Example: animsvgwww `ls frame*.svg | numericsort 2` > myanim.html
#
#Animates a sequence of svg files using Javascript and HTML.
echo "<html>"
echo "<head>"
echo " <title>SVG+JavaScript Slideshow</title>"
echo ""
echo "</head>"
echo "<body>"
echo ""
echo "<center><img src=\"$1\" alt=\"rotating image\" width=\"400\" height=\"300\" id=\"flipbookimage\">"
echo "<br>"
echo "<button id=\"slowerButton\">Slower</button>"
echo "<button id=\"stopButton\">Stop</button>"
echo "<button id=\"fasterButton\">Faster</button>"
echo "<button id=\"forwardOneButton\">Fwd</button>"
echo "<button id=\"backwardOneButton\">Bwd</button>"
echo "</center>"
echo ""
echo "<script type=\"text/javascript\">"
echo "(function() {"
echo " var rotator = document.getElementById('flipbookimage');"
echo " var imageDir = './';"
echo " var delayInSeconds = 0.1;"
echo " var num = 0;"
echo ""
echo " var images = ["
for fn in $*; do
if [ "$fn" != "$1" ];then
echo " '$fn',"
fi
done
echo " '$1'];"
echo ""
echo " var incrementImage = function() {"
echo " var len = images.length;"
echo " num++;"
echo " if (num == len) {"
echo " num = 0;"
echo " }"
echo " rotator.src = imageDir + images[num];"
echo ""
echo " };"
echo ""
echo " var decrementImage = function() {"
echo " var len = images.length;"
echo " num--;"
echo " if (num == -1) {"
echo " num = len-1;"
echo " }"
echo " rotator.src = imageDir + images[num];"
echo ""
echo " };"
echo " "
echo " var stopImage = setInterval(incrementImage, delayInSeconds * 1000);"
echo ""
echo " slowerButton.onclick = function()"
echo " {"
echo " clearInterval(stopImage);"
echo " delayInSeconds*=2.0;"
echo " stopImage = setInterval(incrementImage, delayInSeconds * 1000);"
echo " };"
echo ""
echo " stopButton.onclick = function()"
echo " {"
echo " clearInterval(stopImage);"
echo " };"
echo ""
echo " fasterButton.onclick = function()"
echo " {"
echo " clearInterval(stopImage);"
echo " delayInSeconds*=0.5;"
echo " stopImage = setInterval(incrementImage, delayInSeconds * 1000);"
echo " };"
echo ""
echo " forwardOneButton.onclick = function()"
echo " {"
echo " clearInterval(stopImage);"
echo " incrementImage();"
echo " };"
echo ""
echo " backwardOneButton.onclick = function()"
echo " {"
echo " clearInterval(stopImage);"
echo " decrementImage();"
echo " };"
echo ""
echo ""
echo " })();"
echo ""
echo "</script>"
echo ""
echo "</body>"
echo "</html>"
echo ""