Home >Web Front-end >JS Tutorial >Very good page special effects. I suggest you take a look_Typical special effects

Very good page special effects. I suggest you take a look_Typical special effects

WBOY
WBOYOriginal
2016-05-16 19:12:491465browse



精灵'S blog











































































































var r;
var a;
var ai;
var n;
var w;
var k;
var inter;
var period=20000;
var dur; 
var hdur2;
var hdur;
var z;
var nn;
var donut;
var time;
var id = new Array();
for(i=0;i<100;i ){
    id[i]=document.getElementById('ik' i);
}

function again(){
    if(id){
        for(i=0;i<100;i ){
            id[i].style.backgroundColor='rgb(0,0,0)';
        }
    }
    r=0;
    a=0;
    ai=Math.random()/5.0-0.1;
    n=Math.floor(Math.random()*17) 3;
    w=Math.floor(Math.random()*11) 1;
    if(n*w>100){
        n=Math.floor(n/w);
    }
    k=Math.random()*2.0 0.3;
    if(Math.random()<0.5) k=-k;
    inter=1 Math.floor(Math.random()*125);
    dur = Math.floor(period/inter); 
    hdur2=dur*dur/4;
    hdur = dur/2;
    z=2*Math.PI/(n*(1 Math.random()/10));
    nn=Math.floor(Math.random()*n) 1;
    donut=Math.random()*10.0-5.0;
    time=0;
    for(i=0;i        id[i].style.backgroundColor='rgb('
             Math.round(64 Math.random()*191) ','
             Math.round(64 Math.random()*191) ','
             Math.round(64 Math.random()*191) ')';
    }
    hey();
}


function hey(){
    for(i=0;i        tt=time-hdur;
        blah=(Math.sqrt(hdur2-tt*tt)/dur) * (donut 65*Math.cos(k*a z*i/nn));
        L=blah*Math.cos(i*z a);
        T=blah*Math.sin(i*z a);
        id[i].style.left=Math.round((50 L)*10)/10 '%';
        id[i].style.top =Math.round((50 T)*10)/10 '%';
        id[i].style.width=Math.sqrt(4 Math.floor(L*L T*T)) "px";
        id[i].style.height=Math.sqrt(4 Math.floor(L*L T*T)) "px";
        if(Math.random()<0.01){
            id[i].style.backgroundColor='rgb('
                 Math.round(64 Math.random()*191) ','
                 Math.round(64 Math.random()*191) ','
                 Math.round(64 Math.random()*191) ')';
        }
    }
    a =ai;
    time ;
    if(time        setTimeout('hey();',inter);
    }else{
        setTimeout('again();',inter);
    }
}
again();

 


 


 


 


 


 


 


 


 


 


 


 


 


 


 





Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn