Skip to content

Instantly share code, notes, and snippets.

@benfoxall
Created July 13, 2011 02:33
Show Gist options
  • Save benfoxall/1079611 to your computer and use it in GitHub Desktop.
Save benfoxall/1079611 to your computer and use it in GitHub Desktop.
delta drawing
var y1 = 0, y2 = 0, y3 = 0;
var x1 = 0, x2 = width/2, x3 = width;
_(timestamp.ndeltas()).each(function(delta){
var artist = delta[0];
var v1 = delta[1];
var v2 = delta[2];
var v3 = delta[3];
var enter_y = (v1 + v2)/2;
var exit_y = (v2 + v3)/2;
ctx.fillStyle = color(artist);
ctx.beginPath();
ctx.moveTo(x1,y1);
ctx.lineTo(x1,y1 + enter_y);
ctx.lineTo(x2,y2 + v2);
ctx.lineTo(x3,y3 + exit_y);
ctx.lineTo(x3,y3);
ctx.lineTo(x2,y2);
ctx.moveTo(x1,y1);
ctx.fill();
y1 += enter_y;
y2 += v2;
y3 += exit_y;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment