How to clear the canvas for redrawing

后端 未结 23 2818
粉色の甜心
粉色の甜心 2020-11-21 11:37

After experimenting with composite operations and drawing images on the canvas I\'m now trying to remove images and compositing. How do I do this?

I need to clear th

23条回答
  •  温柔的废话
    2020-11-21 12:19

    I always use

    cxt.fillStyle = "rgb(255, 255, 255)";
    cxt.fillRect(0, 0, canvas.width, canvas.height);
    

    For a custom color, and

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

    For making the canvas transparent when clearing

提交回复
热议问题