首页 > 编程语言 > 详细

每天一个JavaScript实例-canvas画图

时间:2014-11-03 14:36:20      阅读:149      评论:0      收藏:0      [点我收藏+]
<!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,.1)";
		ctx.strokeStyle = "#000";
		//第一个
		ctx.fillRect(0,0,100,100);
		ctx.strokeRect(0,0,100,100);
		//第二个
		ctx.fillRect(50,50,100,200);

		//第三个
		ctx.strokeRect(80,130,200,100);
	}
}
</script>

</head>

<body>

<canvas class="canvas" id = "imgcanvas">
<p>画布</p>
	
</canvas>

</body>
</html>

每天一个JavaScript实例-canvas画图

原文:http://blog.csdn.net/waiting7436/article/details/40740311

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!