canvas制作螺旋塔罗牌效果

tech2024-12-25  17

<!DOCTYPE html> <html> <head> <meta http-equiv = "content-type" content = "text/html" charset = "utf-8"/> <title> 塔罗牌 </title> <script> window.onload=function(){ var canvas=document.getElementById('canvas'); var cx=canvas.getContext("2d"); cx.translate(220,30); cx.fillStyle='rgba(255, 0, 0, 0.25)'; for (var i = 0; i < 50; i++) { //图形向左、向下各移动25 cx.translate(25, 25); //图形缩放 cx.scale(0.95, 0.95); //图形旋转 cx.rotate(Math.PI/10); cx.fillRect(0, 0, 100, 50); } } </script> </head> <body> <canvas id="canvas" width="400px" height="300px" style="background-color: rgb(223, 199, 199);"></canvas> </body> </html>

效果图如下:

最新回复(0)