老师,请检查
来源:4-5 编程练习
phantom0308
2020-08-30 21:28:30
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>canvasL</title> <style> canvas{background-color:lightblue;} </style> </head> <body> <canvas id="canvas" width="600px" height="600px">您的浏览器不支持</canvas> <script> // 在此处写出代码 var canvas = document.getElementById("canvas"); var ctx = canvas.getContext("2d"); // console.log(ctx); ctx.translate(200,300); ctx.rotate(Math.PI / 3); ctx.scale(0.5,0.5); ctx.fillStyle = "#ff0"; ctx.fillRect(100,100,200,300); </script> </body> </html>
1回答
你可以看看这个
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>canvasL</title> <style> canvas{background-color:lightblue;} </style> </head> <body> <canvas id="canvas" width="600px" height="600px">您的浏览器不支持</canvas> <script> var canvas=document.getElementById("canvas"); var context=canvas.getContext("2d"); context.translate(100,200); context.rotate(Math.PI/3); context.scale(0.5,0.5) context.fillStyle="yellow"; context.fillRect(100,100,200,300); </script> </body> </html>