且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

删除HTML5画布上以前绘制的线条

更新时间:2023-11-23 23:13:10

由于我可以扩展的原因,你应该考虑清除你的画布并重新绘制它,除非有性能或合成的原因不这样做。

For reasons that I could expand upon, you should consider clearing your canvas and redrawing it entirely unless there are performance or compositing reasons not to.

你想 clearRect ,如下所示:

//clear the canvas so we can draw a fresh clock
ctx.clearRect(0, 0, canvasWidth, canvasHeight);

//redraw your clock here
/* ... */