Toggle navigation
在线编辑器
在线代码
文本比较
jQuery下载
前端库
在线手册
登录/注册
下载代码
html
css
js
分享到微信朋友圈
X
html
css
* { box-sizing: border-box; } html, body { margin: 0; padding: 0; height: 100vh; width: 100%; } body { width: 100%; height: 100vh; background: #ededed; overflow: hidden; } .support { position: absolute; right: 10px; bottom: 10px; padding: 10px; display: flex; } .support a { margin: 0 10px; color: green; font-size: 1.8rem; backface-visibility: hidden; transition: all 150ms ease; } .support a:hover { transform: scale(1.1); }
JavaScript
console.clear(); let drops = [], droplets = []; let spawnTimeRate = 25; function setup() { createCanvas(innerWidth, innerHeight); } function draw() { background(0); drops.forEach((drop, index) => { drop.update(); if (drop.destroyed) { let n = floor(random(8, 15)); for (let i = 0; i < n; i++) { droplets.push( new Droplets(drop.position.x, drop.position.y, { velocity: p5.Vector.random2D().setMag(random(8, 10)), gravity: createVector(0, 0.1), radius: random(6, 8), timeToLive: 180, friction: 0.2, }) ); } drops.splice(index, 1); } }); droplets.forEach((droplet, index) => { droplet.update(); if (droplet.timeToLive <= 0) droplets.splice(index, 1); }); if (frameCount % spawnTimeRate == 0) { drops.push(new Drop(random(width), random(-100, -200))); spawnTimeRate = floor(random(45, 100)); } } function windowResized() { drops = []; droplets = []; resizeCanvas(innerWidth, innerHeight); } class Drop { constructor(x, y, options = {}) { this.velocity = options.velocity || createVector(random(0, 0), random(-2, 2)); this.position = options.position || createVector(x, y); this.gravity = options.gravity || createVector(0, 0.65); this.friction = options.friction || 0.45; this.radius = options.radius || floor(random(30, 40)); this.decreaseInRadius = options.decreaseInRadius || 10; this.value = String.fromCharCode(0x30a0 + round(random(0, 96))); this.destroyed = false; this.angle = random(TWO_PI); this.color = options.color || "#00ff00"; } draw() { push(); translate(this.position.x, this.position.y); rotate(this.angle); fill(this.color); noStroke(); textSize(this.radius); text(this.value, -this.radius / 2, this.radius / 4); pop(); } update() { if (this.radius <= 0) this.destroyed = true; this.position.add(this.velocity); this.velocity.add(this.gravity); this.draw(); this.edge(); this.angle += 0.05; } edge() { if (this.position.y + this.radius / 2 >= height) { this.velocity.y *= -1 * this.friction; this.radius -= this.decreaseInRadius; this.break(floor(random(2))); } } break (n) { for (let i = 0; i < n; i++) { droplets.push( new Droplets(this.position.x, this.position.y, { velocity: createVector( random(-5, 5), [random(-15, -10), random(10, 15)][floor(random(2))] ), gravity: createVector(0, 0.4), radius: random(6, 10), timeToLive: 200, friction: 0.75, }) ); } } } class Droplets extends Drop { constructor(x, y, options = {}) { super(x, y, options); this.timeToLive = options.timeToLive; } update() { this.color = color(this.color); this.color.setAlpha(this.timeToLive); this.position.add(this.velocity); this.velocity.add(this.gravity); super.draw(); this.edge(); this.timeToLive -= 1; this.angle -= 0.1; } edge() { if (this.position.y + this.radius >= height) { this.velocity.y = -this.velocity.y * this.friction; } } }
粒子
时间
文字
hover
canvas
3d
游戏
音乐
火焰
水波
轮播图
鼠标跟随
动画
css
加载动画
导航
菜单
按钮
滑块
tab
弹出层
统计图
svg
×
Close
在线代码下载提示
开通在线代码永久免费下载,需支付20jQ币
开通后,在线代码模块中所有代码可终身免费下!
您已开通在线代码永久免费下载,关闭提示框后,点下载代码可直接下载!
您已经开通过在线代码永久免费下载
对不起,您的jQ币不足!可通过发布资源 或
直接充值获取jQ币
取消
开通下载
<!doctype html> <html> <head> <meta charset="utf-8"> <title>p5.js矩阵雨-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号