Pointer Particle Field (Repel) new 鼠标粒子扰动 web

Stir the field

radius 70px · push 1.0 · spring 0.035 · damping 0.88

标本可交互,可以直接操作。

Anatomy — every part, named解剖 —— 每个部件的名字

  1. 1 Particle field粒子场 canvas

    Short flakes rest on a jittered grid, each remembering its home.

    短小的碎片静止在带抖动的网格上,各自记住原位。

    Prompt fragmentPrompt 片段

    a few hundred flakes on a jittered grid with stored home positions

    几百片碎片放在抖动网格上并记录原位

  2. 2 Repel radius排斥半径 distance falloff

    Particles inside the radius are pushed away, harder when closer.

    半径内的粒子被推开,越近越用力。

    Prompt fragmentPrompt 片段

    a 70px radius pushing flakes away with distance falloff

    70px 半径内按距离衰减地推开碎片

  3. 3 Spring back弹回 spring + damping

    Each particle is pulled home and slowed until it rests.

    每个粒子被拉回原位并减速,直到静止。

    Prompt fragmentPrompt 片段

    spring 0.035 toward home and damping 0.88 each frame

    每帧以弹力 0.035 拉回原位、阻尼 0.88

  4. 4 Tumble翻滚 rotation

    Flakes rotate and brighten while they move.

    碎片移动时旋转并变亮。

    Prompt fragmentPrompt 片段

    flakes rotating with their velocity and brightening while moving

    碎片按速度旋转,移动时变亮

Prompt — paste into your agentPrompt —— 直接粘贴给你的代理

Build a pointer particle field on a canvas: seed a few hundred short flakes on a jittered grid, each storing a home position; every frame, push particles within a 70px radius away from the pointer with force proportional to closeness, pull each back to its home with spring 0.035, multiply velocity by damping 0.88, and rotate each flake by its velocity so it tumbles. Brighten flakes while they move. Scale the canvas for devicePixelRatio, stop the loop offscreen, and under prefers-reduced-motion draw a still field.

在 canvas 上做一个鼠标粒子场:在带随机抖动的网格上放几百片短小的碎片,每片记住自己的原位;每一帧,把鼠标 70px 半径内的粒子按距离远近推开(越近越用力),再以弹力 0.035 拉回原位、速度乘以阻尼 0.88,并按速度旋转碎片让它翻滚,移动时变亮。按 devicePixelRatio 设置画布尺寸,离开视口时停止循环,prefers-reduced-motion 时画一个静止的粒子场。

Debug prompt — when it misbehaves调试 Prompt —— 当它不听话时

Debug my particle field. Check that the canvas is sized for devicePixelRatio and resized with its container; pointer coordinates are converted to canvas space; force falls off with distance and never divides by zero; spring and damping bring particles to rest without oscillating forever; the loop pauses when offscreen or hidden; particle count stays reasonable on small screens; and reduced motion shows a static field. The symptom:

调试我的粒子场。检查:画布是否按 devicePixelRatio 设置尺寸并随容器缩放;鼠标坐标是否换算到画布坐标;力是否随距离衰减、且不会除以零;弹力和阻尼能否让粒子停下来而不是一直振荡;离开视口或页面隐藏时循环是否暂停;小屏幕上粒子数量是否合理;以及减少动态效果时是否显示静止画面。症状是:

In code代码里叫什么

Framework框架Symbol符号Note说明
Canvas CanvasRenderingContext2D draw hundreds of particles cheaply each frame每帧低成本地画几百个粒子
JS requestAnimationFrame + pointermove a per-frame loop reading the latest pointer position每帧读取最新鼠标位置的循环
Physics spring + damping each particle is pulled to its home and slowed every frame每个粒子被拉回原位,并逐帧减速
tsParticles interactivity.modes.repulse a library route with a built-in repulse mode自带排斥模式的现成库

See also相关词条

我的参考集

组合知名网站、UI 元素、视觉风格和平面设计案例,导出给 AI。

你的下一份设计,从这里开始。

在任意案例旁点击「加入参考」,就能把品牌、组件、风格和平面设计案例组合成一份 AI 设计说明。

搜索参考库Search the library

输入关键词,搜索所有参考。