1 BouncingCanvasParticle = Utilities.createSubclass(BouncingParticle,
4 BouncingParticle.call(this, stage);
5 this.context = stage.context;
7 this._clip = stage.clip;
10 applyRotation: function()
12 if (this._shape == "circle")
15 this.context.translate(this.size.x / 2, this.size.y / 2);
16 this.context.rotate(this.rotater.degree() * Math.PI / 180);
17 this.context.translate(-this.size.x / 2, -this.size.y / 2);
20 applyClipping: function()
22 var clipPoints = BouncingCanvasParticle.clips[this._clip];
26 this.context.beginPath();
27 clipPoints.forEach(function(point, index) {
28 var point = this.size.multiply(point);
30 this.context.moveTo(point.x, point.y);
32 this.context.lineTo(point.x, point.y);
35 this.context.closePath();
41 throw "Not implemented";
44 animate: function(timeDelta)
46 BouncingParticle.prototype.animate.call(this, timeDelta);
48 this.context.translate(this.position.x, this.position.y);
50 this.context.restore();
54 BouncingCanvasParticle.clips = {
56 new Point(0.50, 0.00),
57 new Point(0.38, 0.38),
58 new Point(0.00, 0.38),
59 new Point(0.30, 0.60),
60 new Point(0.18, 1.00),
61 new Point(0.50, 0.75),
62 new Point(0.82, 1.00),
63 new Point(0.70, 0.60),
64 new Point(1.00, 0.38),
69 BouncingCanvasParticlesStage = Utilities.createSubclass(BouncingParticlesStage,
72 BouncingParticlesStage.call(this);
75 initialize: function(benchmark, options)
77 BouncingParticlesStage.prototype.initialize.call(this, benchmark, options);
78 this.context = this.element.getContext("2d");
81 animate: function(timeDelta)
83 this.context.clearRect(0, 0, this.size.x, this.size.y);
84 this.particles.forEach(function(particle) {
85 particle.animate(timeDelta);