<!doctype html>
<html>
<head>
<!--canvas画矩形-->
<style>
#huaban{
border:1px solid;
}
</style>
<script>
</script>
<meta charset="UTF-8">
</head>
<body>
<canvas width="200" height="200" id="huaban">
</canvas>
<script>
var can=document.getElementById("huaban");//获得画板数据
var con=can.getContext('2d');//获得笔刷
con.fillStyle="red";//设置填充颜色
con.strokeStyle="blue";//设置线条颜色
con.fillRect(10,10,100,100);//填充画矩形
con.strokeRect(100,100,200,200);//线条画矩形
</script>
</body>
</html>
HTMLcanvas画矩形
最新推荐文章于 2024-10-18 12:27:51 发布