39,084
社区成员
发帖
与我相关
我的任务
分享
<canvas id="test" width="700" height="300">浏览器不支持canvas!</canvas>
var test = document.getElementById("test").getContext("2d");
//第一个图形
test.fillStyle = "red";
test.fillStyle = "green";
test.globalCompositeOperation = "source-over";
test.beginPath();
test.arc(100,100,50,0,Math.PI*2);
test.closePath();
test.fill();
//第二个图形
test.fillStyle = "red";
test.fillRect(150,0,100,100);
test.fillStyle = "green";
test.globalCompositeOperation = "destination-over";
test.beginPath();
test.arc(250,100,50,0,Math.PI*2);
test.closePath();
test.fill();
//第三个图形
test.fillStyle = "red";
test.fillRect(300,0,100,100);
test.fillStyle = "green";
test.globalCompositeOperation = "source-atop";
test.beginPath();
test.arc(400,100,50,0,Math.PI*2);
test.closePath();
test.fill();
//第四个图形
test.fillStyle = "red";
test.fillRect(450,0,100,100);
test.fillStyle = "green";
test.globalCompositeOperation = "destination-atop";
test.beginPath();
test.arc(550,100,50,0,Math.PI*2);
test.closePath();
test.fill();