<body>
<script>
/**通过 rect() 方法来创建三个矩形**/
var c=document.createElement("canvas");
document.body.appendChild(c);
var ctx=c.getContext("2d");
// 红色矩形
ctx.beginPath();
ctx.lineWidth="6";
ctx.strokeStyle="red";
ctx.rect(5,5,140,140);
ctx.stroke();
// 绿色矩形
ctx.beginPath();
ctx.lineWidth="4";
ctx.strokeStyle="green";
ctx.rect(30,30,50,50);
ctx.stroke();
// 蓝色矩形
ctx.beginPath();
ctx.lineWidth="10";
ctx.strokeStyle="blue";
ctx.rect(50,50,150,80);
ctx.stroke();
</script>
</body>
JavaScript网页绘图(一)
最新推荐文章于 2022-12-10 23:37:43 发布