pixi+tinycolor实现canvas高空瀑布动画效果代码
代码语言:html
所属分类:动画
代码描述:pixi+tinycolor实现canvas高空瀑布动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<style>
body {
background: #222;
color: white;
}
#container {
box-shadow: inset 0 1px 0 #444, 0 -1px 0 #000;
height: 100vh;
width: 100vw;
position: absolute;
left: 0;
top: 0;
margin: 0;
will-change: transform;
-webkit-transform: translateZ(0);
transform: translateZ(0);
}
canvas#waterfall {
display: block;
margin: 0 auto;
width: 30%;
height: 55%;
will-change: transform;
-webkit-transform: translateZ(0);
transform: translateZ(0);
}
.emma {
height: 100vh;
width: 100%;
position: absolute;
left: 0;
top: 0;
margin: 0;
}
h1 {
color: #0af;
font-size: 30vw;
}
canvas#surface {
-webkit-animation: fade-in 3000ms forwards;
animation: fade-in 3000ms forwards;
display: block;
left: 0;
position: absolute;
top: 0;
z-index: -1;
}
@-webkit-keyframes fade-in {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
@keyframes fade-in {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
</style>
</head>
<body>
<div id="container">
<canvas id="waterfall"></canvas> <div class="emma flex">
<div>
</div>
</div>
</div>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/pixi.min.js"></script>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/tinycolor.min.js"></script>
<script>
+!~-(function(PIXI, window, document, undefined) {
var waterfallCanvas = function(c, cw, ch) {
var _this = this;
this.c = c;
this.ctx = c.getContext('2d');
this.cw = cw;
this.ch = ch;
this.particles = [];
this.particleRate = 6;
this.gravity = 0.15;
this.init = function() {
this.loop();
};
this.reset = function() {
this.ctx.clearRect(0, 0, this.cw, this.ch);
this.particles = [];
};
this.rand = function(rMi, rMa) {
return ~~((Math.random() * (rMa - rMi + 1)) + rMi);
};
this.Particle = function() {
var newWidth = _this.ra.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0