(function () {
- var canvas = document.querySelector('canvas');
- var context = canvas.getContext('2d');
- var fps = 30;
- var lastFrame = 0;
- var speed = 1;
- var size = 5 + Roundom(10);
+ var canvas = document.querySelector('canvas'),
+ context = canvas.getContext('2d'),
+ fps = 30,
+ lastFrame = 0,
+ speed = 1,
+ size = 5 + rand(10);
var clear = !!(Math.random() > 0.5);
var changeColor = !!(Math.random() > 0.5);
- var items = Array(Roundom(10) + 6).fill(null).map(() => ({
- x: Roundom(100),
- y: Roundom(100),
+ var items = Array(rand(10) + 6).fill(null).map(() => ({
+ x: rand(100),
+ y: rand(100),
angle: Math.random() * 2 * Math.PI,
- color: Array(3).fill(null).map(() => Roundom(256))
+ color: Array(3).fill(null).map(() => rand(256))
}));
var shapes = [square, circle, heart, chaos, lineChaos];
var positions = [identity, spin(5), spin(15)];
- var draw = shapes[Roundom(shapes.length)];
- var position = positions[Roundom(positions.length)];
+ var draw = shapes[rand(shapes.length)];
+ var position = positions[rand(positions.length)];
- function Roundom (x) {
+ function rand (x) {
return Math.floor(Math.random() * x);
}
context.beginPath();
context.moveTo(p.x, p.y);
context.lineTo(p.x * 10 * Math.cos(item.angle), p.y * 10 * Math.sin(item.angle));
- context.lineTo(Roundom(100), Roundom(100));
+ context.lineTo(rand(100), rand(100));
context.fill();
}