代码很简单,稍微会点canvas的应该就可以看懂
<html lang="en-US">
<canvas id=myCanvas width=500px height=400px></canvas>
<script>
var myCanvas = document.getElementById("myCanvas");
var context = myCanvas.getContext("2d");
context.fillStyle = "red";
context.fillRect(50,50,100,100);
context.fillStyle = "rgba(0,0,255,0.4)";
context.fillRect(80,80,100,100);
context.fill();
</script>
</html>
