运行 ❯
获取您
自己
的网站
×
更改方向
保存代码
更改主题,暗/亮
前往 Spaces
<!DOCTYPE html> <html> <body> <h1>HTML5 Canvas setTransform()</h1> <canvas id="myCanvas" width="300" height="300" style="border:1px solid grey"> Sorry, your browser does not support canvas. </canvas> <script> const canvas = document.getElementById("myCanvas"); const ctx = canvas.getContext("2d"); ctx.fillStyle = "yellow"; ctx.fillRect(10, 10, 200, 100) ctx.setTransform(1, 0.5, -0.5, 1, 30, 10); ctx.fillStyle = "red"; ctx.fillRect(10, 10, 200, 100); ctx.setTransform(1, 0.5, -0.5, 1, 30, 10); ctx.fillStyle = "blue"; ctx.fillRect(10, 10, 200, 100); </script> </body> </html>