-2

I have a loop like this using <canvas>:

for (i = 0; i < 1000; i++) { draw_something(); // clears canvas at start of function }

When this runs, nothing happens on the canvas until the loop finishes. The function draw_something is confirmed to work and displays something different each time.

Is there a way to make this draw to the canvas 1000 times? I don't want to use setInterval because I can't know how long draw_something will take.

heptagon
  • 31
  • 4

1 Answers1

0

setTimeout(draw_something, 0) seems to work, as suggested in this thread.

Community
  • 1
  • 1
heptagon
  • 31
  • 4