Toggle navigation
在线编辑器
在线代码
文本比较
jQuery下载
前端库
在线手册
登录/注册
下载代码
html
css
js
分享到微信朋友圈
X
html
css
body { margin: 0; height: 100vh; display: flex; overflow: hidden; background: black; } canvas { margin: auto; touch-action: none; filter: drop-shadow(0px 0px 3px rgba(0, 228, 233, 0.7)); }
JavaScript
console.clear(); const particles = []; const amount = innerWidth < 600 || innerHeight < 600 ? 1000 : 2000; const durationShrink = 8; const durationGrow = 8; const total = durationShrink + durationGrow; const theme = ['#393e46', '#00adb5', '#393e46', '#00adb5', '#e6eeef']; // we'll tween the values in this proxy object. "progress" is for the overall progress of the movement around the circle, and "val" is for the individual grow/shrink stuff. // This technique was kindly provided by Jack from Greensock const proxy = { progress: 1, val: 0 }; // for the movement around the circle const progress = gsap.to(proxy, { progress: 0, ease: "none", duration: total, repeat: -1 }); // for the interpolation of each dot's movement (resuse) const interpolator = gsap.timeline({ paused: true, reverse: true }).to(proxy, { val: 1, duration: durationShrink, ease: 'elastic.in(1.5, 0.15)' }).to(proxy, { val: 0, duration: durationGrow, ease: 'back.in(3)' }); class P { constructor (i) { this.i = i; this.cos = cos(i * TWO_PI); this.sin = sin(i * TWO_PI); this.r = floor(random(2, 8)); this.offset = pow(random(1, 2), 2.5) * random(-0.015, 0.015); this.color = random(theme); } draw () { interpolator.progress((proxy.progress + this.i) % 1); let r = width * (0.35 + (proxy.val * this.offset)); let x = this.cos * r + width / 2; let y = this.sin * r + width / 2; fill(this.color); circle(x, y, this.r); } } function setup () { const size = min(windowWidth, windowHeight); createCanvas(size, size); noStroke(); if (navigator.userAgent.indexOf('Firefox') < 0) { blendMode(SCREEN); } for(let i = 0; i < amount; i++) { particles.push(new P(i / amount)); } } function windowResized () { const size = min(windowWidth, windowHeight); resizeCanvas(size, size); } function touchMoved () { if (touches.length === 0) return; onMove(touches[0].x, touches[0].y); } function mouseMoved () { onMove(mouseX, mouseY); } function onMove (x, y) { let mouseAngle = atan2(y - height / 2, x - width / 2); mouseAngle = mouseAngle < 0 ? mouseAngle + TWO_PI : mouseAngle; mouseAngle = abs(mouseAngle / TWO_PI) * total; progress.time(mouseAngle); } function draw () { clear(); particles.forEach(p => { p.draw(); }); }
粒子
时间
文字
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号