案例:html/html5 案例     状态:可编辑再运行    进入竖版
 运行结果 
x
 
1
<!DOCTYPE html>
2
<html>
3
<body>
4
5
<canvas id="myCanvas" width="300" height="150" style="border:1px solid #d3d3d3;">
6
Your browser does not support the HTML5 canvas tag.
7
</canvas>
8
9
<script>
10
11
var c=document.getElementById("myCanvas");
12
var ctx=c.getContext("2d");
13
ctx.fillStyle="red";
14
ctx.fillRect(20,20,75,50);
15
ctx.fillStyle="blue";   
16
ctx.globalCompositeOperation="source-over";
17
ctx.fillRect(50,50,75,50);  
18
ctx.fillStyle="red";
19
ctx.fillRect(150,20,75,50);
20
ctx.fillStyle="blue";   
21
ctx.globalCompositeOperation="destination-over";
22
ctx.fillRect(180,50,75,50); 
23
24
</script>
25
26
</body>
27
</html>
28