zoukankan      html  css  js  c++  java
  • 3D效果的JS烟花背景特效

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                <html xmlns="http://www.w3.org/1999/xhtml" >
                <head>
                <title>3D效果的JS烟花背景特效丨www.update8.com</title>
                </head>
                <style type="text/css">
                .fire{display:block; overflow:hidden; font-size:12px; position:absolute};
                body{overflow:hidden; background:#000}
                html{overflow:hidden; background:#000}
                </style>
                <body>
                <div style="728px;margin:10px auto; overflow:hidden;">
                <script type="text/javascript"><!--
                google_ad_client = "ca-pub-6259241468270513";
                /* 728*90 图片广告 */
                google_ad_slot = "4067870451";
                google_ad_width = 728;
                google_ad_height = 90;
                //-->
                </script>
                <script type="text/javascript"
                src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
                </script>
                </div>
                </body>
                <script type="text/javascript">
                var Fire = function(r, color) {
                this.radius = r || 12;
                this.color = color || "FF6600";
                this.xpos = 0;
                this.ypos = 0;
                this.zpos = 0;
                this.vx = 0;
                this.vy = 0;
                this.vz = 0;
                this.mass = 1;
                this.p = document.createElement("span");
                this.p.className = "fire";
                this.p.innerHTML = "*";
                this.p.style.fontSize = this.radius + "px";
                this.p.style.color = "#" + this.color;
                }
                Fire.prototype = {
                append: function(parent) {
                parent.appendChild(this.p);
                },
                setSize: function(scale) {
                this.p.style.fontSize = this.radius * scale + "px";
                },
                setPosition:function(x, y) {
                this.p.style.left = x + "px";
                this.p.style.top =  y + "px";
                },
                setVisible: function(b) {
                this.p.style.display = b ? "block" : "none";
                }
                }
                var fireworks = function() {
                var fires = new Array();
                var count = 100;
                var fl = 250;
                var vpx = 500;
                var vpy = 300;
                var gravity = .3;
                var floor = 200;
                var bounce = -.8;
                var timer;
                return {
                init: function() {
                for (var i=0; i<count; i++) {
                var color = 0xFF0000;
                color = (Math.random() * 0xFFFFFF).toString(16).toString().split(".")[0];
                while(color.length < 6) {
                color = "0" + color;
                }
                var fire = new Fire(12, color);
                fires.push(fire);
                fire.ypos = -100;
                fire.vx = Math.random() * 6 - 3;
                fire.vy = Math.random() * 6 - 3;
                fire.vz = Math.random() * 6 - 3;
                fire.append(document.body);
                }
                var that = this;
                timer = setInterval(function() {
                for (var i=0;i<count; i++) {
                that.move(fires[i]);
                }
                }, 30);
                },
                move: function(fire) {
                fire.vy += gravity;
                fire.xpos += fire.vx;
                fire.ypos += fire.vy;
                fire.zpos += fire.vz;
                if (fire.ypos > floor) {
                fire.ypos = floor;
                fire.vy *= bounce;
                }
                if (fire.zpos > -fl) {
                var scale = fl/ (fl+fire.zpos);
                fire.setSize(scale);
                fire.setPosition(vpx + fire.xpos * scale,
                vpy + fire.ypos * scale);
                fire.setVisible(true);
                } else {
                fire.setVisible(false);
                }
                }
                }
                }
                fireworks().init();
                </script>
                </html>
               

  • 相关阅读:
    cookie,session和cache关于缓存的使用和区别
    CPU利用率与Load Average的区别
    进程和线程
    当load飙升时问题排查思路
    动态查看JVM内存的工具
    springcloud在 repository层通过sql语句实现查询功能
    java ==与equals的区别
    java 位运算(经常用到)
    api document 文档撰写实例
    markdown 语法案例
  • 原文地址:https://www.cnblogs.com/visense/p/3112548.html
Copyright © 2011-2022 走看看