pixi实现按钮萤火虫粒子飞舞动画效果代码
代码语言:html
所属分类:粒子
代码描述:pixi实现按钮萤火虫粒子飞舞动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> @import url('https://fonts.googleapis.com/css?family=Indie+Flower'); * { box-sizing: border-box; cursor: default; outline: none; margin: 0; padding: 0; } html, body { height: 100%; background: #171623; overflow: hidden; } canvas { display: block; } #background { display: block; position: absolute; top: 0; left: 0; width: 100%; height: 100%; } .table { display: table; width: 100%; height: 100%; } .cell { display: table-cell; vertical-align: middle; text-align: center; padding-top: 10px; cursor: pointer; } .excitement { transition: all 300ms cubic-bezier(0.175, 0.885, 0.32, 1.275); position: absolute; top: 0; right: 0; bottom: 0; left: 0; margin: auto; width: 300px; height: 120px; border-radius: 10px; box-shadow: 0 5px 10px 5px rgba(0,0,0,0.2); background: #333333; overflow: hidden; cursor: pointer; z-index: 1000; } .excitement:hover { transform: scale(1.08); } .excitement:active { transform: scale(1); } .excitement::before { position: absolute; width: 250px; height: 180px; content: ""; display: block; top: 0; margin-left: 138px; transform-style: flat; transform: skew(20deg); background: -moz-linear-gradient(top, hsla(0,0%,100%,0.1) 0%, hsla(0,0%,100%,0) 100%); background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,hsla(0,0%,100%,0.2)), color-stop(100%,hsla(0,0%,100%,0))); background: -webkit-linear-gradient(top, hsla(0,0%,100%,0.1) 0%,hsla(0,0%,100%,0) 100%); background: -o-linear-gradient(top, hsla(0,0%,100%,0.1) 0%,hsla(0,0%,100%,0) 100%); background: -ms-linear-gradient(top, hsla(0,0%,100%,0.1) 0%,hsla(0,0%,100%,0) 100%); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#42ffffff', endColorstr='#00ffffff',GradientType=0 ); background: linear-gradient(to bottom, hsla(0,0%,100%,0.1) 0%,hsla(0,0%,100%,0) 100%); } .excitement h1 { user-select: none; font-family: 'Indie Flower', cursive; text-shadow: 0 2px 2px black; color: #ffd800; font-size: 50px; letter-spacing: 3px; cursor: pointer; } </style> </head> <body> <!-- partial:index.partial.html --> <div id="background"></div> <div class="excitement"> <div class="table"> <div class="cell"> <h1>Fireflies!!!</h1> </div> </div> </div> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/jquery.2.11.js"></script> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/pixi.4.4.3.js"></script> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/dat.gui-min.js"></script> <script> var gui = new dat.GUI(); gui.close(); var firefliesConfig = { width: 300, // button width height: 120, // button height fireflyCount: 1500, radius: 10, spawnRate: 2, simplexStart: 20, fireflyColor: [ 200, 254, 117 ], blur: 0.7, backgroundColor: 0x171623, blendMode: PIXI.BLEND_MODES.ADD, blinkDelay: 0.7, blinkDecay: 0.01, liveTime: 200, scatterDecay: 0.03, scatterAccel: 0.3, scatterRate: 0.5, xVelocity: 1.4, yVelocity: 1 }; $(document).ready(function() { var state = true; var fireflies = new Fireflies($('#background')[0], firefliesConfig, function() { state = false; }); $('.excitement').on('click', function() { state = !state; state ? fireflies.start() : fireflies.stop(); }); gui.addColor(firefliesConfig, 'fireflyColor').onChange(function() { fireflies.generateTexture(); }); gui.addColor(firefliesConfig, 'backgroundColor').onChange(function(val) { fireflies.app.renderer.backgroundColor = val; }); //gui.add(firefliesConfig, 'blendMode', PIXI.BLEND_MODES); gui.add(firefliesConfig, 'blendMode', { NORMAL: PIXI.BLEND_MODES.NORMAL, ADD: PIXI.BLEND_MODES.ADD, MULTIPLY: PIXI.BLEND_MODES.MULTIPLY, SCREEN: PIXI.BLEND_MODES.SCREEN }); gui.add(firefliesConfig, 'radius', 2, 100).onChange(function() { fireflies.generateTexture(); }); gui.add(firefliesConfig, 'blur', 0, 1).onChange(function() { fireflies.generateTexture(); }); gui.add(firefliesConfig, 'fireflyCount', 1000, 10000, 1); gui.add(firefliesConfig, 'spawnRate', 1, 10, 1); gui.add(firefliesConfig, 'simplexStart', 0, 100, 1); gu.........完整代码请登录后点击上方下载按钮下载查看
网友评论0