Created
December 1, 2018 19:13
-
-
Save 0xCourtney/49e7ae57153d0550c8241767956d9919 to your computer and use it in GitHub Desktop.
HTML Canvas Grid of X's
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
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