老师,请检查
来源:3-8 编程练习
慕函数4436287
2019-06-05 11:23:51
<!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 canvas=document.getElementById("canvas"); var ctx=canvas.getContext("2d"); ctx.moveTo(295,40); ctx.lineTo(355,180); ctx.stroke(); ctx.beginPath(); ctx.moveTo(505,40); ctx.lineTo(430,180); ctx.stroke(); ctx.beginPath(); ctx.strokeRect(280, 180, 240, 135); ctx.beginPath(); ctx.strokeRect(255, 205, 25, 55); ctx.beginPath(); ctx.strokeRect(520, 205, 25, 55); ctx.beginPath(); ctx.strokeRect(370, 270, 55, 25); ctx.beginPath(); ctx.arc(340, 235, 13, 0, Math.PI * 2, true); ctx.stroke(); ctx.beginPath(); ctx.arc(450, 235, 13, 0, Math.PI * 2, true); ctx.stroke(); ctx.beginPath(); ctx.strokeRect(120, 400, 205, 25); ctx.beginPath(); ctx.strokeRect(325, 315, 140, 205); ctx.beginPath(); ctx.strokeRect(465, 400, 205, 25); ctx.beginPath(); ctx.strokeRect(350, 520, 25, 205); ctx.beginPath(); ctx.strokeRect(415, 520, 25, 205); </script> </body> </html>
1回答
好帮手慕夭夭
2019-06-05
你好同学,实现的非常棒,继续加油,祝学习愉快!