Javascript/jQuery: remove shape/path from canvas

前端 未结 8 1137
离开以前
离开以前 2021-02-19 05:34

I can\'t seem to find the function to remove a shape or path from the canvas after it has been created.

So I\'m creating a bezier curve between 2 points with

<         


        
相关标签:
8条回答
  • 2021-02-19 06:00

    You can't remove a path/shape from the canvas. You can draw something else over it or clear the canvas.

    0 讨论(0)
  • 2021-02-19 06:06

    Try this:

    ctx.save();
    ctx.globalCompositeOperation = "destination-out";
    // drawing here you path second time
    ctx.restore();
    

    "The globalCompositeOperation attribute sets how shapes and images are drawn onto the scratch bitmap" specs

    How it works you can see here.

    0 讨论(0)
提交回复
热议问题