JavaScript烟花效果
来源:互联网 发布:淘宝代营运是什么意思 编辑:程序博客网 时间:2024/04/29 16:43
一个很简单的烟花代码
JavaScript代码
- radius =0;
- last_radius=100;
- startY=200;
- c_count=0;
- deviatY=1;
- // 设定礼花颜色
- Colors=new Array('ff0000','00ff00','ffffff','ff00ff','ffa500','ffff00','00ff00','ffffff','ff00ff');
- sColors=new Array('ffa500','00ff00','FFAAFF','fff000','fffffF');
- color=sColors[Math.floor(Math.random()*sColors.length)];
- if(document.all){
- last_radius=document.body.clientWidth/8;
- startX=document.body.clientWidth/2;
- staY= document.body.clientHeight-20;
- }else{last_radius=window.outerWidth/8;
- startX=window.outerWidth/2;
- staY= window.outerHeight-20;
- }
- for(i=0;i<Math.PI*2;i=i+0.3){
- document.write("<DIV STYLE='position:absolute;font-size:5;background-color:"+color+";top:"+staY+";left:"+startX+";'ID='bon"+i+"'>*</DIV>");
- }
- // 设定礼花升起时间
- setTimeout("uchiage()",10)
- function uchiage(){
- if(startY < staY){
- staY-=10;
- for(i=0;i<Math.PI*2;i=i+0.3){
- if(document.all){
- document.all["bon"+i].style.pixelTop = staY+document.body.scrollTop;
- }else{
- document.getElementById("bon"+i).style.top=staY+window.pageYOffset +"px";
- }
- }
- setTimeout("uchiage()",50);
- }else{
- radius =20;hanabi();
- }
- }
- function hanabi(){
- if(last_radius > radius){
- radius +=10;
- for(i=0;i<Math.PI*2;i=i+0.3){
- pointX = startX + Math.cos(i)*radius;
- (deviatY == 0.3)?katamuki=(pointX - startX) * 0.4:katamuki=0;
- pointY = startY + Math.sin(i)*radius*deviatY+katamuki;
- if(document.all){
- document.all["bon"+i].style.pixelTop = pointY+document.body.scrollTop;
- document.all["bon"+i].style.pixelLeft = pointX;
- }else{
- document.getElementById("bon"+i).style.top=pointY+window.pageYOffset +"px";
- document.getElementById("bon"+i).style.left=pointX+"px";
- }
- }
- // 设定礼花张开时间
- setTimeout("hanabi()",60);
- }else if(c_count<300){
- for(i=0;i<Math.PI*2;i=i+0.3){
- color=Colors[Math.floor(Math.random()*Colors.length)];
- if(document.all){
- document.all["bon"+i].style.backgroundColor = color;
- }else{
- document.getElementById("bon"+i).style.backgroundColor = color;
- }
- c_count++
- }
- // 设定礼花持续时间
- setTimeout("hanabi()",50);
- }else{
- color=sColors[Math.floor(Math.random()*sColors.length)];
- radius = 20;c_count=0;
- if(document.all){
- scrX=document.body.clientWidth - last_radius*2;
- startX=Math.floor(Math.random()*scrX)+last_radius;
- startY=Math.random()*last_radius+last_radius;
- staY= document.body.clientHeight-20;
- (!(Math.floor(Math.random()*3)))?deviatY=0.3:deviatY=1;
- for(i=0;i<Math.PI*2;i=i+0.3){
- document.all["bon"+i].style.backgroundColor = color;
- document.all["bon"+i].style.pixelTop = staY+document.body.scrollTop;
- document.all["bon"+i].style.pixelLeft = startX;
- }
- }else{
- scrX=window.outerWidth-last_radius*2;
- startX=Math.floor(Math.random()*scrX)+last_radius;
- startY=Math.random()*last_radius+last_radius;
- staY= window.outerHeight-20;
- (!(Math.floor(Math.random()*3)))?deviatY=0.3:deviatY=1;
- for(i=0;i<Math.PI*2;i=i+0.3){
- document.getElementById("bon"+i).style.backgroundColor = color;
- document.getElementById("bon"+i).style.top=staY+window.pageYOffset +"px";
- document.getElementById("bon"+i).style.left=startX+"px";
- }
- }
- uchiage();
- }
- }
- function hanabi_size(){
- if(document.all){
- last_radius=document.body.clientWidth/8;
- }else{
- last_radius=window.outerWidth/8;
- }
- }
- document.body.onresize=hanabi_size;
- <html>
- <body bgcolor="black">
- <SCRIPT type="text/javascript">
- <!--放入烟花的JavaScript代码-->
- </SCRIPT>
- </body>
- </html>
转贴请注明出处:http://blog.csdn.net/froole
- JavaScript烟花效果
- JavaScript烟花效果
- javascript 烟花效果
- 庆元旦,放烟花(纯javascript版烟花效果)
- 烟花效果
- 烟花效果
- 烟花效果
- 释放烟花的效果
- powershell 实现烟花效果
- android 放烟花效果
- html5烟花绽放效果
- html5烟花绽放效果
- html5烟花效果
- html5烟花绽放效果
- android实现烟花效果
- html5烟花绽放效果
- 如何增强烟花照片效果
- OGRE粒子调烟花效果
- arptables
- 基于CICS的中间业务平台设计与实现
- 用C#生成随机中文汉字验证码的基本原理
- factory
- 正则表达式规则
- JavaScript烟花效果
- 工作就是愉快的带薪学习
- linux 下查看服务和与服务的运行级别以及自动启动相关的配置
- 利用watir自动化测试并截图,截图后保存
- javascript格式化时间
- 每个分类取最新的几条的SQL实现
- 使用Eclipse制作可执行jar文件
- 正则语法WEB调试器
- 关于FLEX3中的ComboBox的一些问题