Skip to content

Instantly share code, notes, and snippets.

@mahemoff
Created July 25, 2011 11:55
Show Gist options
  • Save mahemoff/1103972 to your computer and use it in GitHub Desktop.
Save mahemoff/1103972 to your computer and use it in GitHub Desktop.
canvas draw grid (jquery + kaffeine)
$.fn.grid = (interval) -> {
var canvas = @[0], context = canvas.getContext('2d')
x = y = 0.5
while((x+=interval)<canvas.width) {
context.moveTo(x,0)
context.lineTo(x,canvas.height)
}
while((y+=interval)<canvas.height) {
context.moveTo(0,y)
context.lineTo(canvas.width,y)
}
context.strokeStyle = "rgba(0,0,0,0.5)"
context.stroke();
}
// $("canvas").grid(16)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment