| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2253 人关注过本帖
标题:雪花飞舞的背景
只看楼主 加入收藏
风中情子
Rank: 1
等 级:新手上路
帖 子:61
专家分:0
注 册:2005-1-11
收藏
 问题点数:0 回复次数:8 
雪花飞舞的背景

<body bgcolor="#000000" text=ffffff onLoad="snow()"><script language="JavaScript"> <!-- N = 40; Y = new Array(); X = new Array(); S = new Array(); A = new Array(); B = new Array(); M = new Array(); V = (document.layers)?1:0;

iH=(document.layers)?window.innerHeight:window.document.body.clientHeight; iW=(document.layers)?window.innerWidth:window.document.body.clientWidth; for (i=0; i < N; i++){ Y[i]=Math.round(Math.random()*iH); X[i]=Math.round(Math.random()*iW); S[i]=Math.round(Math.random()*5+2); A[i]=0; B[i]=Math.random()*0.1+0.1; M[i]=Math.round(Math.random()*1+1); } if (V){ for (i = 0; i < N; i++) {document.write("<LAYER NAME='sn"+i+"' LEFT=0 TOP=0 BGCOLOR='#FFFFF0' CLIP='0,0,"+M[i]+","+M[i]+"'></LAYER>")} } else{ document.write('<div style="position:absolute;top:0px;left:0px">'); document.write('<div style="position:relative">'); for (i = 0; i < N; i++) {document.write('<div id="si" style="position:absolute;top:0;left:0;width:'+M[i]+';height:'+M[i]+';background:#fffff0;font-size:'+M[i]+'"></div>')} document.write('</div></div>'); } function snow(){ var H=(document.layers)?window.innerHeight:window.document.body.clientHeight; var W=(document.layers)?window.innerWidth:window.document.body.clientWidth; var T=(document.layers)?window.pageYOffset:document.body.scrollTop; var L=(document.layers)?window.pageXOffset:document.body.scrollLeft; for (i=0; i < N; i++){ sy=S[i]*Math.sin(90*Math.PI/180); sx=S[i]*Math.cos(A[i]); Y[i]+=sy; X[i]+=sx; if (Y[i] > H){ Y[i]=-10; X[i]=Math.round(Math.random()*W); M[i]=Math.round(Math.random()*1+1); S[i]=Math.round(Math.random()*5+2); } if (V){document.layers['sn'+i].left=X[i];document.layers['sn'+i].top=Y[i]+T} else{si[i].style.pixelLeft=X[i];si[i].style.pixelTop=Y[i]+T} A[i]+=B[i]; } setTimeout('snow()',10); } file://--> </script> </body>

搜索更多相关主题的帖子: 雪花 
2005-01-13 10:31
bingxue2332
Rank: 3Rank: 3
等 级:新手上路
威 望:6
帖 子:446
专家分:0
注 册:2004-11-6
收藏
得分:0 

[CODE]<html> <body bgcolor="#000000" text=ffffff onLoad="snow()"><script language="JavaScript"> <!-- N = 40; Y = new Array(); X = new Array(); S = new Array(); A = new Array(); B = new Array(); M = new Array(); V = (document.layers)?1:0; iH=(document.layers)?window.innerHeight:window.document.body.clientHeight; iW=(document.layers)?window.innerWidth:window.document.body.clientWidth; for (i=0; i < N; i++){ Y[i]=Math.round(Math.random()*iH); X[i]=Math.round(Math.random()*iW); S[i]=Math.round(Math.random()*5+2); A[i]=0; B[i]=Math.random()*0.1+0.1; M[i]=Math.round(Math.random()*1+1); } if (V){ for (i = 0; i < N; i++) {document.write("<LAYER NAME='sn"+i+"' LEFT=0 TOP=0 BGCOLOR='#FFFFF0' CLIP='0,0,"+M[i]+","+M[i]+"'></LAYER>")} } else{ document.write('<div style="position:absolute;top:0px;left:0px">'); document.write('<div style="position:relative">'); for (i = 0; i < N; i++) {document.write('<div id="si" style="position:absolute;top:0;left:0;width:'+M[i]+';height:'+M[i]+';background:#fffff0;font-size:'+M[i]+'"></div>')} document.write('</div></div>'); } function snow(){ var H=(document.layers)?window.innerHeight:window.document.body.clientHeight; var W=(document.layers)?window.innerWidth:window.document.body.clientWidth; var T=(document.layers)?window.pageYOffset:document.body.scrollTop; var L=(document.layers)?window.pageXOffset:document.body.scrollLeft; for (i=0; i < N; i++){ sy=S[i]*Math.sin(90*Math.PI/180); sx=S[i]*Math.cos(A[i]); Y[i]+=sy; X[i]+=sx; if (Y[i] > H){ Y[i]=-10; X[i]=Math.round(Math.random()*W); M[i]=Math.round(Math.random()*1+1); S[i]=Math.round(Math.random()*5+2); } if (V){document.layers['sn'+i].left=X[i];document.layers['sn'+i].top=Y[i]+T} else{si[i].style.pixelLeft=X[i];si[i].style.pixelTop=Y[i]+T} A[i]+=B[i]; } setTimeout('snow()',10); } file://--> </script> </body> </html>[/CODE]

这样看好点 呵呵 的确不错


2005-01-15 17:08
伤心地铁
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2005-3-25
收藏
得分:0 
。。。。。。。。。。
2005-03-25 12:57
caiyakang
Rank: 2
等 级:新手上路
威 望:5
帖 子:2111
专家分:0
注 册:2005-3-24
收藏
得分:0 
请问这种效果是怎么想出来的.

中国人的财富网:http://www..cn/
2005-03-27 13:45
失落的永恒
Rank: 1
等 级:新手上路
帖 子:21
专家分:0
注 册:2005-4-6
收藏
得分:0 
N年前就有了,有特效公主里面早就有了(并不是说你抄到别人的)

如果上帝可以让我选择死亡的地方, 我想我应该会选择电脑前, 趴在键盘上, 默默的去那失落的天堂。
2005-04-06 18:19
songyuyu
Rank: 8Rank: 8
等 级:贵宾
威 望:47
帖 子:6090
专家分:25
注 册:2007-1-17
收藏
得分:0 
呵,原來是可以做這些的

我喝水只喝纯净水,牛奶只喝纯牛奶,所以我很单纯……
2007-05-11 16:00
yms123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
收藏
得分:0 

个人的原理分析,随机在网页X轴document.write出几个div层,然后主要改变y轴的坐标来实现下降效果,这个效果关键问题是算法,主要
sy=S[i]*Math.sin(90*Math.PI/180);
sx=S[i]*Math.cos(A[i]);
Y[i]+=sy;
X[i]+=sx;
if (Y[i] > H){
Y[i]=-10;
X[i]=Math.round(Math.random()*W);
M[i]=Math.round(Math.random()*1+1);
S[i]=Math.round(Math.random()*5+2);
个人认为是这几个计算位置的算法。

2007-05-11 17:21
baomaboy
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2007-5-19
收藏
得分:0 

重要的是创意!

2007-05-19 14:31
hyfz_825
Rank: 1
等 级:新手上路
帖 子:42
专家分:0
注 册:2007-5-2
收藏
得分:0 
   真是狠呀!这都能做!!

爲明天而奮鬥!!!
2007-05-20 01:00
快速回复:雪花飞舞的背景
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019598 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved