11th Apr 2021, 2:11 AM
Michael
Michael - avatar
3 Respuestas
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
11th Apr 2021, 8:40 AM
Giorgos
0
Giorgos Dim can I have example code
12th Apr 2021, 8:56 AM
Michael
Michael - avatar