这样对的吗
来源:3-8 编程练习
Ting111
2020-07-02 16:01:00
<!DOCTYPE html> <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 content=canvas.getContext('2d'); //天线1 content.moveTo(200,50); content.lineTo(250,150) content.stroke(); //天线2 content.beginPath(); content.moveTo(350,50); content.lineTo(300,150); content.stroke(); //头 content.beginPath(); content.strokeRect(180,150,200,100); //左耳 content.beginPath(); content.strokeRect(160,180,20,40); //右耳 content.beginPath(); content.strokeRect(380,180,20,40); //左眼 content.beginPath(); content.arc(240,180,10,0,2*Math.PI); content.stroke(); //右眼 content.beginPath(); content.arc(320,180,10,0,2*Math.PI); content.stroke(); //嘴巴 content.beginPath(); content.strokeRect(260,210,40,20); //身体 content.beginPath(); content.strokeRect(235,250,90,150); //左手 content.beginPath(); content.strokeRect(36,280,200,20); //右手 content.beginPath(); content.strokeRect(326,280,200,20); //左腿 content.beginPath(); content.strokeRect(260,400,10,180); //右腿 content.beginPath(); content.strokeRect(290,400,10,180); </script> </body> </html>
1回答
好帮手慕码
2020-07-02
同学你好,总体是正确的。可再优化:
祝学习愉快~
相似问题