• 面向对象写的简单的colors rain


      <!DOCTYPE html>
      <html>
      <head>
      <meta charset="UTF-8">
      <title>Colors Rain</title>
      </head>
      <style>
      html,body{
      100%;
      height: 100%;
      position: relative;
      background: #000;
      }
      .star{
       
      background: url(bullet.png);
      }
      </style>
      <body>
       
      </body>
      <script>
      var ww=window.innerWidth;
      var hh=window.innerHeight;
      var x,y;
      function snow(){
       
      this.x=Math.random()*ww;
      this.y=Math.random()*hh;
      this.r=Math.random()*255;
      this.g=Math.random()*255;
      this.b=Math.random()*255;
      this.v=Math.random()*10+5;
      this.w=1;
      this.h=Math.random()*40+15;
      this.color='#'+('00000'+((Math.random()*16777215+0.5)>>0).toString(16)).slice(-6)
       
      this.create()
      }
      snow.prototype={
      create:function(){
      this.node =document.createElement('div');
      this.node.style.position='absolute';
       
      this.node.style.left=this.x+'px';
      this.node.style.width=this.w+'px';
      this.node.style.height=this.h+'px';
       
      this.node.style.transform='rotateX(30deg) translateX(-10px)'
      this.node.style.backgroundColor=this.color;
      document.body.appendChild(this.node);
      },
      move:function(){
      this.y=this.y+this.v;
      if(this.y>=hh){
      this.y=0;
      }
      // if(y-10>this.y>y+10||x-10<this.x<x+10){
      // this.v=0;
      // ;
      // }
      this.x=this.x+this.v*Math.cos(-30);
      if(this.x>=ww){
      this.x=0;
      }
      this.node.style.left=this.x+'px';
      this.node.style.top=this.y*0.9+'px';
       
      }
      }
       
       
      function gosnow(){
      var snowarr=[];
       
      for(var i=0;i<150;i++){
      var snows= new snow();
      snowarr.push(snows);
       
       
      }
      setInterval(function(){
      for(var j=snowarr.length-1;j>=0;j--){
      snowarr[j].move()
      }
      },1000/30)
      }
      gosnow(
       
      )
      document.onmousemove=function(ev){
      var ev=window.ev||ev;
      x= ev.clientX;
      y=ev.clientY;
      console.log(x,y)
      }
      </script>
      </html>
       

  • 相关阅读:
    你真的会玩SQL吗?EXISTS和IN之间的区别
    大数据征信六大难题待解
    大数据征信六大难题待解
    大数据小白的一些浅见
    大数据小白的一些浅见
    spss命令数据整理中compute与record命令的区别
    spss命令数据整理中compute与record命令的区别
    R语言实现分层抽样(Stratified Sampling)以iris数据集为例
    R语言实现分层抽样(Stratified Sampling)以iris数据集为例
    ORA-24247: 网络訪问被訪问控制列表 (ACL) 拒绝
  • 原文地址:https://www.cnblogs.com/zzh965390267/p/8023162.html
Copyright © 2020-2023  润新知