B
B
Brain Storm2014-02-23 12:06:08
JavaScript
Brain Storm, 2014-02-23 12:06:08

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

2 answer(s)
P
Pozadi, 2014-02-23
@EkLast

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();
}

K
Konstantin Dovnar, 2014-02-23
@SolidlSnake

Control chtoli? :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question