clearing circular regions from HTML5 Canvas

后端 未结 6 1059
耶瑟儿~
耶瑟儿~ 2020-11-30 01:37

It appears the only way to clear a region from a canvas is to use the clearRect() command - I need to clear a circle (I am masking out areas from a filled canvas, point ligh

6条回答
  •  悲哀的现实
    2020-11-30 02:20

    Use canvas.getContext("2d").arc(...) to draw a circle over the area with the background colour?

    var canvas = document.getElementById("myCanvas");
    var context = canvas.getContext("2d");
    context.arc(x, y, r, 0, 2*Math.PI, false);
    context.fillStyle = "#FFFFFF";
    context.fill();
    

提交回复
热议问题