How can I clear an arc or circle in HTML5 canvas?

后端 未结 6 1977
谎友^
谎友^ 2021-02-04 02:06

I found that there\'s a clearRect() method, but can\'t find any to clear an arc (or a full circle).

Is there any way to clear an arc in canvas?

6条回答
  •  迷失自我
    2021-02-04 02:42

    Here's an updated fiddle for you too (uses clearRect): https://jsfiddle.net/x9ztn3vs/2/

    It has a clearApple function:

    block.prototype.clearApple = function() {
        ctx.beginPath();
        ctx.clearRect(this.x - 6, this.y - 6, 2 * Math.PI, 2 * Math.PI);
        ctx.closePath();
    }
    

提交回复
热议问题