Welcome 微信登录

首页 / 软件开发 / JAVA / Web Chart入门(7) 物理动画效果(如撕扯效果)

Web Chart入门(7) 物理动画效果(如撕扯效果)2013-07-01物理动画

这里物理动画说的是,图形的动画效果和实际生活中的物理效果类似,比如说重力影响的效果。

其实动画的实现就是把一个动作拆分成间隔连续的去完成, 视觉上就感觉是在动的了。

比如把一个图从左边移到右边, 设总距离100的话, 每隔 1/40秒 移到 1 的话,效果就会有了。

这个时间间隔和距离间隔设置多少为最佳,美学上是有一些定义的,这里就不探讨了。

一个拽动和撕扯窗布的例子

三个文件

tearCloth.html ;  tearCloth.css ; tearCloth.js

tearCloth.html

<!--Add by oscar999--><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML><HEAD><TITLE> New Document </TITLE><META NAME="Author" CONTENT="oscar999"><link rel="stylesheet" type="text/css" href="tearCloth.css"/></HEAD><BODY><canvas id = "c" > </canvas><center id="info"><center id="top"><a id="close" href="">close</a></center><p><br>- Tear the cloth with your mouse.<br><br>- Right click and drag to cut the cloth<br><br>- Reduce physics_accuracy if it"s laggy.<br><br></p></center><script src="tearCloth.js"></script></BODY></HTML>