canvas绘制两个位置、形状完全相同的三角形,当globalCompositeOperation = ‘xor' 时,斜线没有变透明?有办法让其变透明吗?
`<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
canvas
{
border:1px solid #d3d3d3; margin-right:10px; margin-bottom:20px;
}
</style>
</head>
<body>
<script>
var gco=new Array();
gco.push("source-atop");
gco.push("source-in");
gco.push("source-over");
gco.push("destination-atop");
gco.push("destination-in");
gco.push("destination-over");
gco.push("lighter");
gco.push("copy");
gco.push("xor");
for (n=0;n<gco.length;n++)
{
document.write("<div id='p_" + n + "' style='float:left;'>" + gco[n] + ":<br>"); var c=document.createElement("canvas"); c.width=120; c.height=100; document.getElementById("p_" + n).appendChild(c); var ctx=c.getContext("2d"); ctx.beginPath(); ctx.fillStyle="blue"; ctx.moveTo(50, 50); ctx.lineTo(10, 50); ctx.lineTo(10, 10); ctx.fill(); ctx.globalCompositeOperation=gco[n]; ctx.beginPath(); ctx.fillStyle="red"; ctx.moveTo(50, 50); ctx.lineTo(10, 50); ctx.lineTo(10, 10); ctx.fill(); document.write("</div>");
}
</script>
</body>
</html>`
待解决
悬赏分:10
- 离问题结束还有 158天22小时16分38秒
点赞 0反对 0举报 0
收藏 0
分享 0
