1 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
5 <script type=
"text/javascript" src=
"script/util.js"></script>
6 <script type=
"text/javascript" src=
"script/canvas.js"></script>
7 <link rel=
"stylesheet" type=
"text/css" href=
"style/common.css" />
8 <style type=
"text/css">
16 <div id=
"target"></div>
17 <script type=
"text/javascript">
18 var canvas
= document
.createElement('canvas');
19 canvas
.setAttribute('width', '800px');
20 canvas
.setAttribute('height', '500px');
21 var ctx
= canvas
.getContext('2d');
22 document
.getElementById('target').appendChild(canvas
);
24 Function
.prototype.animate = function(timems
)
29 var n
= timems
/fraction
;
30 var step
= 1/n
, x
= 0;
32 // linear easing (more to come)
40 window
.setTimeout(fn
, seq
[i
] * timems
, seq
[i
]);
43 var x
, y
, r
, mx
= 800, my
= 500, n
= 500;
45 function setCircle() {
46 x
= Math
.random() * mx
;
47 y
= Math
.random() * my
;
48 r
= 40 + Math
.random() * 20;
49 ctx
.fillStyle
= '#d7d7d7';
52 function drawCircle(n
)
54 ctx
.fillCircle(x
, y
, n
* r
);
57 function resetCircle() {
58 ctx
.fillStyle
= '#262626';
59 nx
= x
- 20 + Math
.random() * 41;
60 ny
= y
- 20 + Math
.random() * 41;
61 r
+= 1.1 * Math
.sqrt((x
-nx
)*(x
-nx
) + (y
-ny
)*(y
-ny
));
64 drawCircle
.animate(n
);
69 var t
= n
* ( .8 + Math
.random() * .45);
70 drawCircle
.animate(t
);
71 window
.setTimeout(function(){
74 drawCircle
.animate(t2
);
75 window
.setTimeout(doit
, t2
);