1
<canvas id="myCanvas" width="300" height="150" style="border:1px solid #d3d3d3;">
2
您的浏览器不支持 HTML5 canvas 标签。
3
</canvas>
4
<script>
5
var c = document.getElementById("myCanvas");
6
var ctx = c.getContext("2d");
7
ctx.shadowBlur = 20;
8
ctx.fillStyle = "red";
9
ctx.shadowColor = "black";
10
ctx.fillRect(20, 20, 100, 80);
11
ctx.shadowColor = "blue";
12
ctx.fillRect(140, 20, 100, 80);
13
</script>