正弦曲线及其波动02

<html xmlns:v="urn:schemas-microsoft-com:vml">

<head>
<meta http-equiv=Content-Type content="text/html; charset=GB2312">

<style>
v/:* {behavior:url(#default#VML);}
o/:* {behavior:url(#default#VML);}
x/:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
 
<xml>
 <o:shapedefaults v:ext="edit" spidmax="1027"/>
</xml>

<xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1"/>
 </o:shapelayout></xml>
</head>

<body>
<p οnclick=movetox()>A Sin waving Circle...
<script>

//由width:10pt;height:10pt; 控制圆的大小

 var r = 20;
  var pi = Math.PI;
 var aa = 0;
 var a=0;
 var str = "";
 var fillcolor="#FF0000";
 var strokecolor="#FF0000";
 for(var a0=0;a0<=1440*2;a0=a0+10){
  aa = 4 * (a + a0) * pi / 1440;
  kx=2+a0*1/3;
  ky=250 + 180 * Math.sin(aa);
  str = str +"<v:oval id='_glc0"+a0+"' ";
  str = str +"style='position:absolute;left:"+kx+"px;top:"+ky+"px;width:2px;height:2px;z-index:1;cursor:move' ";
  str = str +"fillcolor='"+fillcolor+"' strokecolor='"+strokecolor+"' strokeweight='2px' strokecolor='windowText [64]'/>";
 }
 document.write(str);

function movetox() {
 theTime = setTimeout("movetox()", 200);
 var today = new Date();

 var display= today.toLocaleString();
 status=""+a+"-"+display;
 for(var jj=0;jj<=1440*2;jj=jj+10){
  obj2=eval("_glc0"+jj);
  ab = 4 * (a + jj) * pi / 1440;
  var yy=250 + 180 * Math.sin(ab);
  obj2.fillcolor=getrandomcolor();
//  obj2.strokecolor=getrandomcolor();
  obj2.style.top=yy;
 }
 if(a>=1440*1) a = 0;
 a=a+10;

}


//var x;
//x=getrandomcolor();

function getrandomcolor()
{
 var r1,r2,r3;
 r1=Math.round((Math.random()*256));
 r2=Math.round((Math.random()*256));
 r3=Math.round((Math.random()*256));

// document.write("随机数:"+r1+"."+r2+"."+r3);
// document.write("<br>");

 return "#"+prefixzero(r1.toString(16),2,1)+prefixzero(r2.toString(16),2,1)+prefixzero(r3.toString(16),2,1);

}

//按要求的宽度输出字串,另上前缀零:
//
//flag: 1 - 如strg的宽度大于wdth,则输出strg (缺省)
//      2 - 如strg的宽度大于wdth,则输出前wdth个字符的strg
//      3 - 如strg的宽度大于wdth,则输出后wdth个字符的strg

function prefixzero(strg,wdth,flag)
{
 var zero ="000000000000000000000000000";

 var slen=strg.length;
 var zlen=zero.length;
 var prez;

 if (slen>=wdth) {
  if (flag == 2) {
   return strg.substring(0, wdth)
  } else if (flag == 3) {
   return strg.substring(slen-wdth, slen)
  } else       //if (flag == 1)
  {
   return strg;
  }
 } else {
  prez = zero.substring(0, wdth-slen)
  return prez + strg;
 }
}

</script>
</body>
</html> 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值