HTML5 Remove previous drawn object in canvas

后端 未结 2 1504
刺人心
刺人心 2020-12-17 19:01

I have a polygon object (say a car) drawn inside a HTML5 canvas with help of methods moveTo and lineTo. I want to repeatedly draw that object at di

2条回答
  •  旧巷少年郎
    2020-12-17 19:17

    You have to clear the canvas at the start of every draw frame

    context.clearRect(0, 0, canvas.width, canvas.height);
    

提交回复
热议问题