X-Git-Url: https://git.r.bdr.sh/rbdr/r.bdr.sh/blobdiff_plain/21b1c71d7a582d5303edef60ed171c776306c07f..47805069c1aa6c1fb36f7029104089aa56554405:/jekyll/js/animation.js diff --git a/jekyll/js/animation.js b/jekyll/js/animation.js index 3fc4a85..65ee4bd 100644 --- a/jekyll/js/animation.js +++ b/jekyll/js/animation.js @@ -1,26 +1,26 @@ (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); } @@ -44,7 +44,7 @@ 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(); }