Toggle navigation
在线编辑器
在线代码
文本比较
jQuery下载
前端库
在线手册
登录/注册
下载代码
html
css
js
分享到微信朋友圈
X
html
css
html,body { margin:0; padding:0; } canvas { background-color:#030722; width:100%; height:100%; }
JavaScript
window.setInterval(onCanvasClick, 6000); ccc.addEventListener("click",onCanvasClick); var Configs = { backgroundColor: '#030722', particleNum: 700, step: 17, base: 3000, zInc: 0.000009 }; // Vars var fadeTime = 2000; // in ms var fadeTimeStart; var canvas; var context; var screenWidth; var screenHeight; var centerX; var centerY; var particles = []; var hueBase = 0; var simplexNoise; var zoff = 0; var gui; var can2; var ctx2; // Initialize function init() { canvas = document.getElementById('ccc'); can2 = document.createElement("canvas"); ctx = can2.getContext("2d"); ctx2 = canvas.getContext("2d"); window.addEventListener('resize', onWindowResize, false); onWindowResize(null); for (var i = 0, len = Configs.particleNum; i < len; i++) { initParticle((particles[i] = new Particle())); } simplexNoise = new SimplexNoise(); canvas.addEventListener('click', onCanvasClick, true); gui = new dat.GUI(); gui.add(Configs, 'step', 1, 5); gui.add(Configs, 'base', 1500, 4000); gui.add(Configs, 'zInc', 0.001, 0.01); gui.close(); requestAnimationFrame(update); ctx.lineWidth = 0.7; ctx.lineCap = ctx.lineJoin = 'round'; ctx.fillStyle = Configs.backgroundColor; ctx.fillRect(0, 0, screenWidth, screenHeight); } // Event listeners function onWindowResize(e) { can2.width = screenWidth = canvas.width = window.innerWidth; can2.height = screenHeight = canvas.height = window.innerHeight; centerX = screenWidth / 10; centerY = screenHeight / 10; } function onCanvasClick(e) { ctx.globalAlpha = 0.9; ctx.fillStyle = Configs.backgroundColor; ctx.fillRect(0, 0, screenWidth, screenHeight); simplexNoise = new SimplexNoise(); fadeTimeStart = undefined; } // Functions function getNoise(x, y, z) { var octaves = 2, fallout = 0.5, amp = 1, f = 1, sum = 1, i; for (i = 0; i < octaves; ++i) { amp *= fallout; sum += amp * (simplexNoise.noise3D(x * f, y * f, z * f) + 1) * 4.4; f *= 3; } return sum; } function initParticle(p) { p.x = p.pastX = screenWidth * Math.random(); p.y = p.pastY = screenHeight * Math.random(); p.color.h = hueBase + Math.atan2(centerY - p.y, centerX - p.x) * 200 / Math.PI; p.color.s = 1; p.color.l = 0.6; p.color.a = 0; } // Update function update(time) { var step = Configs.step; var base = Configs.base; var i, p, angle; for (i = 0; i < particles.length; i++) { p = particles[i]; p.pastX = p.x; p.pastY = p.y; angle = Math.PI * 6 * getNoise(p.x / base * 1.75, p.y / base * 1.75, zoff); p.x += Math.cos(angle) * step; p.y += Math.sin(angle) * step; if (p.color.a < 1) p.color.a += 0.001; ctx.beginPath(); ctx.strokeStyle = p.color.toString(); ctx.moveTo(p.pastX, p.pastY); ctx.lineTo(p.x, p.y); ctx.stroke(); if (p.x < 0 || p.x > screenWidth || p.y < 0 || p.y > screenHeight) { initParticle(p); } } hueBase += 0.4; zoff += Configs.zInc; // Code to fade in the view if(fadeTimeStart === undefined){ fadeTimeStart = time; } var fTime = (time - fadeTimeStart) / fadeTime; if(fTime < 1){ ctx2.globalAlpha = fTime; ctx2.clearRect(0,0,canvas.width,canvas.height); ctx2.drawImage(can2,0,0); }else{ ctx2.globalAlpha = 1; ctx2.drawImage(can2,0,0); } requestAnimationFrame(update); } /** * HSLA */ function HSLA(h, s, l, a) { this.h = h || 0; this.s = s || 0; this.l = l || 0; this.a = a || 0; } HSLA.prototype.toString = function() { return 'hsla(' + this.h + ',' + (this.s * 100) + '%,' + (this.l * 100) + '%,' + this.a + ')'; } /** * Particle */ function Particle(x, y, color) { this.x = x || 0; this.y = y || 0; this.color = color || new HSLA(); this.pastX = this.x; this.pastY = this.y; } // Run init();
粒子
时间
文字
hover
canvas
3d
游戏
音乐
火焰
水波
轮播图
鼠标跟随
动画
css
加载动画
导航
菜单
按钮
滑块
tab
弹出层
统计图
svg
×
Close
在线代码下载提示
开通在线代码永久免费下载,需支付20jQ币
开通后,在线代码模块中所有代码可终身免费下!
您已开通在线代码永久免费下载,关闭提示框后,点下载代码可直接下载!
您已经开通过在线代码永久免费下载
对不起,您的jQ币不足!可通过发布资源 或
直接充值获取jQ币
取消
开通下载
<!doctype html> <html> <head> <meta charset="utf-8"> <title>抽象噪声微粒-jq22.com</title> <script src="https://www.jq22.com/jquery/jquery-1.10.2.js"></script> <style>
</style> </head> <body>
<script>
</script>
</body> </html>
2012-2021 jQuery插件库版权所有
jquery插件
|
jq22工具库
|
网页技术
|
广告合作
|
在线反馈
|
版权声明
沪ICP备13043785号-1
浙公网安备 33041102000314号