Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Try it, run in about:blank and paste in the console
- document.body.appendChild(c=document.createElement("canvas"));
- c.width = 800;
- c.height = 800;
- var ctx = c.getContext("2d");
- ctx.fillRect(0,0,800,800)
- var ctr = 0;
- function deg2rad(a) {
- return (((a%360)+360)%360) / (180/Math.PI);
- }
- var ps = [];
- var I = 0;
- function p(x,y,a) {
- if ((I=(I+1)%3)==0)ps.push([x,y,a]);
- for (var i = 0; i < ps.length; i++) {
- var x = ps[i][0],
- y = ps[i][1],
- a = ps[i][2];
- ctx.strokeStyle="hsl("+a+",50%,70%)";
- ctx.beginPath();
- ctx.moveTo(x,y);
- x += Math.sin(deg2rad(a)) * 1.2;
- y += Math.cos(deg2rad(a)) * 1.2;
- ctx.lineTo(x,y);
- ctx.stroke();
- ps[i] = [x,y,a];
- }
- ps = ps.filter(function (p) {
- return!(p[0] < -5 || p[0] > 805 || p[1] < -5 || p[1] > 805);
- })
- }
- ctx.lineWidth = 4;
- ctx.fillStyle = "#000";
- ctx.lineCap = "round";
- function draw() {
- ctr = (ctr + 4.4) % 360;
- ctx.globalAlpha = 0.04;
- ctx.fillRect(0,0,800,800);
- ctx.globalAlpha = 1;
- p(400,400,ctr);
- };
- function frame() {
- requestAnimationFrame(frame);
- draw();
- }
- frame();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement