|γ^0^γ|知足者常乐|γ^0^γ|

歪酷博客


面对E个残酷嘅世界
需要乐观
态度
你呢?
To face the HARSH REALITY, Optimism
, for me, is needed.And you?

« 上一篇: 体验无线上网... 下一篇: 攰... »
常乐 @ 2005-08-22 16:23

即喺你E家见倒喺你只MOUSE后面跟住嗰串有人会觉得好烦...但喺我又好鬼死中意嘅嘢...

<SCRIPT language=JavaScript>
dCol='66FF00';//date colour.
fCol='FF6600';//face colour.
sCol='660099';//seconds colour.
mCol='3366FF';//minutes colour.
hCol='569923';//hours colour.
gCol='0099FF';//I love sissy 嗰串嘢嘅 colour.
ClockHeight=40;//钟高.
ClockWidth=40;//钟宽.
ClockFromMouseY=80;//钟中心离MOUSE嘅纵坐标.
ClockFromMouseX=80;//钟中心离MOUSE嘅横坐标.
//Alter nothing below! Alignments will be lost!(E条警告可以当渠傻嘅)
d=new Array//创建日期数组.("SUNDAY","MONDAY","TUESDAY","WEDNESDAY","THURSDAY","FRIDAY","SATURDAY");
m=new Array//创建月份数组.("JANUARY","FEBRUARY","MARCH","APRIL","MAY","JUNE","JULY","AUGUST","SEPTEMBER","OCTOBER","NOVEMBER","DECEMBER");
date=new Date();//获取日期.
day=date.getDate();
year=date.getYear();
if (year < 2000) year=year+1900;
TodaysDate=" "+d[date.getDay()]+" "+day+" "+m[date.getMonth()]+" "+year;//(日期栏显示格式)
D=TodaysDate.split('');//数组间隔.
H='...';//时、分、秒针样式
H=H.split('');
M='....';
M=M.split('');
S='.....';
S=S.split('');
T='I Love Sissy ';//字符串.(可更换你想讲嘅嘢嘅地方...支持中文...此部分为我自制...大家亦都可以学我加多几行...不过可能D人会更加烦...呵呵...)
T=T.split('');
Face='1 2 3 4 5 6 7 8 9 10 11 12';//钟面.
font='Arial';//钟面字体.(想换字体就换''号入面嘅嘢,例:font='宋体',但初哥最好换个变量储存...)
size=3;//字体大小.
speed=0.6;//拉动时速.
ns=(document.layers);//好似浏览器类型唔同...有唔同算法...NS之喺以前嗰同IE争得好劲嗰只Netscape.
ie=(document.all);
Face=Face.split(' ');
n=Face.length;
a=size*10;
ymouse=0;
xmouse=0;
scrll=0;
props="<font face="+font+" size="+size+" color="+fCol+"><B>";
props2="<font face="+font+" size="+size+" color="+dCol+"><B>";
props3="<font face="+font+" size="+size+" color="+gCol+"><B>";
Split=360/n;
Dsplit=360/D.length;
Tsplit=360/T.length;
HandHeight=ClockHeight/4.5
HandWidth=ClockWidth/4.5
HandY=-7;
HandX=7;
scrll=0;
step=0.015;//顺时针转速.
rstep=0.03;//逆时针转速
currStep=0;
rigStep=0;//以下为层算法.
y=new Array();x=new Array();Y=new Array();X=new Array();
for (i=0; i < n; i++){y=0;x=0;Y=0;X=0}
Dy=new Array();Dx=new Array();DY=new Array();DX=new Array();
for (i=0; i < D.length; i++){Dy=0;Dx=0;DY=0;DX=0}
Ty=new Array();Tx=new Array();TY=new Array();TX=new Array();
for (i=0; i < T.length; i++){Ty=0;Tx=0;TY=0;TX=0}
if (ns){
for (i=0; i < T.length; i++)
document.write('<layer name="nsDate'+i+'" top=0 left=0 height='+a+' width='+a+'><center><b>'+props3+T+'</b></font></center></layer>');
for (i=0; i < D.length; i++)
document.write('<layer name="nsDate'+i+'" top=0 left=0 height='+a+' width='+a+'><center>'+props2+D+'</font></center></layer>');
for (i=0; i < n; i++)
document.write('<layer name="nsFace'+i+'" top=0 left=0 height='+a+' width='+a+'><center>'+props+Face+'</font></center></layer>');
for (i=0; i < S.length; i++)
document.write('<layer name=nsSeconds'+i+' top=0 left=0 width=15 height=15><font face=Arial size=3 color='+sCol+'><center><b>'+S+'</b></center></font></layer>');
for (i=0; i < M.length; i++)
document.write('<layer name=nsMinutes'+i+' top=0 left=0 width=15 height=15><font face=Arial size=3 color='+mCol+'><center><b>'+M+'</b></center></font></layer>');
for (i=0; i < H.length; i++)
document.write('<layer name=nsHours'+i+' top=0 left=0 width=15 height=15><font face=Arial size=3 color='+hCol+'><center><b>'+H+'</b></center></font></layer>');
}
if (ie){
document.write('<div id="Ot" style="position:absolute;top:0px;left:0px"><div style="position:relative">');
for (i=0; i < T.length; i++)
document.write('<div id="Text" style="position:absolute;top:0px;left:0;height:'+a+';width:'+a+';text-align:center">'+props3+T+'</B></font></div>');
document.write('</div></div>');
document.write('<div id="Od" style="position:absolute;top:0px;left:0px"><div style="position:relative">');
for (i=0; i < D.length; i++)
document.write('<div id="ieDate" style="position:absolute;top:0px;left:0;height:'+a+';width:'+a+';text-align:center">'+props2+D+'</B></font></div>');
document.write('</div></div>');
document.write('<div id="Of" style="position:absolute;top:0px;left:0px"><div style="position:relative">');
for (i=0; i < n; i++)
document.write('<div id="ieFace" style="position:absolute;top:0px;left:0;height:'+a+';width:'+a+';text-align:center">'+props+Face+'</B></font></div>');
document.write('</div></div>');
document.write('<div id="Oh" style="position:absolute;top:0px;left:0px"><div style="position:relative">');
for (i=0; i < H.length; i++)
document.write('<div id="ieHours" style="position:absolute;width:16px;height:16px;font-family:Arial;font-size:16px;color:'+hCol+';text-align:center;font-weight:bold">'+H+'</div>');
document.write('</div></div>');
document.write('<div id="Om" style="position:absolute;top:0px;left:0px"><div style="position:relative">');
for (i=0; i < M.length; i++)
document.write('<div id="ieMinutes" style="position:absolute;width:16px;height:16px;font-family:Arial;font-size:16px;color:'+mCol+';text-align:center;font-weight:bold">'+M+'</div>');
document.write('</div></div>')
document.write('<div id="Os" style="position:absolute;top:0px;left:0px"><div style="position:relative">');
for (i=0; i < S.length; i++)
document.write('<div id="ieSeconds" style="position:absolute;width:16px;height:16px;font-family:Arial;font-size:16px;color:'+sCol+';text-align:center;font-weight:bold">'+S+'</div>');
document.write('</div></div>')
}
(ns)?window.captureEvents(Event.MOUSEMOVE):0;
function Mouse(evnt){
ymouse = (ns)?evnt.pageY+ClockFromMouseY-(window.pageYOffset):event.y+ClockFromMouseY;
xmouse = (ns)?evnt.pageX+ClockFromMouseX:event.x+ClockFromMouseX;
}//获取MOUSE位置并计算出钟中心实际位置嘅算法.
(ns)?window.onMouseMove=Mouse:document.onmousemove=Mouse;
function ClockAndAssign(){
time = new Date ();
secs = time.getSeconds();
sec = -1.57 + Math.PI * secs/30;
mins = time.getMinutes();
min = -1.57 + Math.PI * mins/30;
hr = time.getHours();
hrs = -1.57 + Math.PI * hr/6+Math.PI*parseInt(time.getMinutes())/360;
if (ie){
Ot.style.top=window.document.body.scrollTop;
Od.style.top=window.document.body.scrollTop;
Of.style.top=window.document.body.scrollTop;
Oh.style.top=window.document.body.scrollTop;
Om.style.top=window.document.body.scrollTop;
Os.style.top=window.document.body.scrollTop;
}
for (i=0; i < n; i++){
var F=(ns)?document.layers['nsFace'+i]:ieFace.style;
F.top=y + ClockHeight*Math.sin(-1.0471 + i*Split*Math.PI/180)+scrll;
F.left=x + ClockWidth*Math.cos(-1.0471 + i*Split*Math.PI/180);
}
for (i=0; i < H.length; i++){
var HL=(ns)?document.layers['nsHours'+i]:ieHours.style;
HL.top=y+HandY+(i*HandHeight)*Math.sin(hrs)+scrll;
HL.left=x+HandX+(i*HandWidth)*Math.cos(hrs);
}
for (i=0; i < M.length; i++){
var ML=(ns)?document.layers['nsMinutes'+i]:ieMinutes.style;
ML.top=y+HandY+(i*HandHeight)*Math.sin(min)+scrll;
ML.left=x+HandX+(i*HandWidth)*Math.cos(min);
}
for (i=0; i < S.length; i++){
var SL=(ns)?document.layers['nsSeconds'+i]:ieSeconds.style;
SL.top=y+HandY+(i*HandHeight)*Math.sin(sec)+scrll;
SL.left=x+HandX+(i*HandWidth)*Math.cos(sec);
}
for (i=0; i < D.length; i++){
var DL=(ns)?document.layers['nsDate'+i]:ieDate.style;
DL.top=Dy + ClockHeight*2*Math.sin(rigStep + i*Dsplit*Math.PI/180)+scrll;
DL.left=Dx + ClockWidth*2*Math.cos(rigStep + i*Dsplit*Math.PI/180);
}
for (i=0; i < T.length; i++){
var TL=(ns)?document.layers['nsText'+i]:Text.style;
TL.top=Ty + ClockHeight*1.5*Math.sin(currStep+i*Tsplit*Math.PI/180)+scrll;
TL.left=Tx + ClockWidth*1.5*Math.cos(currStep+i*Tsplit*Math.PI/180);
}
currStep-=step;
rigStep+=rstep;
}
function Delay(){
scrll=(ns)?window.pageYOffset:0;
Ty[0]=Math.round(TY[0]+=((ymouse)-TY[0])*speed);
Tx[0]=Math.round(TX[0]+=((xmouse)-TX[0])*speed);
for (i=1; i < T.length; i++){
Ty=Math.round(TY+=(Ty[i-1]-TY)*speed);
Tx=Math.round(TX+=(Tx[i-1]-TX)*speed);
}
Dy[0]=Math.round(DY[0]+=((ymouse)-DY[0])*speed);
Dx[0]=Math.round(DX[0]+=((xmouse)-DX[0])*speed);
for (i=1; i < D.length; i++){
Dy=Math.round(DY+=(Dy[i-1]-DY)*speed);
Dx=Math.round(DX+=(Dx[i-1]-DX)*speed);
}
y[0]=Math.round(Y[0]+=((ymouse)-Y[0])*speed);
x[0]=Math.round(X[0]+=((xmouse)-X[0])*speed);
for (i=1; i < n; i++){
y=Math.round(Y+=(y[i-1]-Y)*speed);
x=Math.round(X+=(x[i-1]-X)*speed);
}//以上为实际转动运行算法.
ClockAndAssign();
setTimeout('Delay()',20);
}
if (ns||ie)window.onload=Delay;
</SCRIPT>


实际上我自己都喺个初哥...我嘅认识就喺...代码将钟嘅每个元素分配到N个层度...然后用获取时间加上算法...使图层作圆周运动...

E个圆周运动嘅算法唔错咖...值得参考...


评论 / 个人网页 / 扔小纸条
*昵称

已经注册过? 请登录

Email
网址
*评论
 


 
乐言の间
· 全の乐言 · 知足者常乐 · 常乐の冥想 · 常乐の书栈 · 未分の乐言 ·
乐の搜索
常乐の友
· 歪酷博客 · 常乐の工作间 · 小小肥韵妹妹 · 衰女 · 初七夜 · Sissy · 郭郭鸡 · YB · 傻更更 · JIMMY仔 · 东东 · 精灵 · 子诗阿孙 ·
乐のSHOW

站长信息:
Name:常乐
Gender:Male
Character:Optimism
E-Mail:natineprince@163.com
QQ:25851794Q我
乐のLOGO

订阅 RSS

0043496

歪酷博客