繁體
|
簡體
Sclub交友聊天~加入聊天室當版主
(檢舉)
分享
新浪微博
QQ空间
人人网
腾讯微博
Facebook
Google+
Plurk
Twitter
Line
標題:
[分享]
新年到!放烟花!!!
[打印本頁]
作者:
无界
時間:
2015-2-18 00:04
標題:
新年到!放烟花!!!
点击记忆的属性,返回到深厚的友情,复制我们的曾经,粘贴到你的心灵,春节的到来,伴随着我的祝福,祝sclub所有坛友:一声咩,你吉祥;二声咩,你快乐;三声咩,你幸福;四声咩,你平安;五声咩,你健康;六声咩,你发达!祝你羊年大吉,洋洋得意哦!顺祝sclub越办越好!!!
在论坛放烟花吧,效果参看我论坛
代码如下:(放在第三方即可)
<style type="text/css">
.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[i] = tt * coeff[i] + 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[i] = document.createElement("div");
this.stars[i].innerHTML = star;
this.stars[i].className = "star";
if(colorMode == 1){
this.stars[i].style.color = colors[n];
if(++n > cs + cc)
n = cs;
}else{
this.stars[i].style.color = colors[parseInt(Math.random() * colors.length)];
}
this.sky.appendChild(this.stars[i]);
}
},
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[i].style.left = this.x - Math.round(this.r * Math.sin(Math.PI - (Math.PI / 180 * this.angle * i))) + "px";
this.stars[i].style.top = this.y - Math.round(this.r * Math.cos(Math.PI - (Math.PI / 180 * this.angle * i))) + "px";
this.stars[i].style.fontSize = 4 + p/10 + "px";
this.setOpacity(this.stars[i], 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[i].style.left = this.getNextPoint(this.degree, this.points[(i-1)*2], this.t) + "px";
this.stars[i].style.top = this.getNextPoint(this.degree, this.points[(i-1)*2+1], this.t) + "px";
this.stars[i].style.fontSize = 4 + p/10 + "px";
this.setOpacity(this.stars[i], 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[i]);
this.stars[i] = 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();
}
};
document.ready = function(){
for(var i=0; i<5; i++)
new Fireworks(document.body, true).play();
};
</script>
複製代碼
作者:
4rphotoclub
時間:
2015-2-18 02:04
看帖回帖那是一定要的:
喜!我終於占一了;坐到沙發!
作者:
wwlo54205
時間:
2015-2-18 12:57
感謝分享WWW~
作者:
QQ58
時間:
2015-2-18 14:33
谢谢大大~!也祝大大新年快乐~!
作者:
繽紛色彩
時間:
2016-1-16 22:17
本帖最後由 繽紛色彩 於 2016-1-16 22:25 編輯
代碼擺放好了
看不到有烟花出現
=========
已看到了
一直在頁頂等
原來是從頁底發放上來
效果不錯
作者:
我來自他郷
時間:
2017-5-8 23:01
奇怪!为什么我的不显示?难道不兼容x3.2的!
作者:
无界
時間:
2017-5-8 23:05
回復
6#
我來自他郷
你放在广告位试试
作者:
我來自他郷
時間:
2017-5-8 23:10
回復
7#
无界
ok!谢谢,我再试试,没想到我要找的东西都是你的作品啊!呵呵
作者:
我來自他郷
時間:
2017-5-8 23:29
不行!我不过你的提醒让我想到把小人加到广告位,我只选择注册和论坛,这样他就不会出现在板块,不会阻碍发帖和玩游戏了。。。呵呵
作者:
我來自他郷
時間:
2017-5-8 23:31
刚刚看到烟花出现在板块,但论坛却没有,有可能我安装的东西太多的关系。。。再次谢谢!
作者:
无界
時間:
2017-5-8 23:32
刚刚看到烟花出现在板块,但论坛却没有,有可能我安装的东西太多的关系。。。再次谢谢! ...
我來自他郷 發表於 8-5-2017 23:31
小人我做了关闭 右键就能看见了
作者:
我來自他郷
時間:
2017-5-8 23:40
回復
11#
无界
你不说我还没注意到!谢谢
作者:
我來自他郷
時間:
2017-5-21 00:45
回復
11#
无界
无界版大!我想请问下这个回复在那里设置,因为3.2没有这个,不知能不能实现到3.2的版本?
下載
(25.45 KB)
2017-5-21 00:44
圖片附件:
1.jpg
(2017-5-21 00:44, 25.45 KB) / 下載次數 2298
http://weclub.info/discuz/attachment.php?aid=77519&k=a798c80cfc3396c858341db9763371f4&t=1732371076&sid=j9sQuU
歡迎光臨 SCLUB免費論壇申請-使用者論壇 (http://weclub.info/discuz/)
Powered by Discuz! 7.2