Skip to content

Instantly share code, notes, and snippets.

@kodi
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kodi/c6e00981c364f22632a0 to your computer and use it in GitHub Desktop.
Save kodi/c6e00981c364f22632a0 to your computer and use it in GitHub Desktop.
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
var circleStroke = function(radius, x, y, strokeColor) {
ctx.strokeStyle = strokeColor;
ctx.beginPath();
ctx.arc(x, y, radius, 0, Math.PI * 2);
ctx.stroke();
ctx.closePath();
};
var width = 700;
var height = 700;
var center = {x: width/2, y: height/2};
var mainRadius = 200;
var counter = 0;
var nP = 100;
function draw(){
ctx.clearRect(0, 0, width, height);
var c = 5 + (nP* Math.abs(Math.sin(counter)));
for (var i = 0; i < c; i++){
for(var j = 1; j<=3.4; j += 0.01) {
var x = mainRadius * Math.sin(i + j);
var y = mainRadius * Math.cos(i + j);
var cB = parseInt((255 / j) * (i/nP));
var color = 'rgba(30, 30, ' + cB + ', 0.2)';
circleStroke(c/j, ((x/j) + center.x), ((y/j) + center.y), color);
}
}
counter+=0.01;
window.requestAnimationFrame(draw);
}
window.requestAnimationFrame(draw);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment