- 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(rand(10) + 6).fill(null).map(() => ({
- x: rand(64),
- y: rand(64),
- angle: Math.random() * 2 * Math.PI,
- color: Array(3).fill(rand(256))
- }));
- var shapes = [square, circle, heart, chaos, lineChaos];
- var positions = [identity, spin(5), spin(15)];
- var draw = shapes[rand(shapes.length)];
- var position = positions[rand(positions.length)];
-
- function rand (x) {
- return Math.floor(Math.random() * x);
+ var K = document.querySelector('canvas'),
+ { random: r, PI, cos, sin, floor, atan2 } = Math,
+ ctx = K.getContext('2d'),
+ fps = 24,
+ lst = 0,
+ spd = 1,
+ siz = 5 + rnd(10),
+ clr = r() > 0.5,
+ ccl = r() > 0.5,
+ I = Array(rnd(10) + 6).fill(null).map(() => ({
+ x: rnd(64),
+ y: rnd(64),
+ a: r() * 2 * PI,
+ c: Array(3).fill(rnd(256))
+ })),
+ SHP = [sqr, crc, hrt, chs, lch],
+ POS = [id, spn(5), spn(15)],
+ draw = SHP[rnd(SHP.length)],
+ pos = POS[rnd(POS.length)];
+
+ function rnd (x) {
+ return floor(r() * x);