本文以web页面为例,
介绍了javascript实现效果的
方法,供大家
参考:
网页背景烟花的爆炸效果更不用说是由Js实现的,效果最好的是黑色背景,五彩缤纷的烟花效果和零散的烟花效果。以前,在网页上有一些特殊的效果,这是相似的,但是代码更简洁。
运行效果如下图所示:
具体代码如下:
烟花在背景中的
作用 <!——
{体
背景颜色:# 000000;
}
-->
VaR col =新的数组(' # ffffff ',' # fff000 ',' # ffa000 ',' # ff00ff ',' # 00ff00 ',' # 0000ff ',' # FF0000);
var =;
var = 0;
对于(i = 0;i < 14;+ i i){
氮+;
如果(n =(col.length-1))n = 0;
p=p';
}
p = p ;
document.write(P);
VaR CLRS =新的数组('ff0000 ','00ff00 ','000aff ','ff00ff ','ffa500 ','ffff00 ','00ff00 ',' ffffff);
无功sclrs =新的数组('ffa500 ','55ff66 ','ac9dfc ','fff000 ',' fffff 0);
VaR的啤啤;
无功peepx;
var
步骤= 5;
无功tallystep = 0;
VaR BackColor = 'ffa000;
VaR MTOP = 250;
无功mleft = 250;
功能爆裂(){
PeepY = window.document.body.clientHeight/3;
peepx =窗口。
文件。身体。clientwidth / 8;
放大();
tallystep + =步;
减少();
T = setTimeout(爆裂()
}
函数放大(){
为(i = 0;i < reardiv.all.length;i++){
var c = math.round(Math.random()*(CLRS。length-1));
如果(tallystep<90)
reardiv,{我}。风格。背景为背景色;
如果(tallystep > 90)
reardiv,{我}。风格。背景= CLRS { };
reardiv,{我}。style.top =该+啤啤* Math.sin((tallystep +我×5)/(550 + 3)* Math.sin tallystep / 100);
reardiv,{我}。style.left = mleft +啤啤* Math.cos((tallystep +我×5)/(550 + 3)* Math.sin tallystep / 100);
}
}
函数减少(){
如果(tallystep = = 220){
tallystep = - 10;
var k = math.round(Math.random()*(sclrs。length-1));
BackColor = sclrs {K };
window.document.body.clientheight滴= 250;
dleft = peepx * 3.5;
该math.round(Math.random =()×滴);
mleft = math.round(Math.random()* dleft);
document.all.reardiv.style.top =该+ document.body.scrolltop;
document.all.reardiv.style.left = mleft + document.body.scrollleft;
如果((Mtop < 20)| |(mleft<20)){
该= 90;
mleft = 90;
}
}
}
爆裂();
希望本文能对大家的javascript
程序设计有所帮助。