8-12 canvas专题-阶段练习一(上)

8-12 canvas专题-阶段练习一(上)

 

 

 1 <!DOCTYPE html>
 2 <html lang="zh-cn">
 3 <head>
 4     <meta charset="UTF-8">
 5     <title>8-12 课堂演示</title>
 6 </head>
 7 <style type="text/css">
 8 
 9 </style>
10 <body>
11     <canvas id="canvas" width="800" height="600" style="background: #A9A9A9">
12             很抱歉,您的浏览器暂不支持HTML5的canvas
13     </canvas>
14     <script>
15         var c=document.getElementById("canvas");
16         var ctx=c.getContext("2d");
17         ctx.lineWidth=5;
18         ctx.strokeStyle="orange";
19         ctx.fillStyle="red";
20         var i=0;
21         function rotRect(){
22             i++
23             ctx.save()
24             ctx.clearRect(0,0,c.width,c.height)
25             ctx.translate(c.width/2,c.height/2);
26             ctx.rotate(i*15*Math.PI/180)
27             ctx.strokeRect(0,0,100,100)
28             ctx.fillRect(0,0,100,100)
29             ctx.restore()
30         }
31 
32         setInterval('rotRect()',500)
33     </script>
34 </body>
35 </html>

 

转载于:https://www.cnblogs.com/Renyi-Fan/p/8098202.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值