Ik heb net zitten stoeiten met VML en javascript en heb de eeuwenoude lissajous-figuren weer eens geprogrammeerd:
(het werkt alleen in IE5 en hoger)
Wat vinden jullie ervan?
(het werkt alleen in IE5 en hoger)
code:
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
| <html>
<head>
<xml:namespace ns="urn:schemas-microsoft-com:vml" prefix="v"/>
<style>
v\:* { behavior:url(#default#VML);}
</style>
<title></title>
<script>
function createLineWithDOM(p, color, width, fx, fy, tx, ty) {
var l, d, i;
l = document.createElement("v:line");
l.strokeweight = width+"pt";
l.strokecolor = color;
l.from = fx + "px, " + fy + "px";
l.to = tx + "px, " + ty + "px";
p.insertBefore(l, null);
return l;
}
var maxlines = 10;
var a = new Array(maxlines);
var r = 0;
for(i=0;i<maxlines;i++)
a[i] = null;
var idx=0;
function fun() {
r+=0.01;
x1 = 300 + Math.sin(r*3) * 300;
y1 = 300 + Math.cos(r*5) * 300;
x2 = 300 + Math.sin(r*7) * 300;
y2 = 300 + Math.cos(r*11) * 300;
if (idx==maxlines) idx=0;
if (a[idx]==null) {
a[idx]=createLineWithDOM(canvas,"black",1,x1,y1,x2,y2);
} else {
a[idx].from = x1 + "px, " + y1 + "px";
a[idx].to = x2 + "px, " + y2 + "px";
}
idx++;
window.setTimeout(fun,2);
}
</script>
</head>
<body onload="fun()">
<div id=canvas width=600 height=600>
</div>
</body>
</html> |
Wat vinden jullie ervan?