-
Notifications
You must be signed in to change notification settings - Fork 1
/
Canvas_03.html
76 lines (61 loc) · 2.01 KB
/
Canvas_03.html
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
<!DOCTYPE html>
<html>
<head>
<title>Canvas 03</title>
<link rel="stylesheet" href="css/styles.css" type="text/css" media="all" />
<script src="js/CanvasController.js" type="text/javascript"></script>
<script src="js/DisplayObject.js" type="text/javascript"></script>
<script src="js/DisplayContainer.js" type="text/javascript"></script>
<script src="js/Shape.js" type="text/javascript"></script>
<script src="js/Circle.js" type="text/javascript"></script>
<script src="js/Orb.js" type="text/javascript"></script>
<script src="js/Ticker.js" type="text/javascript"></script>
<script src="js/ColorPool.js" type="text/javascript"></script>
<script src="js/ObjectPool.js" type="text/javascript"></script>
<script>
var canvasController = null;
var colorPool = new ColorPool( "#990000", "#CC0000", "#333333", "#666666", "#999999" );
var objectPool = new ObjectPool( Orb, 1000 );
var orbs = new Array();
function init()
{
objectPool.onCreateObject = onCreateObject;
canvasController = new CanvasController( document.getElementById( "canvas" ) );
objectPool.requestAll();
canvasController.capture = true;
canvasController.update();
Ticker.add( update );
Ticker.start();
}
function onCreateObject( orb )
{
orb.x = Math.random() * 800;
orb.y = Math.random() * 500;
orb.alpha = Math.random() * 0.5 + 0.5;
orb.color = colorPool.getColor();
orbs.push( orb );
canvasController.addChild( orb );
}
function update()
{
for( var i = 0; i < orbs.length; i++ )
{
orbs[i].x += (Math.random() * 4) - 2;
orbs[i].y += (Math.random() * 4) - 2;
}
canvasController.update();
}
</script>
</head>
<body onload="init();">
<canvas id="canvas" width="800" height="500">
This demo uses HTML5 features, please upgrade to a modern browser that supports HTML5.
</canvas>
<p>
<a href="http://markstar.co.uk/?p=414">View the blog post about this demo</a>
</p>
<p>
<a href="Canvas_02.html">View previous demo</a> | <a href="Canvas_04.html">View next demo</a>
</p>
</body>
</html>