时间:2014-11-04 来源: 每天一个JavaScript实例-canvas画图【系统运维】
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>每天一个JavaScript实例-canvas画图</title>
<style>
.canvas{
width:600px;
height:500px;
}
</style>
<script>
window.onload = function(){
var imgcanvas = document.getElementById("imgcanvas");
if(imgcanvas.getContext){
var ctx = imgcanvas.getContext('2d');
ctx.fillStyle="rgba(255,0,0,100);
ctx.strokeRect(0,100,50,200);
//第三个
ctx.strokeRect(80,200,100);
}
}
</script>
</head>
<body>
<canvas class="canvas" id = "imgcanvas">
<p>画布</p>
</canvas>
</body>
</html>
作者: