1 function BouncingCanvasParticle(stage)
3 BouncingParticle.call(this, stage);
4 this._context = stage.context;
6 this._clip = stage.clip;
9 BouncingCanvasParticle.clips = {
11 new Point(0.50, 0.00),
12 new Point(0.38, 0.38),
13 new Point(0.00, 0.38),
14 new Point(0.30, 0.60),
15 new Point(0.18, 1.00),
16 new Point(0.50, 0.75),
17 new Point(0.82, 1.00),
18 new Point(0.70, 0.60),
19 new Point(1.00, 0.38),
24 BouncingCanvasParticle.prototype = Object.create(BouncingParticle.prototype);
25 BouncingCanvasParticle.prototype.constructor = BouncingCanvasParticle;
27 BouncingCanvasParticle.prototype._applyRotation = function()
29 if (this._shape == "circle")
32 this._context.translate(this._size.x / 2, this._size.y / 2);
33 this._context.rotate(this._rotater.degree() * Math.PI / 180);
34 this._context.translate(-this._size.x / 2, -this._size.y / 2);
37 BouncingCanvasParticle.prototype._applyClipping = function()
39 var clipPoints = BouncingCanvasParticle.clips[this._clip];
43 this._context.beginPath();
44 clipPoints.forEach(function(point, index) {
45 var point = this._size.multiply(point);
47 this._context.moveTo(point.x, point.y);
49 this._context.lineTo(point.x, point.y);
52 this._context.closePath();
56 BouncingCanvasParticle.prototype._draw = function()
58 throw "Not implemented";
61 BouncingCanvasParticle.prototype.animate = function(timeDelta)
63 BouncingParticle.prototype.animate.call(this, timeDelta);
65 this._context.translate(this._position.x, this._position.y);
67 this._context.restore();
70 function BouncingCanvasParticlesStage(element, options)
72 BouncingParticlesStage.call(this, element, options);
73 this.context = this.element.getContext("2d");
76 BouncingCanvasParticlesStage.prototype = Object.create(BouncingParticlesStage.prototype);
77 BouncingCanvasParticlesStage.prototype.constructor = BouncingCanvasParticlesStage;
79 function BouncingCanvasParticlesAnimator(benchmark)
81 BouncingParticlesAnimator.call(this, benchmark);
82 this._context = benchmark._stage.context;
85 BouncingCanvasParticlesAnimator.prototype = Object.create(BouncingParticlesAnimator.prototype);
86 BouncingCanvasParticlesAnimator.prototype.constructor = BouncingCanvasParticlesAnimator;
88 BouncingCanvasParticlesAnimator.prototype.animate = function()
90 this._context.clearRect(0, 0, this._benchmark._stage.size.x, this._benchmark._stage.size.y);
91 return BouncingParticlesAnimator.prototype.animate.call(this);
94 function BouncingCanvasParticlesBenchmark(suite, test, options, recordTable, progressBar)
96 StageBenchmark.call(this, suite, test, options, recordTable, progressBar);
99 BouncingCanvasParticlesBenchmark.prototype = Object.create(StageBenchmark.prototype);
100 BouncingCanvasParticlesBenchmark.prototype.constructor = BouncingCanvasParticlesBenchmark;
102 BouncingCanvasParticlesBenchmark.prototype.createAnimator = function()
104 return new BouncingCanvasParticlesAnimator(this);