Whenever I draw something in the canvas using the setinterval() function, the things repeat.how can I remove the last drawnShape | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Whenever I draw something in the canvas using the setinterval() function, the things repeat.how can I remove the last drawnShape

Javascript html5 canvas algorithms

20th Jul 2019, 8:59 AM
BASIL YISUF
BASIL YISUF - avatar
4 Answers
+ 2
You can clear the entire canvas with this function: ctx.clearRect(0, 0, <canvasWidth>, <canvasHeight>);
20th Jul 2019, 9:05 AM
Airree
Airree - avatar
+ 1
You need to store the line's properties in VARIABLES
20th Jul 2019, 10:02 AM
Airree
Airree - avatar
0
For example I drew a line and gave it a velocity. I want the line to look as if it's falling down. But it continues drawing from the last location. What should I do so that it draws again from the new location?
20th Jul 2019, 9:07 AM
BASIL YISUF
BASIL YISUF - avatar
0
Okay THANKS
20th Jul 2019, 10:07 AM
BASIL YISUF
BASIL YISUF - avatar