1 function Rotater(rotateInterval)
4 this._rotateInterval = rotateInterval;
11 return this._rotateInterval;
14 next: function(timeDelta)
16 this._timeDelta = (this._timeDelta + timeDelta) % this._rotateInterval;
21 return (360 * this._timeDelta) / this._rotateInterval;
26 return "rotateZ(" + Math.floor(this.degree()) + "deg)";
29 rotate: function(center)
31 return "rotate(" + Math.floor(this.degree()) + ", " + center.x + "," + center.y + ")";
35 function Stage(element, options)
37 this.element = element;
38 this._size = Point.elementClientSize(element).subtract(Insets.elementPadding(element).size);
48 random: function(min, max)
50 return (Math.random() * (max - min)) + min;
53 randomBool: function()
55 return !!Math.round(this.random(0, 1));
58 randomInt: function(min, max)
60 return Math.round(this.random(min, max));
63 randomPosition: function(maxPosition)
65 return new Point(this.randomInt(0, maxPosition.x), this.randomInt(0, maxPosition.y));
68 randomSquareSize: function(min, max)
70 var side = this.random(min, max);
71 return new Point(side, side);
74 randomVelocity: function(maxVelocity)
76 return this.random(maxVelocity / 8, maxVelocity);
79 randomAngle: function()
81 return this.random(0, Math.PI * 2);
84 randomColor: function()
89 + this.randomInt(min, max).toString(16)
90 + this.randomInt(min, max).toString(16)
91 + this.randomInt(min, max).toString(16);
94 randomRotater: function()
96 return new Rotater(this.random(1000, 10000));
101 throw "Not implemented";
106 throw "Not implemented";
111 return this.tune(-this.tune(0));
115 function StageAnimator(benchmark, options)
117 Animator.call(this, benchmark, options);
120 StageAnimator.prototype = Object.create(Animator.prototype);
121 StageAnimator.prototype.constructor = StageAnimator;
123 StageAnimator.prototype.animate = function()
125 if (!Animator.prototype.animate.call(this))
127 this._benchmark._stage.animate(this.timeDelta());
131 function StageBenchmark(suite, test, options, recordTable, progressBar)
133 Benchmark.call(this, options);
135 var element = document.getElementById("stage");
136 element.setAttribute("width", document.body.offsetWidth);
137 element.setAttribute("height", document.body.offsetHeight);
139 this._stage = this.createStage(element);
140 this._animator = this.createAnimator();
143 this._recordTable = recordTable;
144 this._progressBar = progressBar;
147 StageBenchmark.prototype = Object.create(Benchmark.prototype);
148 StageBenchmark.prototype.constructor = StageBenchmark;
150 StageBenchmark.prototype.createStage = function(element)
152 return new Stage(element, this._options);
155 StageBenchmark.prototype.createAnimator = function()
157 return new StageAnimator(this, this._options);
160 StageBenchmark.prototype.tune = function(count)
162 return this._stage.tune(count);
165 StageBenchmark.prototype.clear = function()
167 return this._stage.clear();
170 StageBenchmark.prototype.showResults = function(message, progress)
172 if (!this._recordTable || !this._progressBar || !this._test)
175 if (this._options["show-running-results"])
176 this._recordTable.showRecord(this._test.name, message, this._sampler.toJSON(true, false), this._options);
178 this._progressBar.setPos(progress);