首页 > 其他 > 详细

Canvas学习-1

时间:2014-12-23 13:50:33      阅读:261      评论:0      收藏:0      [点我收藏+]

简单示例


<!DOCTYPE html>
<html>
	<head>
		<style>
			body{
				background: #dddddd;
			}
			#canvas{
				margin:10px;
				padding:10px;
				background: #ffffff;
			}
		</style>
	</head>
	<body>
		<canvas id=‘canvas‘ width=‘600‘ height=‘300‘>
			Canvas not supported
		</canvas>
		<script type="text/javascript">
			var canvas =document.getElementById(‘canvas‘);
			context=canvas.getContext(‘2d‘);
			context.font=‘38pt Arial‘;
			context.fillStyle=‘cornflowerblue‘;
			context.strokeStyle=‘blue‘;
			context.fillText(‘Hello Valentine‘,canvas.width/2-150,canvas.height/2+15);
			context.fillStroke(‘Hello Valentine‘,canvas.width/2-150,canvas.height/2+15);
		</script>
	</body>
	<footer></footer>
</html>

注意:canvas默认大小为300*150像素

Canvas学习-1

原文:http://www.cnblogs.com/valentineisme/p/4179907.html

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