Skip to content

Instantly share code, notes, and snippets.

@ebinion
Last active January 1, 2016 07:09
Show Gist options
  • Save ebinion/8109410 to your computer and use it in GitHub Desktop.
Save ebinion/8109410 to your computer and use it in GitHub Desktop.
Someday I'll turn this into a Chrome Extension ... just not today
window.GridOverlay = (vHeight = 18, canvasId = "gridOverlayCanvas")->
window.console.log("working")
new_canvas = document.createElement("canvas")
new_context = new_canvas.getContext("2d")
new_canvas.id = canvasId
this.setCanvasDimensions = ->
new_canvas.width = document.body.offsetWidth
new_canvas.height = document.body.offsetHeight
this.drawGrid = ->
y = 0.5
while y < new_canvas.height
new_context.moveTo(0, y)
new_context.lineTo(new_canvas.height, y)
y += vHeight
new_context.strokeStyle = "#FAA"
new_context.stroke()
this.setStyles = ->
cs = new_canvas.style
cs.left = 0
cs.opacity = 0.5
cs.pointerEvents = "none"
cs.position = "absolute"
cs.top = 0
cs.zIndex = 99999
this.setCanvasDimensions()
this.drawGrid()
this.setStyles()
document.body.appendChild(new_canvas)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment