Answer the question
In order to leave comments, you need to log in
How to write a grid drawing loop on canvas?
Help write a loop that draws a grid on a canvas, regardless of the size of the canvas.
Answer the question
In order to leave comments, you need to log in
for (var i = 0; i < canvas.width; i += 25) {
context.beginPath();
context.moveTo(i, 0);
context.lineTo(i, canvas.height);
context.stroke();
}
for (var i = 0; i < canvas.height; i += 25) {
context.beginPath();
context.moveTo(0, i);
context.lineTo(canvas.width, i);
context.stroke();
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question