面向对象写的简单的colors rain
| <!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的更多相关文章
- linux设备驱动归纳总结(十一):写个简单的看门狗驱动【转】
本文转载自:http://blog.chinaunix.net/uid-25014876-id-112879.html linux设备驱动归纳总结(十一):写个简单的看门狗驱动 xxxxxxxxxxx ...
- linux设备驱动归纳总结(五):4.写个简单的LED驱动【转】
本文转载自:http://blog.chinaunix.net/uid-25014876-id-84693.html linux设备驱动归纳总结(五):4.写个简单的LED驱动 xxxxxxxxxxx ...
- 【Linux开发】linux设备驱动归纳总结(十一):写个简单的看门狗驱动
linux设备驱动归纳总结(十一):写个简单的看门狗驱动 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ...
- 【Linux开发】linux设备驱动归纳总结(五):4.写个简单的LED驱动
linux设备驱动归纳总结(五):4.写个简单的LED驱动 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ...
- 用Python写一个简单的Web框架
一.概述 二.从demo_app开始 三.WSGI中的application 四.区分URL 五.重构 1.正则匹配URL 2.DRY 3.抽象出框架 六.参考 一.概述 在Python中,WSGI( ...
- 如何写一个简单的http服务器
最近几天用C++写了一个简单的HTTP服务器,作为学习网络编程和Linux环境编程的练手项目,这篇文章记录我在写一个HTTP服务器过程中遇到的问题和学习到的知识. 服务器的源代码放在Github. H ...
- 如何写一个简单的shell
如何写一个简单的shell 看完<UNIX环境高级编程>后我就一直想写一个简单的shell来作为练习,因为有事断断续续的写了好几个月,如今写了差不多来总结一下. 源代码放在了Github: ...
- 用C#Winform写个简单的批量清空文件内容和删除文件的小工具
用C#Winform写个简单的批量清空文件内容和删除文件的小工具 本文介绍这个简单得不能再简单的小项目.做这个项目,有以下目的. 1 当然是做个能用的工具 2 学习使用Github 关于用VS2013 ...
- 分享:计算机图形学期末作业!!利用WebGL的第三方库three.js写一个简单的网页版“我的世界小游戏”
这几天一直在忙着期末考试,所以一直没有更新我的博客,今天刚把我的期末作业完成了,心情澎湃,所以晚上不管怎么样,我也要写一篇博客纪念一下我上课都没有听,还是通过强大的度娘完成了我的作业的经历.(当然作业 ...
随机推荐
- 电脑中dll文件丢失怎么恢复?
DLL文件是Windows系统中的动态链接文件,我们在运行程序时都必须链接到dll文件,如果缺少了则无法正常运行,相信大家都会遇到dll文件缺失的情况,那么电脑中dll文件丢失怎么恢复?下面装机之家分 ...
- webpack入门宝典
前提摘要 本文是经过二天自己学习总结出来的一些心得,本文是在最新版的webpack4x的基础上进行配置的(听说webpack4x比以往改变都很大有些插件可能有问题).如果你以前没怎么接触过Webpac ...
- 学习笔记︱Nvidia DIGITS网页版深度学习框架——深度学习版SPSS
DIGITS: Deep Learning GPU Training System1,是由英伟达(NVIDIA)公司开发的第一个交互式深度学习GPU训练系统.目的在于整合现有的Deep Learnin ...
- DOS下串口通信程序来传送文件的源代码
接收程序: #include <dos.h>#include <fstream.h>#include <conio.h>#include <stdio.h&g ...
- java.sql.SQLException:Invalid value for getInt()-'zhangsan'
1.错误描述 java.sql.SQLException:Invalid value for getInt()-'zhangsan' 2.错误原因 在遍历打印查询结果时,rs.getInt(3),而在 ...
- CentOS时钟同步服务器
①本地时钟服务器需要安装chrony服务,可以通过yum.rpm.源码包安装,chrony支持C/S模式 ②编辑本地时钟服务,使其指向提供标准时间服务器,例如:中国国家授时中心NTP服务器. 修改配置 ...
- Supermarket POJ - 1456
A supermarket has a set Prod of products on sale. It earns a profit px for each product x∈Prod sold ...
- 一个完整的springmvc + ajaxfileupload实现图片异步上传的案例
一,原理 详细原理请看这篇文章 springmvc + ajaxfileupload解决ajax不能异步上传图片的问题.java.lang.ClassCastException: org.apache ...
- 【转载】Apache Storm 官方文档 —— 基础概念
[转载自https://yq.aliyun.com/articles/87510?t=t1] Storm 系统中包含以下几个基本概念: 拓扑(Topologies) 流(Streams) 数据源(Sp ...
- [hihoCoder] 高斯消元·一 [TPLY]
高斯消元一 题目链接 : http://hihocoder.com/problemset/problem/1195?sid=1269842 很"好aoaoaoaoaoaoa"的高斯 ...