0
Plz help fix the bug
3 Answers
0
The problem is that u are change the canvas width/height on every loop inside setInterval(). This causes it to clear it everytime, effectively allowing only one rect to be shown since the other gets cleared.
Move ur canvas/ctx initialization to the onload() so u only do this once.
Also i would suggest to use requestAnimationFrame() instead of setInterval() for animating things
0
Giorgos Dim can I have example code