原生js实现canvas下雨动画效果代码
代码语言:html
所属分类:粒子
代码描述:原生js实现canvas下雨动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Canvas下雨</title>
<style>
body {
background: #0c0c0c;
}
</style>
</head>
<body>
<script>
(function (window, document) {
var Vector2 = (function () {
function Vector2(x, y) {
this.x = x || 0;
this.y = y || 0;
}
return Vector2;
})();
Vector2.prototype.add = function (addend) {
this.x += addend.x;
this.y += addend.y;
};
var RainDrop = (function () {
function RainDrop(parent) {
this.size = 2;
this.parent = parent;
this.init();
}
return RainDrop;
})();
RainDrop.prototype.init = function () {
this.life = 0;
this.ttl = Math.random() * 500 + 300;
this.positio.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0