Skip to content

Instantly share code, notes, and snippets.

@0xCourtney
Created December 1, 2018 19:13
Show Gist options
  • Save 0xCourtney/49e7ae57153d0550c8241767956d9919 to your computer and use it in GitHub Desktop.
Save 0xCourtney/49e7ae57153d0550c8241767956d9919 to your computer and use it in GitHub Desktop.
HTML Canvas Grid of X's
function draw() {
var canvas = document.getElementById('canvas');
if (canvas.getContext) {
var ctx = canvas.getContext('2d');
ctx.beginPath();
var scale = 10;
var spacing = 20;
for (let x = 0; x <= 1000; x += spacing) {
for (let y = 0; y <= 1000; y += spacing) {
ctx.moveTo(x, y);
ctx.lineTo(x + scale, y + scale);
ctx.moveTo(x + scale, y);
ctx.lineTo(x, y + scale);
ctx.stroke();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment