<!DOCTYPE html>
  <html>
  <head>
  <meta charset="UTF-8">
  <title>Colors Rain</title>
  </head>
  <style>
  html,body{
  width: 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>
   

面向对象写的简单的colors rain的更多相关文章

  1. linux设备驱动归纳总结(十一):写个简单的看门狗驱动【转】

    本文转载自:http://blog.chinaunix.net/uid-25014876-id-112879.html linux设备驱动归纳总结(十一):写个简单的看门狗驱动 xxxxxxxxxxx ...

  2. linux设备驱动归纳总结(五):4.写个简单的LED驱动【转】

    本文转载自:http://blog.chinaunix.net/uid-25014876-id-84693.html linux设备驱动归纳总结(五):4.写个简单的LED驱动 xxxxxxxxxxx ...

  3. 【Linux开发】linux设备驱动归纳总结(十一):写个简单的看门狗驱动

    linux设备驱动归纳总结(十一):写个简单的看门狗驱动 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ...

  4. 【Linux开发】linux设备驱动归纳总结(五):4.写个简单的LED驱动

    linux设备驱动归纳总结(五):4.写个简单的LED驱动 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ...

  5. 用Python写一个简单的Web框架

    一.概述 二.从demo_app开始 三.WSGI中的application 四.区分URL 五.重构 1.正则匹配URL 2.DRY 3.抽象出框架 六.参考 一.概述 在Python中,WSGI( ...

  6. 如何写一个简单的http服务器

    最近几天用C++写了一个简单的HTTP服务器,作为学习网络编程和Linux环境编程的练手项目,这篇文章记录我在写一个HTTP服务器过程中遇到的问题和学习到的知识. 服务器的源代码放在Github. H ...

  7. 如何写一个简单的shell

    如何写一个简单的shell 看完<UNIX环境高级编程>后我就一直想写一个简单的shell来作为练习,因为有事断断续续的写了好几个月,如今写了差不多来总结一下. 源代码放在了Github: ...

  8. 用C#Winform写个简单的批量清空文件内容和删除文件的小工具

    用C#Winform写个简单的批量清空文件内容和删除文件的小工具 本文介绍这个简单得不能再简单的小项目.做这个项目,有以下目的. 1 当然是做个能用的工具 2 学习使用Github 关于用VS2013 ...

  9. 分享:计算机图形学期末作业!!利用WebGL的第三方库three.js写一个简单的网页版“我的世界小游戏”

    这几天一直在忙着期末考试,所以一直没有更新我的博客,今天刚把我的期末作业完成了,心情澎湃,所以晚上不管怎么样,我也要写一篇博客纪念一下我上课都没有听,还是通过强大的度娘完成了我的作业的经历.(当然作业 ...

随机推荐

  1. Codeforces348C - Subset Sums

    Portal Description 给出长度为\(n(n\leq10^5)\)的序列\(\{a_n\}\)以及\(m(m\leq10^5)\)个下标集合\(\{S_m\}(\sum|S_i|\leq ...

  2. 关于C语言文件操作

    关于C语言的文件操作之前我也写过一篇博客来介绍,但是当时写的很不全面,只是简单的使用了一下 ,今天再从新学习一下. 1.文件的写 首先还是先看一个简单的例子: include<stdio.h&g ...

  3. JavaScript设计模式之策略模式

    所谓"条条道路通罗马",在现实中,为达到某种目的往往不是只有一种方法.比如挣钱养家:可以做点小生意,可以打分工,甚至还可以是偷.抢.赌等等各种手段.在程序语言设计中,也会遇到这种类 ...

  4. Five nines

    Five nines, commonly taken to mean "99.999%", may refer to: 高可用  High availability of serv ...

  5. DataCleaner第一章

    Part1. Introduction to DataCleaner 介绍DataCleaner |--What is data quality(DQ) 数据质量? |--What is data p ...

  6. QRCode 扫描二维码、扫描条形码、相册获取图片后识别、生成带 Logo 二维码、支持微博微信 QQ 二维码扫描样式

    目录 功能介绍 常见问题 效果图与示例 apk Gradle 依赖 布局文件 自定义属性说明 接口说明 关于我 功能介绍 根据之前公司的产品需求,参考 barcodescanner 改的,希望能帮助到 ...

  7. VC下ffmpeg例程调试报错处理

    tools/options/directories/include files  添加ffmpeg头文件所在路径 tools/options/directories/library files  添加 ...

  8. Flex父子窗口相互调用

    Flex父子窗口相互调用 1.设计思路 (1)子窗口调用父窗口的方法 (2)子窗口做了修改后,返回父窗口,父窗口调用子窗口函数 2.设计源码 (1)父窗口 ParentWindow.mxml: < ...

  9. gstreamer在Ubuntu下构建开发环境

    1,Ubuntu已经安装了gstreamer库,因此只需要再安装几个开发库即可,是 libstreamer0.-libstreamer0.-devlibstreamer0.--dbg 在新立得里选中应 ...

  10. Caused by: java.lang.ClassNotFoundException: org.aspectj.weaver.reflect.ReflectionWorld$ReflectionWo

    1.错误描述 usage: java org.apache.catalina.startup.Catalina [ -config {pathname} ] [ -nonaming ] { -help ...