【发布时间】:2016-06-22 04:31:20
【问题描述】:
我从 W3S 尝试了下面的代码 他们说蓝色矩形是源,红色矩形是目的地,我想知道他们是如何确定的,是订单还是其他??
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.fillStyle="red";
ctx.fillRect(20,20,75,50);
ctx.globalCompositeOperation="source-over";
ctx.fillStyle="blue";
ctx.fillRect(50,50,75,50);
ctx.fillStyle="red";
ctx.fillRect(150,20,75,50);
ctx.globalCompositeOperation="destination-over";
ctx.fillStyle="blue";
ctx.fillRect(180,50,75,50);
【问题讨论】:
-
你画的东西就是你画的时候的来源。你画的是目的地。如果您稍后在源上绘制,源将成为目标,并且目标甚至可以成为源;-)
标签: html canvas globalcompositeoperation