我有一个带有蓝色轮廓的圆弧,然后使用全局复合操作符"destination- out“覆盖了圆弧的一部分,导致部分圆弧被取消/切断,但这使得新形状的一部分没有轮廓,有什么简单的方法可以重新建立形状的轮廓吗?
可在此处找到工作示例:http://jsfiddle.net/NY2up/

var ctx = document.getElementById("display").getContext('2d');
ctx.beginPath();
ctx.arc(100, 100, 50, 0.0, 1.5, false);
ctx.lineTo(100, 100);
ctx.closePath();
ctx.fillStyle = 'red'
ctx.fill();
ctx.strokeStyle = 'blue';
ctx.lineWidth = 5;
ctx.stroke();
ctx.globalCompositeOperation = "destination-out";
ctx.beginPath();
ctx.arc(100, 100, 20, 0, Math.PI*2, true);
ctx.fill();
ctx.closePath();
发布于 2012-12-06 05:18:47
我所做的是将globalComposition重新设置为source-over,并在该点上划出一条部分弧线以获得效果。
ctx.beginPath();
ctx.arc(100, 100, 50, 0.0, 1.5, false);
ctx.lineTo(100, 100);
ctx.closePath();
ctx.fillStyle = 'red'
ctx.fill();
ctx.strokeStyle = 'blue';
ctx.lineWidth = 5;
ctx.stroke();
ctx.globalCompositeOperation = "destination-out";
ctx.beginPath();
ctx.arc(100, 100, 20, 0, Math.PI*2, true);
ctx.fill();
ctx.closePath();
// reset the global comp and draw a partial arc with the proper radians.
ctx.globalCompositeOperation = "source-over";
ctx.beginPath();
ctx.arc(100, 100, 20, 1.61,-0.11, true);
ctx.stroke();
ctx.closePath();
发布于 2012-12-06 01:19:52
我想你可以在画布上画第三个弧线
https://stackoverflow.com/questions/13727928
复制相似问题