运行 ❯
获取您的
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <body> <h1>The canvas element</h1> <canvas id="myCanvas"> Your browser does not support the canvas tag. </canvas> <script> const c = document.getElementById("myCanvas"); const ctx = c.getContext("2d"); ctx.fillStyle = "red"; ctx.fillRect(20, 20, 75, 50); //Turn transparency on ctx.globalAlpha = 0.2; ctx.fillStyle = "blue"; ctx.fillRect(50, 50, 75, 50); ctx.fillStyle = "green"; ctx.fillRect(80, 80, 75, 50); </script> </body> </html>