首页 > 其他 > 详细

第24章 canvas绘制矩形

时间:2015-12-01 02:10:35      阅读:264      评论:0      收藏:0      [点我收藏+]

html

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script type="text/javascript" src="24.js"></script>
<style type="text/css">
body{ margin:0; padding:0;}
</style>
</head>
<body onBlur="draw(‘canvas‘);">
<canvas id="canvas" width="400" height="300"></canvas>
</body>
</html>

?

js

// JavaScript Document
function draw(id){
    var canvas = document.getElementById(id);
    var context = canvas.getContext(‘2d‘);
    context.fillStyle = "green";
    context.strokeStyle = "#fff";
    context.lineWidth = 5;
    context.fillRect(0,0,400,300);
    context.strokeRect(50,50,180,120);
    context.strokeRect(110,110,180,120);
}

?

效果图:
bubuko.com,布布扣
?

?

?

?

?

?

第24章 canvas绘制矩形

原文:http://onestopweb.iteye.com/blog/2260599

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