Skip to content

Instantly share code, notes, and snippets.

@JPalounek
Created February 28, 2012 21:21
Show Gist options
  • Save JPalounek/1935239 to your computer and use it in GitHub Desktop.
Save JPalounek/1935239 to your computer and use it in GitHub Desktop.
Gridder - developer tool which cover page with grid for easier coding
function setupCanvas() {
var canvas = document.createElement('canvas');
document.body.appendChild(canvas);
canvas.width = 4000;
canvas.height = 4000;
canvas.id = "grid";
canvas.style.position = "absolute";
canvas.style.left = "0px";
canvas.style.top = "0px";
canvas.style.overflow = 'hidden';
}
function drawGrid(x_dist, y_dist, color) {
var a_canvas = document.getElementById("grid");
var a_context = a_canvas.getContext("2d");
for (var x = 0.5; x < 1500; x += x_dist) {
a_context.moveTo(x, 0);
a_context.lineTo(x, 3000);
}
for (var y = 0.5; y < 1500; y += y_dist) {
a_context.moveTo(0, y);
a_context.lineTo(3000, y);
}
a_context.strokeStyle = color;
a_context.stroke();
}
window.onload = function() {
// Set it up here
var x_dist = 20;
var y_dist = 20;
var color = "#00ffff";
// Let it run
setupCanvas();
drawGrid(x_dist, y_dist, color);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment