用java写一些有趣的特效_[Java教程]用JavaScript模拟Flash效果写的炫光波动特效

[Java教程]用JavaScript模拟Flash效果写的炫光波动特效

0

2015-05-13 19:02:10

炫光波动效果

var lightWave = function(T,left,thick,sharp,speed,vibration,amplitude,opacity){

this.cont = T;//炫光容器

this.left = left;//炫光向右偏移量

this.thick = thick;//粗细

this.sharp = sharp;//尖锐度

this.speed = speed;//波动速度

this.vibration = vibration;//单位时间内的振动频率

this.amplitude = amplitude;//振幅

this.opacity = opacity;//透明度

this.cont.style.position = 'relative';

this.move();

}

lightWave.prototype = {

point:function(n,l,t,c,color){

var p = document.createElement('p');

p.innerHTML = ' ';

p.style.top = t + 'px';

p.style.left = l + 'px';

p.style.width = 1 + 'px';

p.style.height = n + 'px';

p.style.filter = 'alpha(opacity='+this.opacity+')';

p.style.lineHeight = 0;

p.style.position = 'absolute';

p.style.background = color;

c.appendChild(p);

return this;

},

color:function(){

var c = ['0','3','6','9','c','f'];

var t = [c[Math.floor(Math.random()*100)%6],'0','f'];

t.sort(function(){return Math.random()>0.5?-1:1;});

return '#'+t.join('');

},

wave:function(){

var l = this.left,t = this.wavelength,color = this.color();

var c = document.createElement('div');

c.style.top = this.amplitude+20+'px';

c.style.position = 'absolute';

c.style.opacity = this.opacity/100;

for(var i=1;i

for(var j=0;j

this.point(i,l,-9999,c,color);

}

}

for(var i=this.thick;i>0;i--){

for(var j=this.thick*this.sharp-i*i;j>0;j--,l++){

this.point(i,l,-9999,c,color);

}

}

this.cont.appendChild(c);

return c;

},

move:function(){

var wl = this.amplitude;

var vibration = this.vibration;

var w = this.wave().getElementsByTagName('p');

for(var i=0;i

w[i].i = i;

}

var m = function(){

for(var i=0,len=w.length;i

if(w[i].ori == true){

w[i].i-=vibration;

var top = w[i].i%180==90?0:wl*Math.cos(w[i].i*Math.PI/180);

w[i].style.top = top+'px';

if(parseFloat(w[i].style.top)<=-wl){

w[i].ori = false;

}

}else{

w[i].i+=vibration;

var top = w[i].i%180==90?0:wl*Math.cos(w[i].i*Math.PI/180);

w[i].style.top = top+'px';

if(parseFloat(w[i].style.top)>=wl){

w[i].ori = true;

}

}

}

}

setInterval(m,this.speed);

}

}

window.onload = function(){

var targetDom = document.body;

new lightWave(targetDom,0,3,36,120,6,20,40);

new lightWave(targetDom,50,2,70,120,10,30,30);

}

http://www.999jiujiu.com/
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值