[ html 绘图 strokeRect() fillRect() clearRect() ] canvas绘图strokeRect() fillRect() clearRect() 实例演示
<!DOCTYPE html>
<html lang='zh-cn'>
<head>
<title>Insert you title</title>
<meta name='description' content='this is my page'>
<meta name='keywords' content='keyword1,keyword2,keyword3'>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type='text/javascript' src='./js/jquery-1.12.1.min.js'></script>
<style type='text/css'>
html,body,canvas{margin:0;padding:0;}
canvas{background:#FFF;display:block;margin:75px auto;border-radius:2px;}
html{background:#000;}
</style>
<script type="text/javascript">
$(function(){
var oCan = $('#can').get(0).getContext('2d');
oCan.beginPath();
oCan.strokeStyle = '#F00';
oCan.lineWidth = 20;
oCan.fillStyle = '#00F';
oCan.strokeRect( 210,130 ,80,90);
oCan.fillRect(220,140,60,70);
//oCan.clearRect(210,130,50,50); /* 清除的原点就是 " 画布 " 的原点(起始点) */
oCan.closePath();
});
</script>
</head>
<body>
<canvas width='500' height='350' id='can'>您的浏览器版本过低,请您更换浏览器后重试...</canvas>
</body>
</html>