Skip to content

Instantly share code, notes, and snippets.

@enjalot
Created August 4, 2012 18:40
Show Gist options
  • Save enjalot/3259253 to your computer and use it in GitHub Desktop.
Save enjalot/3259253 to your computer and use it in GitHub Desktop.
just another inlet to tributary
{"editor_editor":{"coffee":false,"vim":false,"emacs":false,"width":304,"height":402,"hide":true},"endpoint":"cypress"}
// View live at http://enjalot.com/cypress/3126863
var n = 3200; // number of dots
var j = -2.07822; // time spinning
var k = 1.6; // spinning constant
var opacity = 0.8; // dpt opacity
var scale = 4;
var erasing = .1;
trib.munch = 5;
trib_options.munch = {min:-0.45, max: 0.45}
tributary.t = 10;
var w = tributary.sw,
h = tributary.sh;
tributary.init = function(ctx) {
d3.select('#display').style('background', "#090909");
ctx.globalCompositeOperation = 'source-over';
};
tributary.run = function(ctx,t) {
ctx.fillStyle = "rgba(9,9,9," + erasing + ")";
ctx.fillRect(0,0,w,h);
ctx.fillText(t,5,5);
GOLDEN_ANGLE = Math.PI * (j*t/400 - Math.sqrt(k*(t+1)/500));
var points = d3.range(1, n).map(place);
points.forEach(circle);
function circle(p,i) {
ctx.fillStyle = 'hsla(0,00%,' + 100 +'%,' + opacity + ')'
ctx.beginPath();
ctx.arc(p[0],p[1],1,0,2*Math.PI);
ctx.fill();
}
function place(n) {
var r = Math.sqrt(n),
a = GOLDEN_ANGLE / Math.cos(t * n/30)*trib.munch;
return [scale * r * Math.cos(a)+w/2, scale * r * Math.sin(a)+h/2 - 30];
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment