//画圆
function drawcircle(id,x,y,r){
var ca = document.getElementById(id);
var cans = ca.getContext("2d");
cans.globalCompositeOperation = "destination-out";
cans.beginPath();
cans.arc(x,y,r,0,Math.PI*2);
ca.style.display = ‘none’;
ca.offsetHeight;
ca.style.display = ‘inherit’;
cans.fillStyle="#000";
cans.fill();
}
这样可以解决。
本文介绍了一种使用JavaScript在HTML画布上绘制带有透明效果圆形的方法。通过设置全局合成操作和填充样式,实现了一个简单的透明圆形绘制功能。

被折叠的 条评论
为什么被折叠?



