站内搜索: 请输入搜索关键词

当前页面: 开发资料首页Javascript 专题Vml:应用阿基米德算法在网页制作动画,原程+注释

Vml:应用阿基米德算法在网页制作动画,原程+注释

摘要: Vml:应用阿基米德算法在网页制作动画,原程+注释



<head>


网页标题

</head>
<body topmargin='2' leftmargin='2'>


<script>
//原作:风云舞,载自:http://www.lshdic.com/bbs
//以前在VB里很容易利用阿基米德绘图,这次是DHTML版的,VB的下载来http://www.lshdic.com/download/lshdic/vb_xiaoguo.rar
var pos1=0,cos1=0,sin1=0,buchang=1,line1,wid1,hei1,color1 //定义全局变量,为提高运行速度
wid1=a.offsetWidth/2
hei1=a.offsetHeight/2 //预装载宽与高,为提高运行速度
function add1(){
if(pos1==0){buchang=Math.round(Math.random()*5)+1;color1="rgb("+Math.round(Math.random()*255)+","+Math.round(Math.random()*255)+","+Math.round(Math.random()*255)+")"} //初始化时,定义一个随机步长,为达到各种效果
if(pos1<200)pos1+=buchang;else{pos1=0;a.innerHTML="";line1=null;wid1=a.offsetWidth/2;hei1=a.offsetHeight/2} //递加或者初始化
var line1=document.createElement('V:LINE') //创建一条新线段
line1.style.position='absolute'
line1.style.left=wid1
line1.style.top=hei1
line1.strokecolor=color1
line1.to=pos1*Math.cos(pos1)+","+pos1*Math.sin(pos1) //应用阿基米德算法,产生规则角度的线段
a.appendChild(line1);document.title=pos1; //OK,增加线段
}
setInterval('add1();',30) //30毫秒增加一次,注意30毫秒如果超过30条线以上,低于30毫秒对于使用低CPU处理器用户吃不消
</script>
</body>

</td> </tr> <tr> <td vAlign=top align=left height="100%">
↑返回目录
前一篇: 贴一例:当所有图片下载完毕时,然后显示网页(有进度)
后一篇: 利用vml制作统计图全攻略----饼图的制作(一)