<!DOCTYPE HTML> <html> <head> <object id="WebBrowser" width=0 height=0 classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></object> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> (function(){ var canvas=null, context=null, angle=0; num=0; value=1; function resetCanvas(){ canvas=document.getElementById("simple"); canvas.width=window.innerWidth; canvas.height=window.innerHeight; context=canvas.getContext("2d"); } function animate(){ context.save(); try{ //清除画布 context.clearRect(0, 0, canvas.width, canvas.height); if(num==100){ value=-1; } else if(num==0) { value=1; } num +=value; context.scale(num*1/50,num*1/50) //设置原点 context.translate(canvas.width * 0.5, canvas.height * 0.5); //旋转角度 context.rotate(angle); //设置填充颜色 context.fillStyle = "#FF0000"; //绘制矩形 context.fillRect(0, 0, 100, 100); angle += 0.05 * Math.PI; } finally{ context.restore(); } } //当窗口改变时 $(window).bind("resize",resetCanvas).bind("reorient",resetCanvas); $(document).ready(function(){ window.scrollTo(0,1); resetCanvas(); setInterval(animate,40); }); })(); </script> </script> </head> <body> <canvas id="simple"></canvas> </body> </html>
详细解决方案
Html5学习-运动且旋转并放大缩小的卡通效果
热度:99 发布时间:2012-11-08 08:48:11.0
相关解决方案
- HTML5 3D图,该怎么解决
- html5+.net联合开发的有关问题
- HTML5 离线效能详解 - 构建 Offline Web Application
- HTML5,该如何解决
- HTML5/CSS3培训课程
- html5 上传适用小例子
- HTML5+CSS3课程2
- HTML5 Canvas实战――HTML5 Canvas时间成效
- HTML5-audio跟video API
- HTML5-札记
- html5 小技能
- html5 div呈圆形 扇形显示的式样
- HTML5+CSS3制作可自动获得焦点和支持语音输入的超酷搜索框
- HTML5+CSS3制造可自动获得焦点和支持语音输入的超酷搜索框
- html5 chm 相助文档
- html5 输入框默许提示
- html5 本土存储 留言板
- html5 初探二 表单
- html5 input的type属性起动数字输入法
- html5-canvas篇
- HTML5-话音搜索框
- html5 placeholder 属性 并检测浏览器是不是支持这个属性
- HTML5 装置访问入门
- What does idl attribute mean in the W3C html5 standard document
- HTML5 入门稿件目录汇总
- html5 svg 中元素点击事件平添
- html5 canvas 画图形,改变填充颜色解决思路
- html5 canvas做手写签名,该如何解决
- html5 canvas 里边绘制标题 和阴影
- HTML5 拖拽下传图片实例