Skip to content

Instantly share code, notes, and snippets.

@robertcasanova
Created October 22, 2014 07:17
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 robertcasanova/5298256e650e76107d10 to your computer and use it in GitHub Desktop.
Save robertcasanova/5298256e650e76107d10 to your computer and use it in GitHub Desktop.
var paper = Raphael(0, 0, 400, 400);
var r = 100;
var steps = 120;
var totLed = 48;
// Sets the fill attribute of the circle to red (#f00)
var circles = [];
// Sets the stroke attribute of the circle to white
var alpha = 0;
var offsetX = 200;
var offsetY = 200;
for(var i = 0; i < 5700; i++) {
if(i!=0 && i%totLed == 0) {
alpha = (alpha+1)%steps;
}
var x = 4 * (totLed - (i%totLed)) * Math.cos(2*Math.PI/steps * alpha);
var y = 4 * (totLed - (i%totLed)) * Math.sin(2*Math.PI/steps * alpha);
var circle = paper.circle(x + offsetX,y + offsetY,2);
circle.attr("fill", "#000");
circle.attr("stroke", "transparent");
circle.hover(function(e,a){
this.attr("fill","#0f2");
//e.toElement.attr("fill","#000");
});
circles.push(circle);
}
function printBuffer() {
console.log(circles.map(function(item){
return (item.attr("fill") == "#000") ? 0 : 1;
}));
}
window.printBuffer = printBuffer;
<button onClick="printBuffer()" style="position:absolute; bottom:0;">Press</button>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment