当前位置: 首页 > 图文教程 > 网络编程 > Javascript > Vml:应用阿基米德算法在网页制作动画,原程+注释

Javascript
JS 参数传递的实际应用代码分析
prototype与jquery下Ajax实现的差别
用JS写的简单的计算器实现代码
javascript 数组操作实用技巧
JavaScript 中级笔记 第二章
JavaScript 中级笔记 第三章
JavaScript 中级笔记 第四章 闭包
JavaScript 中级笔记 第五章 面向对象的基础
Mootools 1.2教程 函数
Mootools 1.2教程 事件处理
通过Mootools 1.2来操纵HTML DOM元素
Mootools 1.2教程 设置和获取样式表属性
Mootools 1.2教程 输入过滤第一部分(数字)
Mootools 1.2教程 输入过滤第二部分(字符串)
Mootools 1.2教程 Fx.Tween的使用
Mootools 1.2教程 Fx.Morph、Fx选项和Fx事件
MooTools 1.2中的Drag.Move来实现拖放
Mootools 1.2教程 正则表达式
Mootools 1.2教程 定时器和哈希简介
Mootools 1.2教程 滚动条(Slider)

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-10   浏览: 316 ::
收藏到网摘: n/a

<HTML xmlns:v>
<HEAD>
<META http-equiv='Content-Type' content='text/html;charset=gb2312'>
<Meta name='Gemeratpr' content='网络程序员伴侣(Lshdic)2004'>
<TITLE>网页标题</TITLE>
<STYLE>
v\:*{behavior:url(#default#VML);}  //声明变量v为VML对象
*{font-size:12px;color:;}
a{text-decoration:none;}
a:hover{color:red;}
</STYLE>
</HEAD>
<BODY topmargin='2' leftmargin='2'>
<BASE target='_top'>
<div id=a style='table-Layout:fixed;width:100%;height:100%;border:1 solid black'></div>
<script>
 //原作:风云舞,载自:http://www.lshdic.com/bbs
 //以前在VB里很容易利用阿基米德绘图,这次是DHTML版的,VB的下载来http://image.chinaitpower.com/files/20030817/10068.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>
</HTML>