|
|
源码.rar
(3.12 KB, 下载次数: 31)
<body bgcolor="#000000">
<SCRIPT LANGUAGE="JavaScript">
yourLogo='欢迎过来';
logoFont='Arial';
logoSize=9;
logoColor='red';
logoWidth=100;
logoHeight=100;
logoSpeed=0.01;
//Nothing needs altering below!
yourLogo=yourLogo.split('');
L=yourLogo.length;
Result="<font face="+logoFont+" style='font-size:"+logoSize+"pt' color="+logoColor+">";
TrigSplit=360/L;
br=(document.layers)?1:0;
if (br){
for (i=0; i < L; i++)
document.write('<layer name="ns'+i+'" top=0 left=0 width=14 height=14">'+Result+yourLogo+'</layer>');
}
else{
document.write('<div id="outer" style="position:absolute;top:0px;left:0px"><div style="position:relative">');
for (i=0; i < L; i++)
document.write('<div id="ie" style="position:absolute;top:0px;left:0px;width:14px;height:14px">'+Result+yourLogo+'</div>');
document.write('</div></div>');
}
ypos=0;
xpos=0;
step=logoSpeed;
currStep=0;
Y=new Array();
X=new Array();
Yn=new Array();
Xn=new Array();
for (i=0; i < L; i++)
{
Yn=0;
Xn=0;
}
(document.layers)?window.captureEvents(Event.MOUSEMOVE):0;
function Mouse(evnt){
ypos = (document.layers)?evnt.pageY:event.y;
xpos = (document.layers)?evnt.pageX:event.x;
}
(document.layers)?window.onMouseMove=Mouse:document.onmousemove=Mouse;
function animateLogo(){
if (!br)outer.style.pixelTop=document.body.scrollTop;
for (i=0; i < L; i++){
var layer=(document.layers)?document.layers['ns'+i]:ie.style;
layer.top =Y+logoHeight*Math.sin(currStep+i*TrigSplit*Math.PI/180);
layer.left=X+logoWidth*Math.cos(currStep+i*TrigSplit*Math.PI/180);
}
currStep-=step;
}
function Delay(){
for (i=L; i >= 0; i--)
{
Y=Yn+=(ypos-Yn)*(0.1+i/L);
X=Xn+=(xpos-Xn)*(0.1+i/L);
}
animateLogo();
setTimeout('Delay()',20);
}
window.onload=Delay;
// -->
</script>
<head>
<meta http-equiv="Content-Type" c>
<meta name="GENERATOR" c>
<meta name="ProgId" c>
<style>
<!--
body, td, div { font-family: Verdana; font-size: 9pt }
-->
</style>
</head>
</body>
</html>
<body>
</body>
</html>
</body>
<style type="text/css">
html,body{background:#000; height:100%; margin:0px; padding:0px;color:#FFF;}
.ball{color:#FF0000; position:absolute; font-size:16px;}
.star{color:#FF0000; position:absolute; font-size:4px;}
</style>
<script type="text/javascript">
function Fireworks(sky, loop){
this.sky = sky;
this.skyWidth = document.body.clientWidth || document.documentElement.clientWidth;
this.skyHeight= document.body.clientHeight || document.documentElement.clientHeight;
this.x = this.y = 0;
this.step = 20;
this.delay = 30;
this.stars = [];
this.r = 10;
this.step2 = 7;
this.radius = 90;
this.angle = 45;
this.num = 16;
this.loop = loop;
this.degree = 2;
this.t = 0;
this.delt = 0;
this.max = 30;
this.cur = 1;
this.points = null;
}
Fireworks.prototype = {
init : function(){
this.x = parseInt(this.skyWidth/1.3 * Math.random()) + this.skyWidth / 8;
this.y = this.skyHeight;
this._y = parseInt((this.skyHeight / 4) * Math.random()) + this.skyHeight / 5;
},
setOpacity : function(obj, p){
if(p > 85){
var opacity = 100 - (p - 85) * 4;
if(document.all){
obj.style.filter = "alpha(opacity=" + opacity + ")";
}else{
obj.style.MozOpacity = opacity / 100;
}
}
},
getNextPoint : function(degree, coeff, t){
var tt = 1.0 - t;
for(var rr = 1; rr <= degree; rr++){
for(var i=0; i <= degree-rr; i++){
coeff = tt * coeff + t * coeff[i+1];
}
}
return coeff[0];
},
showBall : function(){
this.ball = document.createElement("div");
this.ball.innerHTML = "●";
this.ball.className = "ball";
this.ball.style.left = this.x + "px";
this.ball.style.top = this.y + "px";
this.sky.appendChild(this.ball);
},
moveBall : function(){
var self = this;
if(this.y > this._y){
var p = parseInt((this.skyHeight - this.y) / (this.skyHeight - this._y)*10);
this.y -= (this.step - p * 1.6);
this.ball.style.fontSize = 16 - p + "px";
this.ball.style.top = this.y + "px";
setTimeout(function(){self.moveBall();}, this.delay);
}else{
this.fire();
}
},
hideBall : function(){
this.sky.removeChild(this.ball);
this.ball = null;
},
showStars : function(){
var colors = ['#FF0000','#FF00FF','#00FF00','#00FFFF','#FFFF00','#FF0000','#FF00FF','#00FF00','#00FFFF','#FFFF00'];
var n = cs = parseInt(Math.random() * colors.length / 2);
var cc = parseInt(Math.random() * colors.length / 2);
var colorMode = parseInt(Math.random() * 2);
var star = Math.round(Math.random()) == 1 ? "★" : "☆";
this.r = 10;
this.radius = Math.round(Math.random() * 30) + 60;
this.num = Math.round(Math.random() * 5 + 5) * 2;
this.angle = 180 / this.num * 2;
for(var i=1; i<=this.num; i++){
this.stars = document.createElement("div");
this.stars.innerHTML = star;
this.stars.className = "star";
if(colorMode == 1){
this.stars.style.color = colors[n];
if(++n > cs + cc)
n = cs;
}else{
this.stars.style.color = colors[parseInt(Math.random() * colors.length)];
}
this.sky.appendChild(this.stars);
}
},
moveStars : function(){
var self = this;
if(this.r < this.radius){
var p = this.step2 - parseInt(this.r / this.radius * 5);
p = p < 1 ? 1 : p;
this.r += p;
p = parseInt(this.r / this.radius * 100);
for(var i=1; i<=this.num; i++){
this.stars.style.left = this.x - Math.round(this.r * Math.sin(Math.PI - (Math.PI / 180 * this.angle * i))) + "px";
this.stars.style.top = this.y - Math.round(this.r * Math.cos(Math.PI - (Math.PI / 180 * this.angle * i))) + "px";
this.stars.style.fontSize = 4 + p/10 + "px";
this.setOpacity(this.stars, p);
}
setTimeout(function(){self.moveStars();}, this.delay);
}else{
setTimeout(function(){self.hideStars();}, 200 * Math.random());
}
},
initBezier : function(){
var coeff_x = [];
var coeff_y = [];
this.points = [];
this.t = 0;
this.delt = 1.0 / this.max;
this.cur = 1;
var a = parseInt(Math.random() * 5) * 90;
coeff_x[0] = this.x;
coeff_y[0] = this.y;
for(var i=1; i<=this.num; i++){
coeff_x[1] = this.x + Math.sin(Math.PI - (Math.PI / 180 * this.angle * i)) * this.radius/2;
coeff_y[1] = this.y + Math.cos(Math.PI - (Math.PI / 180 * this.angle * i)) * this.radius/2;
coeff_x[2] = this.x + Math.sin(Math.PI - (Math.PI / 180 * (a-this.angle * i))) * this.radius;
coeff_y[2] = this.y + Math.cos(Math.PI - (Math.PI / 180 * (a-this.angle * i))) * this.radius;
this.points[(i-1)*2] = coeff_x.slice(0);
this.points[(i-1)*2+1] = coeff_y.slice(0);
}
},
moveStars2 : function(){
var self = this;
if(this.cur < this.max){
this.t += this.delt;
this.cur++;
p = parseInt(this.cur / this.max * 100);
for(var i=1; i<=this.num; i++){
this.stars.style.left = this.getNextPoint(this.degree, this.points[(i-1)*2], this.t) + "px";
this.stars.style.top = this.getNextPoint(this.degree, this.points[(i-1)*2+1], this.t) + "px";
this.stars.style.fontSize = 4 + p/10 + "px";
this.setOpacity(this.stars, p);
}
setTimeout(function(){self.moveStars2();}, this.delay);
}else{
setTimeout(function(){self.hideStars();}, 200 * Math.random());
}
},
hideStars : function(){
for(var i=1; i<=this.num; i++){
this.sky.removeChild(this.stars);
this.stars = null;
if(this.points != null){
delete this.points[(i-1)*2];
delete this.points[(i-1)*2+1];
}
}
if(this.points){
delete this.points;
}
this.points = null;
if(this.loop){
this.play();
}
},
fire : function(){
this.hideBall();
this.showStars();
var effect = parseInt(Math.random() * 2) + 1;
switch(effect){
case 1:
this.moveStars();
break;
case 2:
this.initBezier();
this.moveStars2();
break;
}
},
play : function(){
this.init();
this.showBall();
this.moveBall();
}
};
window.onload = function(){
for(var i=0; i<5; i++)
new Fireworks(document.body, true).play();
};
</script>
</head>
<body>
</body>
</html></font> |
|