Use JavaScript to simulate the Flash effect written by the glare wave effects

Source: Internet
Author: User
Tags cos

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<title> Glare Ripple Effect </title>
<script>
var Lightwave = function (t,left,thick,sharp,speed,vibration,amplitude,opacity) {
This.cont = t;//Glare Container
This.left = left;//Glare Right Offset
This.thick = thick;//Thickness
This.sharp = sharp;//sharpness
This.speed = speed;//fluctuation speed
This.vibration = vibration;//Vibration frequency per unit of time
This.amplitude = amplitude;//Amplitude
This.opacity = opacity;//Transparency
this.cont.style.position = ' relative ';
This.move ();
}
Lightwave.prototype = {
Point:function (N,l,t,c,color) {
var p = document.createelement (' P ');
p.innerhtml = ' &nbsp; ';
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<this.thick;i++) {
for (Var j=0;j<this.thick*this.sharp-i*i;j++,l++) {
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.length;i++) {
W[I].I = i;
}
var m = function () {
for (Var i=0,len=w.length;i<len;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);
}
</script>
<body style= "background: #000; margin-top:100px" >
<div><a href= "http://www.999jiujiu.com/" >http://www.999jiujiu.com/</A></div>
</body>

Use JavaScript to simulate the Flash effect written by the glare wave effects

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.