diff --git a/MotionMark/developer.html b/MotionMark/developer.html index 3783708..7a0cfa9 100644 --- a/MotionMark/developer.html +++ b/MotionMark/developer.html @@ -33,6 +33,7 @@ + diff --git a/MotionMark/index.html b/MotionMark/index.html index 925a5f1..52cbe8d 100644 --- a/MotionMark/index.html +++ b/MotionMark/index.html @@ -32,6 +32,7 @@ + diff --git a/MotionMark/resources/statistics.js b/MotionMark/resources/statistics.js index b306f2d..5bf4371 100644 --- a/MotionMark/resources/statistics.js +++ b/MotionMark/resources/statistics.js @@ -22,29 +22,6 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ -Pseudo = -{ - initialRandomSeed: 49734321, - randomSeed: 49734321, - - resetRandomSeed: function() - { - Pseudo.randomSeed = Pseudo.initialRandomSeed; - }, - - random: function() - { - var randomSeed = Pseudo.randomSeed; - randomSeed = ((randomSeed + 0x7ed55d16) + (randomSeed << 12)) & 0xffffffff; - randomSeed = ((randomSeed ^ 0xc761c23c) ^ (randomSeed >>> 19)) & 0xffffffff; - randomSeed = ((randomSeed + 0x165667b1) + (randomSeed << 5)) & 0xffffffff; - randomSeed = ((randomSeed + 0xd3a2646c) ^ (randomSeed << 9)) & 0xffffffff; - randomSeed = ((randomSeed + 0xfd7046c5) + (randomSeed << 3)) & 0xffffffff; - randomSeed = ((randomSeed ^ 0xb55a4f09) ^ (randomSeed >>> 16)) & 0xffffffff; - Pseudo.randomSeed = randomSeed; - return (randomSeed & 0xfffffff) / 0x10000000; - } -}; Statistics = { diff --git a/MotionMark/tests/3d/resources/webgl.js b/MotionMark/tests/3d/resources/webgl.js index 33dc0fe..87cd5e4 100644 --- a/MotionMark/tests/3d/resources/webgl.js +++ b/MotionMark/tests/3d/resources/webgl.js @@ -136,12 +136,12 @@ WebGLStage = Utilities.createSubclass(Stage, this._uniformData = new Float32Array(this._bufferSize * 6); for (var i = 0; i < this._bufferSize; ++i) { - this._uniformData[i * 6 + 0] = Stage.random(0.2, 0.4); + this._uniformData[i * 6 + 0] = Random.number(0.2, 0.4); this._uniformData[i * 6 + 1] = 0; - this._uniformData[i * 6 + 2] = Stage.random(-0.9, 0.9); - this._uniformData[i * 6 + 3] = Stage.random(-0.9, 0.9); - this._uniformData[i * 6 + 4] = Stage.random(0.5, 2); - this._uniformData[i * 6 + 5] = Stage.random(0, 10); + this._uniformData[i * 6 + 2] = Random.number(-0.9, 0.9); + this._uniformData[i * 6 + 3] = Random.number(-0.9, 0.9); + this._uniformData[i * 6 + 4] = Random.number(0.5, 2); + this._uniformData[i * 6 + 5] = Random.number(0, 10); } }, @@ -163,8 +163,8 @@ WebGLStage = Utilities.createSubclass(Stage, gl.clear(gl.COLOR_BUFFER_BIT); if (!this._startTime) - this._startTime = Stage.dateCounterValue(1000); - var elapsedTime = Stage.dateCounterValue(1000) - this._startTime; + this._startTime = Random.dateCounterValue(1000); + var elapsedTime = Random.dateCounterValue(1000) - this._startTime; for (var i = 0; i < this._numTriangles; ++i) { diff --git a/MotionMark/tests/3d/resources/webgpu.js b/MotionMark/tests/3d/resources/webgpu.js index f848d1c..0a9befe 100644 --- a/MotionMark/tests/3d/resources/webgpu.js +++ b/MotionMark/tests/3d/resources/webgpu.js @@ -206,11 +206,11 @@ WebGLStage = Utilities.createSubclass(Stage, this._bindGroups = new Array(numTriangles); for (let i = 0; i < numTriangles; ++i) { - uniformWriteArray[alignedUniformFloats * i + 0] = Stage.random(0.2, 0.4); // scale - uniformWriteArray[alignedUniformFloats * i + 1] = Stage.random(-0.9, 0.9); // offsetX - uniformWriteArray[alignedUniformFloats * i + 2] = Stage.random(-0.9, 0.9); // offsetY - uniformWriteArray[alignedUniformFloats * i + 3] = Stage.random(0.5, 2); // scalar - uniformWriteArray[alignedUniformFloats * i + 4] = Stage.random(0, 10); // scalarOffset + uniformWriteArray[alignedUniformFloats * i + 0] = Random.number(0.2, 0.4); // scale + uniformWriteArray[alignedUniformFloats * i + 1] = Random.number(-0.9, 0.9); // offsetX + uniformWriteArray[alignedUniformFloats * i + 2] = Random.number(-0.9, 0.9); // offsetY + uniformWriteArray[alignedUniformFloats * i + 3] = Random.number(0.5, 2); // scalar + uniformWriteArray[alignedUniformFloats * i + 4] = Random.number(0, 10); // scalarOffset this._bindGroups[i] = device.createBindGroup({ layout: this._bindGroupLayout, @@ -259,9 +259,9 @@ WebGLStage = Utilities.createSubclass(Stage, const device = this._device; if (!this._startTime) - this._startTime = Stage.dateCounterValue(1000); + this._startTime = Random.dateCounterValue(1000); - const elapsedTimeData = new Float32Array([Stage.dateCounterValue(1000) - this._startTime]); + const elapsedTimeData = new Float32Array([Random.dateCounterValue(1000) - this._startTime]); // Update time uniform let mappedBuffer; diff --git a/MotionMark/tests/3d/triangles-webgl.html b/MotionMark/tests/3d/triangles-webgl.html index 8ce2a37..0e48957 100644 --- a/MotionMark/tests/3d/triangles-webgl.html +++ b/MotionMark/tests/3d/triangles-webgl.html @@ -83,6 +83,7 @@ gl_FragColor = v_color; } + diff --git a/MotionMark/tests/3d/triangles-webgpu.html b/MotionMark/tests/3d/triangles-webgpu.html index e8929b0..7f0e5f0 100644 --- a/MotionMark/tests/3d/triangles-webgpu.html +++ b/MotionMark/tests/3d/triangles-webgpu.html @@ -35,6 +35,7 @@ + diff --git a/MotionMark/tests/bouncing-particles/bouncing-canvas-images.html b/MotionMark/tests/bouncing-particles/bouncing-canvas-images.html index 90264c9..f4b8f8e 100644 --- a/MotionMark/tests/bouncing-particles/bouncing-canvas-images.html +++ b/MotionMark/tests/bouncing-particles/bouncing-canvas-images.html @@ -38,6 +38,7 @@ + diff --git a/MotionMark/tests/bouncing-particles/bouncing-canvas-shapes.html b/MotionMark/tests/bouncing-particles/bouncing-canvas-shapes.html index 63c3fee..7ee85aa 100644 --- a/MotionMark/tests/bouncing-particles/bouncing-canvas-shapes.html +++ b/MotionMark/tests/bouncing-particles/bouncing-canvas-shapes.html @@ -30,6 +30,7 @@ + diff --git a/MotionMark/tests/bouncing-particles/bouncing-css-images.html b/MotionMark/tests/bouncing-particles/bouncing-css-images.html index b52a2b9..a2dc911 100644 --- a/MotionMark/tests/bouncing-particles/bouncing-css-images.html +++ b/MotionMark/tests/bouncing-particles/bouncing-css-images.html @@ -35,6 +35,7 @@
+ diff --git a/MotionMark/tests/bouncing-particles/bouncing-css-shapes.html b/MotionMark/tests/bouncing-particles/bouncing-css-shapes.html index 00df8d6..cb277e1 100644 --- a/MotionMark/tests/bouncing-particles/bouncing-css-shapes.html +++ b/MotionMark/tests/bouncing-particles/bouncing-css-shapes.html @@ -46,6 +46,7 @@
+ diff --git a/MotionMark/tests/bouncing-particles/bouncing-svg-images.html b/MotionMark/tests/bouncing-particles/bouncing-svg-images.html index 351cd6b..f3bb7c0 100644 --- a/MotionMark/tests/bouncing-particles/bouncing-svg-images.html +++ b/MotionMark/tests/bouncing-particles/bouncing-svg-images.html @@ -30,6 +30,7 @@ + diff --git a/MotionMark/tests/bouncing-particles/bouncing-svg-shapes.html b/MotionMark/tests/bouncing-particles/bouncing-svg-shapes.html index 233f649..611f70b 100644 --- a/MotionMark/tests/bouncing-particles/bouncing-svg-shapes.html +++ b/MotionMark/tests/bouncing-particles/bouncing-svg-shapes.html @@ -30,6 +30,7 @@ + diff --git a/MotionMark/tests/bouncing-particles/bouncing-tagged-images.html b/MotionMark/tests/bouncing-particles/bouncing-tagged-images.html index fc0e2f9..ee3729c 100644 --- a/MotionMark/tests/bouncing-particles/bouncing-tagged-images.html +++ b/MotionMark/tests/bouncing-particles/bouncing-tagged-images.html @@ -32,6 +32,7 @@ + diff --git a/MotionMark/tests/bouncing-particles/resources/bouncing-canvas-particles.js b/MotionMark/tests/bouncing-particles/resources/bouncing-canvas-particles.js index ce12c72..696a45e 100644 --- a/MotionMark/tests/bouncing-particles/resources/bouncing-canvas-particles.js +++ b/MotionMark/tests/bouncing-particles/resources/bouncing-canvas-particles.js @@ -37,7 +37,7 @@ BouncingCanvasParticle = Utilities.createSubclass(BouncingParticle, return; this.context.translate(this.size.x / 2, this.size.y / 2); - this.context.rotate(this.rotater.degree() * Math.PI / 180); + this.context.rotate(this.rotator.degree() * Math.PI / 180); this.context.translate(-this.size.x / 2, -this.size.y / 2); }, diff --git a/MotionMark/tests/bouncing-particles/resources/bouncing-canvas-shapes.js b/MotionMark/tests/bouncing-particles/resources/bouncing-canvas-shapes.js index f3d0d81..6bd010b 100644 --- a/MotionMark/tests/bouncing-particles/resources/bouncing-canvas-shapes.js +++ b/MotionMark/tests/bouncing-particles/resources/bouncing-canvas-shapes.js @@ -29,8 +29,8 @@ BouncingCanvasShape = Utilities.createSubclass(BouncingCanvasParticle, { BouncingCanvasParticle.call(this, stage, stage.shape); this._fill = stage.fill; - this._color0 = Stage.randomColor(); - this._color1 = Stage.randomColor(); + this._color0 = Random.color(); + this._color1 = Random.color(); }, { _applyFill: function() diff --git a/MotionMark/tests/bouncing-particles/resources/bouncing-css-images.js b/MotionMark/tests/bouncing-particles/resources/bouncing-css-images.js index 2f3fa53..3d9fcb8 100644 --- a/MotionMark/tests/bouncing-particles/resources/bouncing-css-images.js +++ b/MotionMark/tests/bouncing-particles/resources/bouncing-css-images.js @@ -40,7 +40,7 @@ BouncingCssImage = Utilities.createSubclass(BouncingParticle, _move: function() { - this.element.style.transform = "translate(" + this.position.x + "px," + this.position.y + "px) " + this.rotater.rotateZ(); + this.element.style.transform = "translate(" + this.position.x + "px," + this.position.y + "px) " + this.rotator.rotateZ(); }, animate: function(timeDelta) diff --git a/MotionMark/tests/bouncing-particles/resources/bouncing-css-shapes.js b/MotionMark/tests/bouncing-particles/resources/bouncing-css-shapes.js index d3048d4..26d294f 100644 --- a/MotionMark/tests/bouncing-particles/resources/bouncing-css-shapes.js +++ b/MotionMark/tests/bouncing-particles/resources/bouncing-css-shapes.js @@ -34,20 +34,20 @@ BouncingCssShape = Utilities.createSubclass(BouncingParticle, switch (stage.fill) { case "solid": default: - this.element.style.backgroundColor = Stage.randomColor(); + this.element.style.backgroundColor = Random.color(); break; case "gradient": - this.element.style.background = "linear-gradient(" + Stage.randomColor() + ", " + Stage.randomColor() + ")"; + this.element.style.background = "linear-gradient(" + Random.color() + ", " + Random.color() + ")"; break; } if (stage.blend) - this.element.style.mixBlendMode = Stage.randomStyleMixBlendMode(); + this.element.style.mixBlendMode = Random.styleMixBlendMode(); // Some browsers have not un-prefixed the css filter yet. if (stage.filter) - Utilities.setElementPrefixedProperty(this.element, "filter", Stage.randomStyleFilter()); + Utilities.setElementPrefixedProperty(this.element, "filter", Random.styleFilter()); this._move(); }, { @@ -64,13 +64,13 @@ BouncingCssShape = Utilities.createSubclass(BouncingParticle, _move: function() { - this.element.style.transform = "translate(" + this.position.x + "px," + this.position.y + "px)" + this.rotater.rotateZ(); + this.element.style.transform = "translate(" + this.position.x + "px," + this.position.y + "px)" + this.rotator.rotateZ(); }, animate: function(timeDelta) { BouncingParticle.prototype.animate.call(this, timeDelta); - this.rotater.next(timeDelta); + this.rotator.next(timeDelta); this._move(); } }); diff --git a/MotionMark/tests/bouncing-particles/resources/bouncing-particles.js b/MotionMark/tests/bouncing-particles/resources/bouncing-particles.js index 393d4b2..4f48e99 100644 --- a/MotionMark/tests/bouncing-particles/resources/bouncing-particles.js +++ b/MotionMark/tests/bouncing-particles/resources/bouncing-particles.js @@ -27,10 +27,10 @@ function BouncingParticle(stage) this._stageSize = stage.size; this.size = stage.particleSize; - this.position = Stage.randomPosition(stage.size.subtract(stage.particleSize)); - this._angle = Stage.randomAngle(); - this._velocity = Stage.randomVelocity(stage.maxVelocity); - this.rotater = Stage.randomRotater(); + this.position = Random.position(stage.size.subtract(stage.particleSize)); + this._angle = Random.angle(); + this._velocity = Random.velocity(stage.maxVelocity); + this.rotator = Random.rotator(); } BouncingParticle.prototype = @@ -43,7 +43,7 @@ BouncingParticle.prototype = animate: function(timeDelta) { this.position = this.position.move(this._angle, this._velocity, timeDelta); - this.rotater.next(timeDelta); + this.rotator.next(timeDelta); // If particle is going to move off right side if (this.position.x + this.size.x > this._stageSize.x) { diff --git a/MotionMark/tests/bouncing-particles/resources/bouncing-svg-particles.js b/MotionMark/tests/bouncing-particles/resources/bouncing-svg-particles.js index ae10dfd..eba9468 100644 --- a/MotionMark/tests/bouncing-particles/resources/bouncing-svg-particles.js +++ b/MotionMark/tests/bouncing-particles/resources/bouncing-svg-particles.js @@ -42,7 +42,7 @@ BouncingSvgParticle = Utilities.createSubclass(BouncingParticle, { var transform = "translate(" + this.position.x + ", " + this.position.y + ")"; if (this._shape != "circle") - transform += this.rotater.rotate(this.size.center); + transform += this.rotator.rotate(this.size.center); this.element.setAttribute("transform", transform); }, diff --git a/MotionMark/tests/bouncing-particles/resources/bouncing-svg-shapes.js b/MotionMark/tests/bouncing-particles/resources/bouncing-svg-shapes.js index 91be977..10ac479 100644 --- a/MotionMark/tests/bouncing-particles/resources/bouncing-svg-shapes.js +++ b/MotionMark/tests/bouncing-particles/resources/bouncing-svg-shapes.js @@ -63,7 +63,7 @@ BouncingSvgShape = Utilities.createSubclass(BouncingSvgParticle, case "solid": default: - this.element.setAttribute("fill", Stage.randomColor()); + this.element.setAttribute("fill", Random.color()); break; } } @@ -88,7 +88,7 @@ BouncingSvgShapesStage = Utilities.createSubclass(BouncingSvgParticlesStage, var gradient = Utilities.createSVGElement("linearGradient", attrs, {}, this._ensureDefsIsCreated()); for (var i = 0; i < stops; ++i) { - attrs = { offset: i * 100 / (stops - 1) + "%", 'stop-color': Stage.randomColor() }; + attrs = { offset: i * 100 / (stops - 1) + "%", 'stop-color': Random.color() }; Utilities.createSVGElement("stop", attrs, {}, gradient); } diff --git a/MotionMark/tests/bouncing-particles/resources/bouncing-tagged-images.js b/MotionMark/tests/bouncing-particles/resources/bouncing-tagged-images.js index d8be60f..c93cfc5 100644 --- a/MotionMark/tests/bouncing-particles/resources/bouncing-tagged-images.js +++ b/MotionMark/tests/bouncing-particles/resources/bouncing-tagged-images.js @@ -32,7 +32,7 @@ BouncingTaggedImage = Utilities.createSubclass(BouncingParticle, this.element = document.createElement("img"); this.element.style.width = this.size.x + "px"; this.element.style.height = this.size.y + "px"; - this.element.setAttribute("src", Stage.randomElementInArray(stage.images).src); + this.element.setAttribute("src", Random.itemInArray(stage.images).src); stage.element.appendChild(this.element); this._move(); @@ -40,7 +40,7 @@ BouncingTaggedImage = Utilities.createSubclass(BouncingParticle, _move: function() { - this.element.style.transform = "translate(" + this.position.x + "px," + this.position.y + "px) " + this.rotater.rotateZ(); + this.element.style.transform = "translate(" + this.position.x + "px," + this.position.y + "px) " + this.rotator.rotateZ(); }, animate: function(timeDelta) diff --git a/MotionMark/tests/core/canvas-stage.html b/MotionMark/tests/core/canvas-stage.html index 9054192..5fb5e52 100644 --- a/MotionMark/tests/core/canvas-stage.html +++ b/MotionMark/tests/core/canvas-stage.html @@ -30,6 +30,7 @@ + diff --git a/MotionMark/tests/core/design.html b/MotionMark/tests/core/design.html index 0f30dfd..ec24c86 100644 --- a/MotionMark/tests/core/design.html +++ b/MotionMark/tests/core/design.html @@ -97,6 +97,7 @@ + diff --git a/MotionMark/tests/core/image-data.html b/MotionMark/tests/core/image-data.html index ef2e429..858fdc4 100644 --- a/MotionMark/tests/core/image-data.html +++ b/MotionMark/tests/core/image-data.html @@ -42,6 +42,7 @@
+ diff --git a/MotionMark/tests/core/leaves.html b/MotionMark/tests/core/leaves.html index 7d9bd3f..1d7ff26 100644 --- a/MotionMark/tests/core/leaves.html +++ b/MotionMark/tests/core/leaves.html @@ -38,6 +38,7 @@
+ diff --git a/MotionMark/tests/core/multiply.html b/MotionMark/tests/core/multiply.html index 4549951..3ebd6a2 100644 --- a/MotionMark/tests/core/multiply.html +++ b/MotionMark/tests/core/multiply.html @@ -67,6 +67,7 @@
+ diff --git a/MotionMark/tests/core/resources/canvas-stage.js b/MotionMark/tests/core/resources/canvas-stage.js index 57626bc..baadecc 100644 --- a/MotionMark/tests/core/resources/canvas-stage.js +++ b/MotionMark/tests/core/resources/canvas-stage.js @@ -53,7 +53,7 @@ SimpleCanvasStage = Utilities.createSubclass(Stage, newIndex = -newIndex; for (var i = 0; i < newIndex; ++i) { if (this._canvasObject.constructor === Array) - this.objects.push(new (Stage.randomElementInArray(this._canvasObject))(this)); + this.objects.push(new (Random.itemInArray(this._canvasObject))(this)); else this.objects.push(new this._canvasObject(this)); } diff --git a/MotionMark/tests/core/resources/canvas-tests.js b/MotionMark/tests/core/resources/canvas-tests.js index 3676e70..4d94f74 100644 --- a/MotionMark/tests/core/resources/canvas-tests.js +++ b/MotionMark/tests/core/resources/canvas-tests.js @@ -29,11 +29,11 @@ CanvasLineSegment = Utilities.createClass( function(stage) { - var circle = Stage.randomInt(0, 3); + var circle = Random.integer(0, 3); this._color = ["#e01040", "#10c030", "#744CBA", "#e05010"][circle]; this._lineWidth = Math.pow(Pseudo.random(), 12) * 20 + 3; this._omega = Pseudo.random() * 3 + 0.2; - var theta = Stage.randomAngle(); + var theta = Random.angle(); this._cosTheta = Math.cos(theta); this._sinTheta = Math.sin(theta); this._startX = stage.circleRadius * this._cosTheta + stage.circleX[circle]; @@ -47,7 +47,7 @@ CanvasLineSegment = Utilities.createClass( context.strokeStyle = this._color; context.lineWidth = this._lineWidth; - this._length += Math.sin(Stage.dateCounterValue(100) * this._omega); + this._length += Math.sin(Random.dateCounterValue(100) * this._omega); context.beginPath(); context.moveTo(this._startX, this._startY); @@ -63,21 +63,21 @@ CanvasArc = Utilities.createClass( var maxX = 6, maxY = 3; var distanceX = stage.size.x / maxX; var distanceY = stage.size.y / (maxY + 1); - var randY = Stage.randomInt(0, maxY); - var randX = Stage.randomInt(0, maxX - 1 * (randY % 2)); + var randY = Random.integer(0, maxY); + var randX = Random.integer(0, maxX - 1 * (randY % 2)); this._point = new Point(distanceX * (randX + (randY % 2) / 2), distanceY * (randY + .5)); this._radius = 20 + Math.pow(Pseudo.random(), 5) * (Math.min(distanceX, distanceY) / 1.8); - this._startAngle = Stage.randomAngle(); - this._endAngle = Stage.randomAngle(); + this._startAngle = Random.angle(); + this._endAngle = Random.angle(); this._omega = (Pseudo.random() - 0.5) * 0.3; - this._counterclockwise = Stage.randomBool(); + this._counterclockwise = Random.bool(); var colors = ["#101010", "#808080", "#c0c0c0"]; colors.push(["#e01040", "#10c030", "#e05010"][(randX + Math.ceil(randY / 2)) % 3]); this._color = colors[Math.floor(Pseudo.random() * colors.length)]; this._lineWidth = 1 + Math.pow(Pseudo.random(), 5) * 30; - this._doStroke = Stage.randomInt(0, 3) != 0; + this._doStroke = Random.integer(0, 3) != 0; }, { draw: function(context) @@ -108,7 +108,7 @@ CanvasLinePoint = Utilities.createClass( function(stage) { var colors = ["#101010", "#808080", "#c0c0c0", "#101010", "#808080", "#c0c0c0", "#e01040"]; - this.color = Stage.randomElementInArray(colors); + this.color = Random.itemInArray(colors); this.width = Math.pow(Pseudo.random(), 5) * 20 + 1; this.isSplit = Pseudo.random() > 0.5; @@ -133,7 +133,7 @@ CanvasLinePoint = Utilities.createClass( { var coordinate = startCoordinate; if (stage.objects.length) { - var offset = Stage.randomElementInArray(this.offsets); + var offset = Random.itemInArray(this.offsets); coordinate = coordinate.add(offset); if (coordinate.x < 0 || coordinate.x > this.gridSize.width) @@ -231,12 +231,12 @@ CanvasLineSegmentStage = Utilities.createSubclass(SimpleCanvasStage, var context = this.context; context.clearRect(0, 0, this.size.x, this.size.y); - var angle = Stage.dateFractionalValue(3000) * Math.PI * 2; + var angle = Random.dateFractionalValue(3000) * Math.PI * 2; var dx = this.twoFifthsSizeX * Math.cos(angle); var dy = this.twoFifthsSizeX * Math.sin(angle); var gradient = context.createLinearGradient(this.halfSize.x + dx, this.halfSize.y + dy, this.halfSize.x - dx, this.halfSize.y - dy); - var gradientStep = 0.5 + 0.5 * Math.sin(Stage.dateFractionalValue(5000) * Math.PI * 2); + var gradientStep = 0.5 + 0.5 * Math.sin(Random.dateFractionalValue(5000) * Math.PI * 2); var colorStopStep = Utilities.lerp(gradientStep, -.1, .1); var brightnessStep = Math.round(Utilities.lerp(gradientStep, 32, 64)); var color1Step = "rgba(" + brightnessStep + "," + brightnessStep + "," + (brightnessStep << 1) + ",.4)"; diff --git a/MotionMark/tests/core/resources/design.js b/MotionMark/tests/core/resources/design.js index ff09468..3262691 100644 --- a/MotionMark/tests/core/resources/design.js +++ b/MotionMark/tests/core/resources/design.js @@ -98,10 +98,10 @@ var TextStage = Utilities.createSubclass(Stage, animate: function(timeDelta) { - const angle = Stage.dateCounterValue(this.millisecondsPerRotation); + const angle = Random.dateCounterValue(this.millisecondsPerRotation); const gradient = this.gradients[Math.floor(angle / (Math.PI * 2)) % this.gradients.length]; - const offset = Stage.dateCounterValue(200); + const offset = Random.dateCounterValue(200); const maxX = Math.sin(angle) * this._maxOffset; const maxY = Math.cos(angle) * this._maxOffset; diff --git a/MotionMark/tests/core/resources/focus.js b/MotionMark/tests/core/resources/focus.js index ae51e5d..b90c9a8 100644 --- a/MotionMark/tests/core/resources/focus.js +++ b/MotionMark/tests/core/resources/focus.js @@ -45,8 +45,8 @@ var FocusElement = Utilities.createClass( var distance = Utilities.lerp(this._depth, 0, sizeVariance); size -= distance; - var top = Stage.random(0, stage.size.height - size); - var left = Stage.random(0, stage.size.width - size); + var top = Random.number(0, stage.size.height - size); + var left = Random.number(0, stage.size.width - size); this.particle = document.createElement("div"); this.particle.style.width = size + "px"; @@ -56,8 +56,8 @@ var FocusElement = Utilities.createClass( this.particle.style.zIndex = Math.round((1 - this._depth) * 10); var depthMultiplier = Utilities.lerp(1 - this._depth, 0.8, 1); - this._sinMultiplier = Pseudo.random() * Stage.randomSign() * depthMultiplier * travelDistance; - this._cosMultiplier = Pseudo.random() * Stage.randomSign() * depthMultiplier * travelDistance; + this._sinMultiplier = Pseudo.random() * Random.sign() * depthMultiplier * travelDistance; + this._cosMultiplier = Pseudo.random() * Random.sign() * depthMultiplier * travelDistance; this.animate(stage, 0, 0); }, { diff --git a/MotionMark/tests/core/resources/image-data.js b/MotionMark/tests/core/resources/image-data.js index 1940c3a..9cfc74a 100644 --- a/MotionMark/tests/core/resources/image-data.js +++ b/MotionMark/tests/core/resources/image-data.js @@ -133,8 +133,8 @@ var ImageDataStage = Utilities.createSubclass(Stage, }, _refreshElement: function(element) { - var top = Stage.randomInt(0, Math.floor((this.size.height - this.imageHeight) / this.imageHeight)) * this.imageHeight; - var left = Stage.randomInt(0, Math.floor((this.size.width - this.imageWidth) / this.imageWidth)) * this.imageWidth; + var top = Random.integer(0, Math.floor((this.size.height - this.imageHeight) / this.imageHeight)) * this.imageHeight; + var left = Random.integer(0, Math.floor((this.size.width - this.imageWidth) / this.imageWidth)) * this.imageWidth; element.style.top = top + 'px'; element.style.left = left + 'px'; @@ -170,7 +170,7 @@ var ImageDataStage = Utilities.createSubclass(Stage, context.putImageData(imageData, 0, 0); else { this._refreshElement(element); - element.getContext("2d").drawImage(Stage.randomElementInArray(this.images), 0, 0, this.imageWidth, this.imageHeight); + element.getContext("2d").drawImage(Random.itemInArray(this.images), 0, 0, this.imageWidth, this.imageHeight); } } }, diff --git a/MotionMark/tests/core/resources/leaves.js b/MotionMark/tests/core/resources/leaves.js index e23e383..cb1e90d 100644 --- a/MotionMark/tests/core/resources/leaves.js +++ b/MotionMark/tests/core/resources/leaves.js @@ -28,7 +28,7 @@ window.Leaf = Utilities.createSubclass(Particle, function(stage) { this.element = document.createElement("img"); - this.element.setAttribute("src", Stage.randomElementInArray(stage.images).src); + this.element.setAttribute("src", Random.itemInArray(stage.images).src); stage.element.appendChild(this.element); Particle.call(this, stage); @@ -46,17 +46,17 @@ window.Leaf = Utilities.createSubclass(Particle, if (this.usesOpacity) { this._opacity = .01; - this._opacityRate = 0.02 * Stage.random(1, 6); + this._opacityRate = 0.02 * Random.number(1, 6); } else - this._life = Stage.randomInt(20, 100); + this._life = Random.integer(20, 100); - this._position = new Point(Stage.random(0, this.maxPosition.x), Stage.random(-this.size.height, this.maxPosition.y)); - this._velocity = new Point(Stage.random(-6, -2), .1 * this.size.y + Stage.random(-1, 1)); + this._position = new Point(Random.number(0, this.maxPosition.x), Random.number(-this.size.height, this.maxPosition.y)); + this._velocity = new Point(Random.number(-6, -2), .1 * this.size.y + Random.number(-1, 1)); }, animate: function(timeDelta) { - this.rotater.next(timeDelta); + this.rotator.next(timeDelta); this._position.x += this._velocity.x + 8 * this.stage.focusX; this._position.y += this._velocity.y; @@ -81,7 +81,7 @@ window.Leaf = Utilities.createSubclass(Particle, move: function() { - this.element.style.transform = "translate(" + this._position.x + "px, " + this._position.y + "px)" + this.rotater.rotateZ(); + this.element.style.transform = "translate(" + this._position.x + "px, " + this._position.y + "px)" + this.rotator.rotateZ(); this.element.style.opacity = this._opacity; } }); @@ -143,7 +143,7 @@ Utilities.extendObject(ParticlesStage.prototype, { animate: function(timeDelta) { - this.focusX = 0.5 + 0.5 * Math.sin(Stage.dateFractionalValue(10000) * Math.PI * 2); + this.focusX = 0.5 + 0.5 * Math.sin(Random.dateFractionalValue(10000) * Math.PI * 2); timeDelta /= 4; this.particles.forEach(function(particle) { particle.animate(timeDelta); diff --git a/MotionMark/tests/core/resources/multiply.js b/MotionMark/tests/core/resources/multiply.js index c21febc..987fe75 100644 --- a/MotionMark/tests/core/resources/multiply.js +++ b/MotionMark/tests/core/resources/multiply.js @@ -54,7 +54,7 @@ var MultiplyStage = Utilities.createSubclass(Stage, var maxSide = Math.floor(y / tileStride) * 2 + 1; this._centerSpiralCount = maxSide * maxSide; for (var i = 0; i < this._centerSpiralCount; ++i) { - this._addTile(x, y, tileSize, Stage.randomInt(0, 359)); + this._addTile(x, y, tileSize, Random.integer(0, 359)); if (i == nextIndex) { direction = (direction + 1) % 4; @@ -78,13 +78,13 @@ var MultiplyStage = Utilities.createSubclass(Stage, if (Math.floor(i / maxSide) % 2 == 1) sideX = this.size.width - sideX - tileSize + 1; - this._addTile(sideX, sideY, tileSize, Stage.randomInt(0, 359)); + this._addTile(sideX, sideY, tileSize, Random.integer(0, 359)); } }, _addTile: function(x, y, tileSize, rotateDeg) { - var tile = Utilities.createElement("div", { class: "div-" + Stage.randomInt(0,6) }, this.element); + var tile = Utilities.createElement("div", { class: "div-" + Random.integer(0,6) }, this.element); var halfTileSize = tileSize / 2; tile.style.left = x + 'px'; tile.style.top = y + 'px'; diff --git a/MotionMark/tests/core/resources/particles.js b/MotionMark/tests/core/resources/particles.js index e918e1e..1abeca9 100644 --- a/MotionMark/tests/core/resources/particles.js +++ b/MotionMark/tests/core/resources/particles.js @@ -25,7 +25,7 @@ function Particle(stage) { this.stage = stage; - this.rotater = Stage.randomRotater(); + this.rotator = Random.rotator(1000, 10000); this.reset(); this.move(); } @@ -45,7 +45,7 @@ Particle.prototype = animate: function(timeDelta) { - this.rotater.next(timeDelta); + this.rotator.next(timeDelta); this.position = this.position.add(this.velocity.multiply(timeDelta)); this.velocity.y += 0.03; diff --git a/MotionMark/tests/core/resources/suits.js b/MotionMark/tests/core/resources/suits.js index 526f879..a3b2378 100644 --- a/MotionMark/tests/core/resources/suits.js +++ b/MotionMark/tests/core/resources/suits.js @@ -37,7 +37,7 @@ window.SuitsParticle = Utilities.createSubclass(Particle, initialize: function(stage) { - var shapeId = "#shape-" + Stage.randomInt(1, stage.particleTypeCount); + var shapeId = "#shape-" + Random.integer(1, stage.particleTypeCount); if (this.isClipPath) { this.element = Utilities.createSVGElement("rect", { x: 0, @@ -63,10 +63,10 @@ window.SuitsParticle = Utilities.createSubclass(Particle, { Particle.prototype.reset.call(this); - this.position = Stage.randomElementInArray(this.stage.emitLocation); + this.position = Random.itemInArray(this.stage.emitLocation); - var velocityMagnitude = Stage.random(.5, 2.5); - var angle = Stage.randomInt(0, this.stage.emitSteps) / this.stage.emitSteps * Math.PI * 2 + Stage.dateCounterValue(1000) * this.stage.emissionSpin + velocityMagnitude; + var velocityMagnitude = Random.number(.5, 2.5); + var angle = Random.integer(0, this.stage.emitSteps) / this.stage.emitSteps * Math.PI * 2 + Random.dateCounterValue(1000) * this.stage.emissionSpin + velocityMagnitude; this.velocity = new Point(Math.sin(angle), Math.cos(angle)) .multiply(velocityMagnitude); @@ -81,19 +81,19 @@ window.SuitsParticle = Utilities.createSubclass(Particle, if (this.hasGradient) { var transform = this.stage.element.createSVGTransform(); - transform.setRotate(Stage.randomInt(0, 359), 0, 0); + transform.setRotate(Random.integer(0, 359), 0, 0); this.gradient.gradientTransform.baseVal.initialize(transform); var stops = this.gradient.querySelectorAll("stop"); stops[0].setAttribute("stop-color", "hsl(" + this.stage.colorOffset + ", 70%, 45%)"); - stops[1].setAttribute("stop-color", "hsl(" + ((this.stage.colorOffset + Stage.randomInt(50,100)) % 360) + ", 70%, 65%)"); + stops[1].setAttribute("stop-color", "hsl(" + ((this.stage.colorOffset + Random.integer(50,100)) % 360) + ", 70%, 65%)"); } else this.element.setAttribute("fill", "hsl(" + this.stage.colorOffset + ", 70%, 65%)"); }, move: function() { - this.element.setAttribute("transform", "translate(" + this.position.x + "," + this.position.y + ") " + this.rotater.rotate(Point.zero) + this.transformSuffix); + this.element.setAttribute("transform", "translate(" + this.position.x + "," + this.position.y + ") " + this.rotator.rotate(Point.zero) + this.transformSuffix); } }); @@ -106,14 +106,14 @@ var SuitsStage = Utilities.createSubclass(ParticlesStage, initialize: function(benchmark) { ParticlesStage.prototype.initialize.call(this, benchmark); - this.emissionSpin = Stage.random(0, 3); - this.emitSteps = Stage.randomInt(4, 6); + this.emissionSpin = Random.number(0, 3); + this.emitSteps = Random.integer(4, 6); this.emitLocation = [ new Point(this.size.x * .25, this.size.y * .333), new Point(this.size.x * .5, this.size.y * .25), new Point(this.size.x * .75, this.size.y * .333) ]; - this.colorOffset = Stage.randomInt(0, 359); + this.colorOffset = Random.integer(0, 359); this.particleTypeCount = document.querySelectorAll(".shape").length; this.gradientsDefs = document.getElementById("gradients"); diff --git a/MotionMark/tests/core/suits.html b/MotionMark/tests/core/suits.html index 72d0872..d3dd92b 100644 --- a/MotionMark/tests/core/suits.html +++ b/MotionMark/tests/core/suits.html @@ -51,6 +51,7 @@ + diff --git a/MotionMark/tests/dom/compositing-transforms.html b/MotionMark/tests/dom/compositing-transforms.html index f94d299..8215277 100644 --- a/MotionMark/tests/dom/compositing-transforms.html +++ b/MotionMark/tests/dom/compositing-transforms.html @@ -37,6 +37,7 @@
+ diff --git a/MotionMark/tests/dom/focus.html b/MotionMark/tests/dom/focus.html index cef614e..4a4cf4e 100644 --- a/MotionMark/tests/dom/focus.html +++ b/MotionMark/tests/dom/focus.html @@ -65,6 +65,7 @@
focus
+ diff --git a/MotionMark/tests/dom/leaves.html b/MotionMark/tests/dom/leaves.html index e931fc3..1cecd15 100644 --- a/MotionMark/tests/dom/leaves.html +++ b/MotionMark/tests/dom/leaves.html @@ -38,6 +38,7 @@
+ diff --git a/MotionMark/tests/dom/multiply.html b/MotionMark/tests/dom/multiply.html index b5bef91..0f08c88 100644 --- a/MotionMark/tests/dom/multiply.html +++ b/MotionMark/tests/dom/multiply.html @@ -67,6 +67,7 @@
+ diff --git a/MotionMark/tests/dom/particles.html b/MotionMark/tests/dom/particles.html index 02b0786..6ffb0df 100644 --- a/MotionMark/tests/dom/particles.html +++ b/MotionMark/tests/dom/particles.html @@ -37,6 +37,7 @@
+ diff --git a/MotionMark/tests/dom/resources/compositing-transforms.js b/MotionMark/tests/dom/resources/compositing-transforms.js index c92fadf..5712633 100644 --- a/MotionMark/tests/dom/resources/compositing-transforms.js +++ b/MotionMark/tests/dom/resources/compositing-transforms.js @@ -35,7 +35,7 @@ BouncingCompositedImage = Utilities.createSubclass(BouncingParticle, this.element.setAttribute("src", stage.imageSrc); if (stage.useFilters) - this.element.style.filter = "hue-rotate(" + Stage.randomAngle() + "rad)"; + this.element.style.filter = "hue-rotate(" + Random.angle() + "rad)"; stage.element.appendChild(this.element); this._move(); @@ -43,7 +43,7 @@ BouncingCompositedImage = Utilities.createSubclass(BouncingParticle, _move: function() { - this.element.style.transform = "translate3d(" + this.position.x + "px," + this.position.y + "px, 0) " + this.rotater.rotateZ(); + this.element.style.transform = "translate3d(" + this.position.x + "px," + this.position.y + "px, 0) " + this.rotator.rotateZ(); }, animate: function(timeDelta) diff --git a/MotionMark/tests/dom/resources/dom-particles.js b/MotionMark/tests/dom/resources/dom-particles.js index 985de3c..7491f2a 100644 --- a/MotionMark/tests/dom/resources/dom-particles.js +++ b/MotionMark/tests/dom/resources/dom-particles.js @@ -37,11 +37,11 @@ DOMParticle = Utilities.createSubclass(Particle, { Particle.prototype.reset.call(this); - this.position = Stage.randomElementInArray(this.stage.emitLocation); + this.position = Random.itemInArray(this.stage.emitLocation); - var angle = Stage.randomInt(0, this.stage.emitSteps) / this.stage.emitSteps * Math.PI * 2 + Stage.dateCounterValue(100) * this.stage.emissionSpin; + var angle = Random.integer(0, this.stage.emitSteps) / this.stage.emitSteps * Math.PI * 2 + Random.dateCounterValue(100) * this.stage.emissionSpin; this.velocity = new Point(Math.sin(angle), Math.cos(angle)) - .multiply(Stage.random(.5, 2.5)); + .multiply(Random.number(.5, 2.5)); this.element.style.width = this.size.x + "px"; this.element.style.height = this.size.y + "px"; @@ -51,7 +51,7 @@ DOMParticle = Utilities.createSubclass(Particle, move: function() { - this.element.style.transform = "translate(" + this.position.x + "px, " + this.position.y + "px)" + this.rotater.rotateZ(); + this.element.style.transform = "translate(" + this.position.x + "px, " + this.position.y + "px)" + this.rotator.rotateZ(); } }); @@ -64,14 +64,14 @@ DOMParticleStage = Utilities.createSubclass(ParticlesStage, initialize: function(benchmark) { ParticlesStage.prototype.initialize.call(this, benchmark); - this.emissionSpin = Stage.random(0, 3); - this.emitSteps = Stage.randomInt(4, 6); + this.emissionSpin = Random.number(0, 3); + this.emitSteps = Random.integer(4, 6); this.emitLocation = [ new Point(this.size.x * .25, this.size.y * .333), new Point(this.size.x * .5, this.size.y * .25), new Point(this.size.x * .75, this.size.y * .333) ]; - this.colorOffset = Stage.randomInt(0, 359); + this.colorOffset = Random.integer(0, 359); }, createParticle: function() diff --git a/MotionMark/tests/dom/resources/focus.js b/MotionMark/tests/dom/resources/focus.js index c268d98..edac205 100644 --- a/MotionMark/tests/dom/resources/focus.js +++ b/MotionMark/tests/dom/resources/focus.js @@ -42,8 +42,8 @@ var FocusElement = Utilities.createClass( var distance = Utilities.lerp(this._depth, 0, sizeVariance); size -= distance; - var top = Stage.random(0, stage.size.height - size) - stage.maxBlurValue * 3; - var left = Stage.random(0, stage.size.width - size) - stage.maxBlurValue * 3; + var top = Random.number(0, stage.size.height - size) - stage.maxBlurValue * 3; + var left = Random.number(0, stage.size.width - size) - stage.maxBlurValue * 3; this.container = document.createElement('div'); this.container.style.width = (size + stage.maxBlurValue * 6) + "px"; @@ -59,8 +59,8 @@ var FocusElement = Utilities.createClass( this.particle.style.left = (stage.maxBlurValue * 3) + "px"; var depthMultiplier = Utilities.lerp(1 - this._depth, 0.8, 1); - this._sinMultiplier = Pseudo.random() * Stage.randomSign() * depthMultiplier * travelDistance; - this._cosMultiplier = Pseudo.random() * Stage.randomSign() * depthMultiplier * travelDistance; + this._sinMultiplier = Pseudo.random() * Random.sign() * depthMultiplier * travelDistance; + this._cosMultiplier = Pseudo.random() * Random.sign() * depthMultiplier * travelDistance; }, { hide: function() diff --git a/MotionMark/tests/dom/resources/leaves.js b/MotionMark/tests/dom/resources/leaves.js index a0bb633..72ec983 100644 --- a/MotionMark/tests/dom/resources/leaves.js +++ b/MotionMark/tests/dom/resources/leaves.js @@ -37,7 +37,7 @@ var SimpleLeaf = Utilities.createSubclass(SuperLeaf, move: function() { - this.element.style.transform = "translate(" + this._position.x + "px, " + this._position.y + "px)" + this.rotater.rotateZ(); + this.element.style.transform = "translate(" + this._position.x + "px, " + this._position.y + "px)" + this.rotator.rotateZ(); } }); @@ -53,7 +53,7 @@ var ScaleLeaf = Utilities.createSubclass(SuperLeaf, move: function() { - this.element.style.transform = "translate(" + this._position.x + "px, " + this._position.y + "px)" + this.rotater.rotateZ(); + this.element.style.transform = "translate(" + this._position.x + "px, " + this._position.y + "px)" + this.rotator.rotateZ(); } }); @@ -69,7 +69,7 @@ var OpacityLeaf = Utilities.createSubclass(SuperLeaf, move: function() { - this.element.style.transform = "translate(" + this._position.x + "px, " + this._position.y + "px)" + this.rotater.rotateZ(); + this.element.style.transform = "translate(" + this._position.x + "px, " + this._position.y + "px)" + this.rotator.rotateZ(); this.element.style.opacity = this._opacity; } }); diff --git a/MotionMark/tests/resources/main.js b/MotionMark/tests/resources/main.js index ca7f2a9..46eb4d2 100644 --- a/MotionMark/tests/resources/main.js +++ b/MotionMark/tests/resources/main.js @@ -722,132 +722,7 @@ Stage = Utilities.createClass( } }); -Utilities.extendObject(Stage, { - random: function(min, max) - { - return (Pseudo.random() * (max - min)) + min; - }, - - randomBool: function() - { - return !!Math.round(Pseudo.random()); - }, - - randomSign: function() - { - return Pseudo.random() >= .5 ? 1 : -1; - }, - - randomInt: function(min, max) - { - return Math.floor(this.random(min, max + 1)); - }, - - randomPosition: function(maxPosition) - { - return new Point(this.randomInt(0, maxPosition.x), this.randomInt(0, maxPosition.y)); - }, - - randomSquareSize: function(min, max) - { - var side = this.random(min, max); - return new Point(side, side); - }, - - randomVelocity: function(maxVelocity) - { - return this.random(maxVelocity / 8, maxVelocity); - }, - - randomAngle: function() - { - return this.random(0, Math.PI * 2); - }, - - randomColor: function() - { - var min = 32; - var max = 256 - 32; - return "#" - + this.randomInt(min, max).toString(16) - + this.randomInt(min, max).toString(16) - + this.randomInt(min, max).toString(16); - }, - - randomStyleMixBlendMode: function() - { - var mixBlendModeList = [ - 'normal', - 'multiply', - 'screen', - 'overlay', - 'darken', - 'lighten', - 'color-dodge', - 'color-burn', - 'hard-light', - 'soft-light', - 'difference', - 'exclusion', - 'hue', - 'saturation', - 'color', - 'luminosity' - ]; - - return mixBlendModeList[this.randomInt(0, mixBlendModeList.length)]; - }, - - randomStyleFilter: function() - { - var filterList = [ - 'grayscale(50%)', - 'sepia(50%)', - 'saturate(50%)', - 'hue-rotate(180)', - 'invert(50%)', - 'opacity(50%)', - 'brightness(50%)', - 'contrast(50%)', - 'blur(10px)', - 'drop-shadow(10px 10px 10px gray)' - ]; - - return filterList[this.randomInt(0, filterList.length)]; - }, - - randomElementInArray: function(array) - { - return array[Stage.randomInt(0, array.length - 1)]; - }, - - rotatingColor: function(cycleLengthMs, saturation, lightness) - { - return "hsl(" - + Stage.dateFractionalValue(cycleLengthMs) * 360 + ", " - + ((saturation || .8) * 100).toFixed(0) + "%, " - + ((lightness || .35) * 100).toFixed(0) + "%)"; - }, - - // Returns a fractional value that wraps around within [0,1] - dateFractionalValue: function(cycleLengthMs) - { - return (Date.now() / (cycleLengthMs || 2000)) % 1; - }, - - // Returns an increasing value slowed down by factor - dateCounterValue: function(factor) - { - return Date.now() / factor; - }, - - randomRotater: function() - { - return new Rotater(this.random(1000, 10000)); - } -}); - -Rotater = Utilities.createClass( +Rotator = Utilities.createClass( function(rotateInterval) { this._timeDelta = 0; diff --git a/MotionMark/tests/simple/resources/simple-canvas-paths.js b/MotionMark/tests/simple/resources/simple-canvas-paths.js index 143630d..445ddef 100644 --- a/MotionMark/tests/simple/resources/simple-canvas-paths.js +++ b/MotionMark/tests/simple/resources/simple-canvas-paths.js @@ -28,14 +28,14 @@ CanvasLineSegment = Utilities.createClass( function(stage) { - var radius = Stage.randomInt(10, 100); - var center = Stage.randomPosition(stage.size); - var delta = Point.pointOnCircle(Stage.randomAngle(), radius/2); + var radius = Random.integer(10, 100); + var center = Random.position(stage.size); + var delta = Point.pointOnCircle(Random.angle(), radius/2); this._point1 = center.add(delta); this._point2 = center.subtract(delta); - this._color = Stage.randomColor(); - this._lineWidth = Stage.randomInt(1, 100); + this._color = Random.color(); + this._lineWidth = Random.integer(1, 100); }, { draw: function(context) { @@ -51,7 +51,7 @@ CanvasLineSegment = Utilities.createClass( CanvasLinePoint = Utilities.createClass( function(stage, coordinateMaximumFactor) { var pointMaximum = new Point(Math.min(stage.size.x, coordinateMaximumFactor * stage.size.x), Math.min(stage.size.y, coordinateMaximumFactor * stage.size.y)); - this._point = Stage.randomPosition(pointMaximum).add(new Point((stage.size.x - pointMaximum.x) / 2, (stage.size.y - pointMaximum.y) / 2)); + this._point = Random.position(pointMaximum).add(new Point((stage.size.x - pointMaximum.x) / 2, (stage.size.y - pointMaximum.y) / 2)); }, { draw: function(context) { @@ -61,14 +61,14 @@ CanvasLinePoint = Utilities.createClass( CanvasQuadraticSegment = Utilities.createClass( function(stage) { - var maxSize = Stage.randomInt(20, 200); - var toCenter = Stage.randomPosition(stage.size).subtract(new Point(maxSize/2, maxSize/2)); - - this._point1 = Stage.randomPosition(new Point(maxSize, maxSize)).add(toCenter); - this._point2 = Stage.randomPosition(new Point(maxSize, maxSize)).add(toCenter); - this._point3 = Stage.randomPosition(new Point(maxSize, maxSize)).add(toCenter); - this._color = Stage.randomColor(); - this._lineWidth = Stage.randomInt(1, 50); + var maxSize = Random.integer(20, 200); + var toCenter = Random.position(stage.size).subtract(new Point(maxSize/2, maxSize/2)); + + this._point1 = Random.position(new Point(maxSize, maxSize)).add(toCenter); + this._point2 = Random.position(new Point(maxSize, maxSize)).add(toCenter); + this._point3 = Random.position(new Point(maxSize, maxSize)).add(toCenter); + this._color = Random.color(); + this._lineWidth = Random.integer(1, 50); }, { draw: function(context) { @@ -83,9 +83,9 @@ CanvasQuadraticSegment = Utilities.createClass( CanvasQuadraticPoint = Utilities.createClass( function(stage, coordinateMaximumFactor) { - var pointMaximum = Stage.randomPosition(new Point(Math.min(stage.size.x, coordinateMaximumFactor * stage.size.x), Math.min(stage.size.y, coordinateMaximumFactor * stage.size.y))); - this._point1 = Stage.randomPosition(pointMaximum).add(new Point((stage.size.x - pointMaximum.x) / 2, (stage.size.y - pointMaximum.y) / 2)); - this._point2 = Stage.randomPosition(pointMaximum).add(new Point((stage.size.x - pointMaximum.x) / 2, (stage.size.y - pointMaximum.y) / 2)); + var pointMaximum = Random.position(new Point(Math.min(stage.size.x, coordinateMaximumFactor * stage.size.x), Math.min(stage.size.y, coordinateMaximumFactor * stage.size.y))); + this._point1 = Random.position(pointMaximum).add(new Point((stage.size.x - pointMaximum.x) / 2, (stage.size.y - pointMaximum.y) / 2)); + this._point2 = Random.position(pointMaximum).add(new Point((stage.size.x - pointMaximum.x) / 2, (stage.size.y - pointMaximum.y) / 2)); }, { draw: function(context) { @@ -95,15 +95,15 @@ CanvasQuadraticPoint = Utilities.createClass( CanvasBezierSegment = Utilities.createClass( function(stage) { - var maxSize = Stage.randomInt(20, 200); - var toCenter = Stage.randomPosition(stage.size).subtract(new Point(maxSize/2, maxSize/2)); - - this._point1 = Stage.randomPosition(new Point(maxSize, maxSize)).add(toCenter); - this._point2 = Stage.randomPosition(new Point(maxSize, maxSize)).add(toCenter); - this._point3 = Stage.randomPosition(new Point(maxSize, maxSize)).add(toCenter); - this._point4 = Stage.randomPosition(new Point(maxSize, maxSize)).add(toCenter); - this._color = Stage.randomColor(); - this._lineWidth = Stage.randomInt(1, 50); + var maxSize = Random.integer(20, 200); + var toCenter = Random.position(stage.size).subtract(new Point(maxSize/2, maxSize/2)); + + this._point1 = Random.position(new Point(maxSize, maxSize)).add(toCenter); + this._point2 = Random.position(new Point(maxSize, maxSize)).add(toCenter); + this._point3 = Random.position(new Point(maxSize, maxSize)).add(toCenter); + this._point4 = Random.position(new Point(maxSize, maxSize)).add(toCenter); + this._color = Random.color(); + this._lineWidth = Random.integer(1, 50); }, { draw: function(context) { @@ -118,10 +118,10 @@ CanvasBezierSegment = Utilities.createClass( CanvasBezierPoint = Utilities.createClass( function(stage, coordinateMaximumFactor) { - var pointMaximum = Stage.randomPosition(new Point(Math.min(stage.size.x, coordinateMaximumFactor * stage.size.x), Math.min(stage.size.y, coordinateMaximumFactor * stage.size.y))); - this._point1 = Stage.randomPosition(pointMaximum).add(new Point((stage.size.x - pointMaximum.x) / 2, (stage.size.y - pointMaximum.y) / 2)); - this._point2 = Stage.randomPosition(pointMaximum).add(new Point((stage.size.x - pointMaximum.x) / 2, (stage.size.y - pointMaximum.y) / 2)); - this._point3 = Stage.randomPosition(pointMaximum).add(new Point((stage.size.x - pointMaximum.x) / 2, (stage.size.y - pointMaximum.y) / 2)); + var pointMaximum = Random.position(new Point(Math.min(stage.size.x, coordinateMaximumFactor * stage.size.x), Math.min(stage.size.y, coordinateMaximumFactor * stage.size.y))); + this._point1 = Random.position(pointMaximum).add(new Point((stage.size.x - pointMaximum.x) / 2, (stage.size.y - pointMaximum.y) / 2)); + this._point2 = Random.position(pointMaximum).add(new Point((stage.size.x - pointMaximum.x) / 2, (stage.size.y - pointMaximum.y) / 2)); + this._point3 = Random.position(pointMaximum).add(new Point((stage.size.x - pointMaximum.x) / 2, (stage.size.y - pointMaximum.y) / 2)); }, { draw: function(context) { @@ -131,15 +131,15 @@ CanvasBezierPoint = Utilities.createClass( CanvasArcToSegment = Utilities.createClass( function(stage) { - var maxSize = Stage.randomInt(20, 200); - var toCenter = Stage.randomPosition(stage.size).subtract(new Point(maxSize/2, maxSize/2)); - - this._point1 = Stage.randomPosition(new Point(maxSize, maxSize)).add(toCenter); - this._point2 = Stage.randomPosition(new Point(maxSize, maxSize)).add(toCenter); - this._point3 = Stage.randomPosition(new Point(maxSize, maxSize)).add(toCenter); - this._radius = Stage.randomInt(20, 200); - this._color = Stage.randomColor(); - this._lineWidth = Stage.randomInt(1, 50); + var maxSize = Random.integer(20, 200); + var toCenter = Random.position(stage.size).subtract(new Point(maxSize/2, maxSize/2)); + + this._point1 = Random.position(new Point(maxSize, maxSize)).add(toCenter); + this._point2 = Random.position(new Point(maxSize, maxSize)).add(toCenter); + this._point3 = Random.position(new Point(maxSize, maxSize)).add(toCenter); + this._radius = Random.integer(20, 200); + this._color = Random.color(); + this._lineWidth = Random.integer(1, 50); }, { draw: function(context) { @@ -168,16 +168,16 @@ CanvasArcToSegmentFill = Utilities.createClass( CanvasArcSegment = Utilities.createClass( function(stage) { - var maxSize = Stage.randomInt(20, 200); - var toCenter = Stage.randomPosition(stage.size).subtract(new Point(maxSize/2, maxSize/2)); - - this._point = Stage.randomPosition(new Point(maxSize, maxSize)).add(toCenter); - this._radius = Stage.randomInt(20, 200); - this._startAngle = Stage.randomAngle(); - this._endAngle = Stage.randomAngle(); - this._counterclockwise = Stage.randomBool(); - this._color = Stage.randomColor(); - this._lineWidth = Stage.randomInt(1, 50); + var maxSize = Random.integer(20, 200); + var toCenter = Random.position(stage.size).subtract(new Point(maxSize/2, maxSize/2)); + + this._point = Random.position(new Point(maxSize, maxSize)).add(toCenter); + this._radius = Random.integer(20, 200); + this._startAngle = Random.angle(); + this._endAngle = Random.angle(); + this._counterclockwise = Random.bool(); + this._color = Random.color(); + this._lineWidth = Random.integer(1, 50); }, { draw: function(context) { @@ -204,11 +204,11 @@ CanvasArcSegmentFill = Utilities.createClass( CanvasRect = Utilities.createClass( function(stage) { - this._width = Stage.randomInt(20, 200); - this._height = Stage.randomInt(20, 200); - this._point = Stage.randomPosition(stage.size).subtract(new Point(this._width/2, this._height/2)); - this._color = Stage.randomColor(); - this._lineWidth = Stage.randomInt(1, 20); + this._width = Random.integer(20, 200); + this._height = Random.integer(20, 200); + this._point = Random.position(stage.size).subtract(new Point(this._width/2, this._height/2)); + this._color = Random.color(); + this._lineWidth = Random.integer(1, 20); }, { draw: function(context) { @@ -235,16 +235,16 @@ CanvasRectFill = Utilities.createClass( CanvasEllipse = Utilities.createClass( function(stage) { - this._radius = new Point(Stage.randomInt(20, 200), Stage.randomInt(20, 200)); - var toCenter = Stage.randomPosition(stage.size).subtract(this._radius.multiply(.5)); - - this._center = Stage.randomPosition(this._radius).add(toCenter); - this._rotation = Stage.randomAngle(); - this._startAngle = Stage.randomAngle(); - this._endAngle = Stage.randomAngle(); - this._anticlockwise = Stage.randomBool(); - this._color = Stage.randomColor(); - this._lineWidth = Stage.randomInt(1, 20); + this._radius = new Point(Random.integer(20, 200), Random.integer(20, 200)); + var toCenter = Random.position(stage.size).subtract(this._radius.multiply(.5)); + + this._center = Random.position(this._radius).add(toCenter); + this._rotation = Random.angle(); + this._startAngle = Random.angle(); + this._endAngle = Random.angle(); + this._anticlockwise = Random.bool(); + this._color = Random.color(); + this._lineWidth = Random.integer(1, 20); }, { draw: function(context) { @@ -271,7 +271,7 @@ CanvasEllipseFill = Utilities.createClass( CanvasStroke = Utilities.createClass( function (stage) { - this._object = new (Stage.randomElementInArray(this.objectTypes))(stage); + this._object = new (Random.itemInArray(this.objectTypes))(stage); }, { objectTypes: [ @@ -290,7 +290,7 @@ CanvasStroke = Utilities.createClass( CanvasFill = Utilities.createClass( function (stage) { - this._object = new (Stage.randomElementInArray(this.objectTypes))(stage); + this._object = new (Random.itemInArray(this.objectTypes))(stage); }, { objectTypes: [ @@ -316,8 +316,8 @@ SimpleCanvasPathStrokeStage = Utilities.createSubclass(SimpleCanvasStage, { var context = this.context; context.clearRect(0, 0, this.size.x, this.size.y); - context.lineWidth = Stage.randomInt(1, 20); - context.strokeStyle = Stage.rotatingColor(); + context.lineWidth = Random.integer(1, 20); + context.strokeStyle = Random.rotatingColor(); context.beginPath(); context.moveTo(this.size.x / 2, this.size.y / 2); for (var i = 0, length = this.offsetIndex; i < length; ++i) @@ -335,7 +335,7 @@ SimpleCanvasPathFillStage = Utilities.createSubclass(SimpleCanvasStage, { var context = this.context; context.clearRect(0, 0, this.size.x, this.size.y); - context.fillStyle = Stage.rotatingColor(); + context.fillStyle = Random.rotatingColor(); context.beginPath(); context.moveTo(this.size.x / 2, this.size.y / 2); for (var i = 0, length = this.offsetIndex; i < length; ++i) diff --git a/MotionMark/tests/simple/simple-canvas-paths.html b/MotionMark/tests/simple/simple-canvas-paths.html index a914548..d83a7d1 100644 --- a/MotionMark/tests/simple/simple-canvas-paths.html +++ b/MotionMark/tests/simple/simple-canvas-paths.html @@ -30,6 +30,7 @@ + diff --git a/MotionMark/tests/simple/tiled-canvas-image.html b/MotionMark/tests/simple/tiled-canvas-image.html index 237aeac..199087e 100644 --- a/MotionMark/tests/simple/tiled-canvas-image.html +++ b/MotionMark/tests/simple/tiled-canvas-image.html @@ -30,6 +30,7 @@ + diff --git a/MotionMark/tests/svg/suits.html b/MotionMark/tests/svg/suits.html index a39d1d8..5eda6bc 100644 --- a/MotionMark/tests/svg/suits.html +++ b/MotionMark/tests/svg/suits.html @@ -56,6 +56,7 @@ + diff --git a/MotionMark/tests/svg/suits.js b/MotionMark/tests/svg/suits.js index 9916755..42fa770 100644 --- a/MotionMark/tests/svg/suits.js +++ b/MotionMark/tests/svg/suits.js @@ -89,8 +89,8 @@ StaticSuit = Utilities.createSubclass(SuperSuitsParticle, reset: function() { SuperSuitsParticle.prototype.reset.call(this); - this.originalPosition = Stage.randomPosition(this.stage.size); - this.transformSuffix = " rotate(" + Math.floor(Stage.randomAngle() * 180 / Math.PI) + ",0,0)" + this.transformSuffix; + this.originalPosition = Random.position(this.stage.size); + this.transformSuffix = " rotate(" + Math.floor(Random.angle() * 180 / Math.PI) + ",0,0)" + this.transformSuffix; }, move: function() diff --git a/MotionMark/tests/template/template-canvas.html b/MotionMark/tests/template/template-canvas.html index bdcab6f..b0da810 100644 --- a/MotionMark/tests/template/template-canvas.html +++ b/MotionMark/tests/template/template-canvas.html @@ -30,6 +30,7 @@ + diff --git a/MotionMark/tests/template/template-css.html b/MotionMark/tests/template/template-css.html index ed6b6ca..da77a6b 100644 --- a/MotionMark/tests/template/template-css.html +++ b/MotionMark/tests/template/template-css.html @@ -30,6 +30,7 @@
+ diff --git a/MotionMark/tests/template/template-svg.html b/MotionMark/tests/template/template-svg.html index eb7a034..751b70a 100644 --- a/MotionMark/tests/template/template-svg.html +++ b/MotionMark/tests/template/template-svg.html @@ -30,6 +30,7 @@ + diff --git a/MotionMark/tests/text/design-6.html b/MotionMark/tests/text/design-6.html index decbdd2..9923a69 100644 --- a/MotionMark/tests/text/design-6.html +++ b/MotionMark/tests/text/design-6.html @@ -106,6 +106,7 @@ + diff --git a/MotionMark/tests/text/design.html b/MotionMark/tests/text/design.html index 2de4977..fac8116 100644 --- a/MotionMark/tests/text/design.html +++ b/MotionMark/tests/text/design.html @@ -96,6 +96,7 @@ +