Created
July 13, 2011 02:33
-
-
Save benfoxall/1079611 to your computer and use it in GitHub Desktop.
delta drawing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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