好丑啊,哈哈哈!!!
来源:3-9 填充与描边
老姜辣口哦
2017-10-17 23:10:35
<html>
<head>
<meta charset="UTF-8">
<title>canvas</title>
<style>
canvas{background-color:lightblue;}
</style>
</head>
<body>
<canvas id="canvas" width="800" height="800">
您的浏览器不支持canvas
</canvas>
<script>
//在此处写出代码
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
ctx.moveTo(200,50);
ctx.lineTo(300,200);
ctx.moveTo(500,50);
ctx.lineTo(400,200);
ctx.stroke();
ctx.strokeRect(200,200,300,100);
ctx.strokeRect(180,230,20,40);
ctx.strokeRect(500,230,20,40);
ctx.strokeRect(293,260,100,30);
ctx.strokeRect(260,300,180,250);
ctx.strokeRect(60,380,200,30);
ctx.strokeRect(440,380,200,30);
ctx.strokeRect(300,550,20,150);
ctx.strokeRect(380,550,20,150);
ctx.beginPath();
ctx.arc(260,230,15,0,2*Math.PI,true);
ctx.stroke();
ctx.beginPath();
ctx.arc(420,230,15,0,2*Math.PI,true);
ctx.stroke();
</script>
</body>
</html>
1回答
樱桃小胖子
2017-10-18
轮廓实现的很好呀。但是少了颜色填充,再完善一下,将颜色填充一下就不丑了咩,加油~~
相似问题