性能
需注意帧率: 平均 60 fps,p5 59.5 · 长任务: 0 个,共 0 毫秒,最长 0 毫秒 · 源码 gzip 6.7 KB · 运行时 153 KB
ParticlesMIT图案Bencho
由 Lorenzo Cabra 制作的图案 React 组件。依据 MIT 许可从 Bencho 原样收录,此处为实时预览。
质量报告
等级和分数来自构建或测试时跑过的自动检查。没跑过的项目会标成「未检测」,不会填假数据。
帧率: 平均 60 fps,p5 59.5 · 长任务: 0 个,共 0 毫秒,最长 0 毫秒 · 源码 gzip 6.7 KB · 运行时 153 KB
问题 0 · 读屏: 通过
没有持续动效
无溢出
帧率和长任务是在无界面的 Chromium 里用软件 WebGL 测的,只适合在本站组件之间比较,不代表真机表现。
不适用:静止时没有可见动画;由悬停触发的动画没有测试。
没有 axe-core 违规。

检测于 2026年11月15日 · 数据来自自动脚本,不是手工填写。
按实际尺寸显示。
复制内容以许可声明开头,使用代码时请保留。
<div id="root"></div>:root{--bg:#f6f4f0;--ink:#17181a;--background:40 20% 96%;--foreground:24 10% 8%;--card:0 0% 100%}html,body{min-height:100%;margin:0;background:var(--bg);color:var(--ink)}html,body{height:100%;overflow:hidden}body{display:grid;place-items:center}#root{display:grid;place-items:center;max-width:100%;max-height:100%;box-sizing:border-box;padding:16px;color:hsl(var(--foreground))}#root.full{width:100%;height:100%;padding:0}@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation-play-state:paused!important;transition-duration:0s!important}}
/*
MIT License
Copyright (c) 2026 Lorenzo Cabra
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
---
Not covered by this licence: the Bencho name and the goat mark, and the
photographs shown on bencho.dev (none are included here). Third-party
material keeps its own licence; see THIRD_PARTY.md.
Icon substitution (this copy only): lucide-react (ISC) was replaced with @tabler/icons-react (MIT).
Sample photographs were replaced with Incidental AI assets. The Bencho name and goat mark are not licensed for marketing use.
*/
/* ── Bencho tokens ─────────────────────────────────────────
The custom properties the free blocks read, at the values
bencho.dev draws them with. Light by default; dark under
[data-theme="dark"] on any ancestor, or automatically with
the system setting unless [data-theme="light"] says otherwise.
Map these to your own theme rather than keeping two: a block
only ever reads the names, never the values. */
:root {
--font-ui: "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;
--bg: #ffffff;
--board: #ffffff;
--card: #f7f7f6;
--surface: #f7f7f6;
--surface-2: #f1f1f0;
--surface-3: #ecebe7;
--ink: #17181a;
--ink-rgb: 23, 24, 26;
--ink-2: #3c3b37;
--ink-3: #5c5b56;
--ink-4: #6f6e68;
--ink-5: #85847e;
--on-ink: #ffffff;
--on-ink-rgb: 255, 255, 255;
--slab: #17181a;
--on-slab: #ffffff;
--slab-dark: #0e0f11;
--fill-slab: #ffffff;
--fill-on: #17181a;
--fill-on-rgb: 23, 24, 26;
--pane: var(--fill-slab);
--pane-edge: rgba(23, 24, 26, 0.08);
--pane-thumb: rgba(23, 24, 26, 0.07);
--inlay: rgba(255, 255, 255, 0.55);
--inlay-hi: rgba(23, 24, 26, 0.09);
--elev-rgb: 255, 255, 255;
--glass-rgb: 255, 255, 255;
--shadow-rgb: 23, 24, 26;
--wash: 0.06;
--pick: #0d99ff;
--signal: #2231dd;
--focus: #2231dd;
--ok: #15803d;
--ember: #b8431c;
color-scheme: light;
}
[data-theme="dark"] {
--bg: #000000;
--board: #1a1a1a;
--card: #0a0a0a;
--surface: #0f0f0f;
--surface-2: #181818;
--surface-3: #202020;
--ink: #ffffff;
--ink-rgb: 255, 255, 255;
--ink-2: #b4b4b4;
--ink-3: #9a9a9a;
--ink-4: #828282;
--ink-5: #6b6b6b;
--on-ink: #000000;
--on-ink-rgb: 0, 0, 0;
--slab: #1a1a1a;
--on-slab: #ffffff;
--slab-dark: #262626;
--fill-slab: #262626;
--fill-on: #ffffff;
--fill-on-rgb: 255, 255, 255;
--pane-edge: rgba(255, 255, 255, 0.08);
--pane-thumb: rgba(255, 255, 255, 0.07);
--inlay: rgba(255, 255, 255, 0.1);
--inlay-hi: rgba(255, 255, 255, 0.09);
--elev-rgb: 32, 32, 32;
--shadow-rgb: 0, 0, 0;
--wash: 0.09;
--pick: #3aa9ff;
--ok: #34d17a;
color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
:root:not([data-theme="light"]) {
--bg: #000000;
--board: #1a1a1a;
--card: #0a0a0a;
--surface: #0f0f0f;
--surface-2: #181818;
--surface-3: #202020;
--ink: #ffffff;
--ink-rgb: 255, 255, 255;
--ink-2: #b4b4b4;
--ink-3: #9a9a9a;
--ink-4: #828282;
--ink-5: #6b6b6b;
--on-ink: #000000;
--on-ink-rgb: 0, 0, 0;
--slab: #1a1a1a;
--on-slab: #ffffff;
--slab-dark: #262626;
--fill-slab: #262626;
--fill-on: #ffffff;
--fill-on-rgb: 255, 255, 255;
--pane-edge: rgba(255, 255, 255, 0.08);
--pane-thumb: rgba(255, 255, 255, 0.07);
--inlay: rgba(255, 255, 255, 0.1);
--inlay-hi: rgba(255, 255, 255, 0.09);
--elev-rgb: 32, 32, 32;
--shadow-rgb: 0, 0, 0;
--wash: 0.09;
--pick: #3aa9ff;
--ok: #34d17a;
color-scheme: dark;
}
}
/* Particles.css */
/*
MIT License
Copyright (c) 2026 Lorenzo Cabra
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
---
Not covered by this licence: the Bencho name and the goat mark, and the
photographs shown on bencho.dev (none are included here). Third-party
material keeps its own licence; see THIRD_PARTY.md.
Icon substitution (this copy only): lucide-react (ISC) was replaced with @tabler/icons-react (MIT).
Sample photographs were replaced with Incidental AI assets. The Bencho name and goat mark are not licensed for marketing use.
*/
/* ══ Particles ═════════════════════════════════════════════
lab/Particles.tsx. The dots are drawn on a canvas in the
element's own `color`, so the ink is set here and the theme
carries it. */
.ptc {
position: relative;
display: grid;
place-items: center;}
.ptc-canvas {
display: block;
color: var(--fill-on, var(--ink));
cursor: crosshair;
touch-action: none;}
// bencho source (MIT). npm i motion react · Tailwind CSS v4
// ── blocks/particles/Particles.tsx (https://github.com/cabralorenzo/bencho/blob/c65992417427bb09e661674ffa800bef29adef49/blocks/particles/Particles.tsx)
/*
MIT License
Copyright (c) 2026 Lorenzo Cabra
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
---
Not covered by this licence: the Bencho name and the goat mark, and the
photographs shown on bencho.dev (none are included here). Third-party
material keeps its own licence; see THIRD_PARTY.md.
Icon substitution (this copy only): lucide-react (ISC) was replaced with @tabler/icons-react (MIT).
Sample photographs were replaced with Incidental AI assets. The Bencho name and goat mark are not licensed for marketing use.
*/
import { useEffect, useRef } from "react";
/* ══ Particles ════════════════════════════════════════════
A shape made of dots. Move over it and the dots are pushed
away from the pointer and spring home behind it; press and a
shockwave throws them out, and they gather again into the
NEXT shape — circle, square, flower, round again.
── ONE SET OF DOTS, MANY SHAPES ────────────────────────
The dots never change, only where home is. Every shape is
sampled to the same number of points, and a change of shape
pairs each dot with a new home by angle round the middle, so
the swarm sweeps round into the new outline rather than
crossing itself.
── STRETCHED BY SPEED ──────────────────────────────────
A dot at rest is round; a moving one is drawn a little long
along the way it is going, which is what makes a burst read
as a splash rather than a scatter of points. */
/* ── inlined from lab/spring ──────────────────────── */
/* ── one spring, for everything that settles ───────────────
The maths was already on this bench twice, copied by hand:
Humidity's wheel and Brightness's column both accumulate
velocity toward a target, damp it, and snap when both the
delta and the velocity fall under 0.02. Two copies is a
coincidence; five would be a policy, so it comes out here
before the elastic blocks are written against it.
The two shipped copies are deliberately NOT refactored onto
this. They work, they are tuned, and rewriting the innards
of two live components to prove a point about duplication
is how a good afternoon becomes a bad one. This is the one
new code uses.
Frames, not milliseconds. `dt` is expressed in sixtieths of
a second and the damping is RAISED to it rather than
multiplied by it, so a dropped frame decays the same amount
of energy as the two frames it replaced. Multiplying is the
version that makes a spring behave differently on a busy
page, which is the hardest kind of bug to see.
The loop parks itself the moment the value has settled.
CLAUDE.md is not complimentary about the one permanent
requestAnimationFrame already on this bench and there is no
case for five more. */
/* Read once, the way the wheel and the pill nav do. A
preference, not a live input. */
const stillness = () =>
typeof window !== "undefined" &&
!!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
const W = 480;
const H = 400;
const CX = W / 2;
const CY = H / 2;
/* how many dots every shape is sampled to */
const N = 720;
export const SHAPES = ["Circle", "Square", "Flower"] as const;
type Shape = (typeof SHAPES)[number];
type Dot = { hx: number; hy: number; x: number; y: number; vx: number; vy: number };
const clamp = (v: number, a: number, b: number) => Math.min(b, Math.max(a, v));
function outline(s: Shape): Path2D {
const p = new Path2D();
if (s === "Circle") p.arc(CX, CY, 150, 0, Math.PI * 2);
else if (s === "Square") p.roundRect(CX - 140, CY - 140, 280, 280, 36);
else {
/* five round petals round a smaller middle — circles drawn
the same way round, so the fill is their union. Petals
just touching their neighbours, so the notches between
them read at the dots' own grain */
for (let i = 0; i < 5; i++) {
const a = -Math.PI / 2 + (i * Math.PI * 2) / 5;
const x = CX + Math.cos(a) * 104;
const y = CY + 8 + Math.sin(a) * 104;
p.moveTo(x + 60, y);
p.arc(x, y, 60, 0, Math.PI * 2);
}
p.moveTo(CX + 58, CY + 8);
p.arc(CX, CY + 8, 58, 0, Math.PI * 2);
}
return p;
}
/* ── N points, spread evenly over the inside of a shape ──
A hex grid spaced so the shape holds about N of them — its
area over N, which is the spacing that fills it evenly — then
trimmed or topped up to exactly N. It was a fixed fine grid
thinned by a stride, and the stride beat against the grid:
the circle came out in zigzag bands. */
function homes(s: Shape): [number, number][] {
const c = document.createElement("canvas");
c.width = W;
c.height = H;
const g = c.getContext("2d")!;
const path = outline(s);
let area = 0;
for (let y = 1; y < H; y += 2) for (let x = 1; x < W; x += 2) if (g.isPointInPath(path, x, y)) area += 4;
const sp = Math.sqrt((area / N) * (2 / Math.sqrt(3)));
const rowH = (sp * Math.sqrt(3)) / 2;
const pts: [number, number][] = [];
for (let y = rowH / 2, row = 0; y < H; y += rowH, row++) {
for (let x = sp / 2 + (row % 2) * (sp / 2); x < W; x += sp) {
if (g.isPointInPath(path, x, y)) pts.push([x, y]);
}
}
/* within a few of N either way; drop evenly or repeat evenly */
const out: [number, number][] = [];
for (let i = 0; i < N; i++) out.push(pts[Math.floor((i * pts.length) / N)]);
return out;
}
const angle = (x: number, y: number) => Math.atan2(y - CY, x - CX);
export function Particles({
/* the shape it opens as */
shape = "Circle",
/* how far the pointer's push reaches, px */
reach = 80,
/* how hard it pushes, 0..100 */
force = 60,
/* the size of a dot */
grain = "Fine",
}: {
shape?: string;
reach?: number;
force?: number;
grain?: string;
} = {}) {
const still = stillness();
const cv = useRef<HTMLCanvasElement | null>(null);
const dots = useRef<Dot[]>([]);
const at = useRef<Shape>("Circle");
const hand = useRef<{ x: number; y: number } | null>(null);
const raf = useRef(0);
const knobs = useRef({ reach, force, grain });
knobs.current = { reach, force, grain };
/* ── give every dot a home in a shape ────────────────── */
const become = (s: Shape) => {
at.current = s;
const next = homes(s);
const ds = dots.current;
if (!ds.length) {
dots.current = next.map(([x, y]) => ({ hx: x, hy: y, x, y, vx: 0, vy: 0 }));
return;
}
/* pair by angle round the middle, so the swarm sweeps */
const a = ds.map((d, i) => [angle(d.x, d.y), i] as const).sort((p, q) => p[0] - q[0]);
const b = next.map((h, i) => [angle(h[0], h[1]), i] as const).sort((p, q) => p[0] - q[0]);
a.forEach(([, di], k) => {
const h = next[b[k][1]];
ds[di].hx = h[0];
ds[di].hy = h[1];
if (still) { ds[di].x = h[0]; ds[di].y = h[1]; }
});
};
const draw = () => {
const c = cv.current;
if (!c) return;
const x = c.getContext("2d")!;
const k = c.width / W;
x.setTransform(k, 0, 0, k, 0, 0);
x.clearRect(0, 0, W, H);
x.fillStyle = getComputedStyle(c).color;
const r = knobs.current.grain === "Coarse" ? 2.7 : 1.9;
x.beginPath();
for (const d of dots.current) {
const sp = Math.hypot(d.vx, d.vy);
if (sp < 0.3) {
x.moveTo(d.x + r, d.y);
x.arc(d.x, d.y, r, 0, Math.PI * 2);
} else {
/* long along its path, a little thin across it */
const s = Math.min(2.6, 1 + sp * 0.12);
const rot = Math.atan2(d.vy, d.vx);
x.moveTo(d.x + Math.cos(rot) * r * s, d.y + Math.sin(rot) * r * s);
x.ellipse(d.x, d.y, r * s, r / Math.sqrt(s), rot, 0, Math.PI * 2);
}
}
x.fill();
};
const run = () => {
if (raf.current) return;
let prev = 0;
const tick = (t: number) => {
const dt = prev ? clamp((t - prev) / 16.67, 0, 2.5) : 1;
prev = t;
const h = hand.current;
const R = clamp(knobs.current.reach, 30, 160);
const S = (clamp(knobs.current.force, 0, 100) / 100) * 11;
let busy = !!h;
for (const d of dots.current) {
if (h) {
const dx = d.x - h.x;
const dy = d.y - h.y;
const dd = Math.hypot(dx, dy);
if (dd < R && dd > 0.01) {
const f = Math.pow(1 - dd / R, 2) * S;
d.vx += (dx / dd) * f * dt;
d.vy += (dy / dd) * f * dt;
}
}
d.vx = (d.vx + (d.hx - d.x) * 0.05 * dt) * Math.pow(0.84, dt);
d.vy = (d.vy + (d.hy - d.y) * 0.05 * dt) * Math.pow(0.84, dt);
d.x += d.vx * dt;
d.y += d.vy * dt;
if (Math.abs(d.hx - d.x) < 0.05 && Math.abs(d.hy - d.y) < 0.05 && Math.abs(d.vx) < 0.02 && Math.abs(d.vy) < 0.02) {
d.x = d.hx; d.y = d.hy; d.vx = 0; d.vy = 0;
} else busy = true;
}
draw();
raf.current = busy ? requestAnimationFrame(tick) : 0;
};
raf.current = requestAnimationFrame(tick);
};
/* set up once, then follow the Shape knob */
useEffect(() => {
const c = cv.current;
if (!c) return;
const dpr = Math.min(2, window.devicePixelRatio || 1);
c.width = Math.round(W * dpr);
c.height = Math.round(H * dpr);
}, []);
useEffect(() => {
const s = (SHAPES as readonly string[]).includes(shape) ? (shape as Shape) : "Circle";
become(s);
draw();
run();
}, [shape]);
useEffect(() => { draw(); }, [grain]);
useEffect(() => () => { cancelAnimationFrame(raf.current); raf.current = 0; }, []);
useEffect(() => {
const mo = new MutationObserver(() => draw());
mo.observe(document.documentElement, { attributes: true, attributeFilter: ["data-theme"] });
return () => mo.disconnect();
}, []);
const where = (e: React.PointerEvent) => {
const r = e.currentTarget.getBoundingClientRect();
const k = r.width / W;
return { x: (e.clientX - r.left) / k, y: (e.clientY - r.top) / k };
};
return (
<div className="ptc">
<canvas
ref={cv}
className="ptc-canvas"
style={{ width: W, height: H }}
role="img"
aria-label="A shape made of dots. Move over it; press to change the shape."
onPointerMove={(e) => {
if (still) return;
hand.current = where(e);
run();
}}
onPointerLeave={() => { hand.current = null; run(); }}
onPointerDown={(e) => {
/* the shockwave, then the next shape */
const p = where(e);
if (!still) {
const S = 0.4 + (clamp(knobs.current.force, 0, 100) / 100) * 1.2;
for (const d of dots.current) {
const dx = d.x - p.x;
const dy = d.y - p.y;
const dd = Math.hypot(dx, dy);
if (dd > 200 || dd < 0.01) continue;
const f = (1 - dd / 200) * 30 * S;
d.vx += (dx / dd) * f;
d.vy += (dy / dd) * f;
}
}
become(SHAPES[(SHAPES.indexOf(at.current) + 1) % SHAPES.length]);
draw();
run();
}}
/>
</div>
);
}控件 · HTML · CSS · JS
直接改代码,再用控件微调,预览会随输入实时更新。

在线编辑每个组件,用控件微调,下载完整源码,复制进阶提示词。
一次性 $49占位价格
测试模式:不会真实扣款。
免费:预览、复制按钮和课程说明。
重复的图案增加质感,又不和文字抢戏。
首屏背景、分区分隔和空白区域。
缩放图块大小、降低对比度、选两种颜色。
把 Bencho (github.com/cabralorenzo/bencho)(MIT)中的「粒子」组件加入我的 React + Tailwind CSS 应用。源文件:https://github.com/cabralorenzo/bencho/blob/c65992417427bb09e661674ffa800bef29adef49/blocks/particles/Particles.tsx。重复的图案增加质感,又不和文字抢戏。 适用场景:首屏背景、分区分隔和空白区域。 可调参数:缩放图块大小、降低对比度、选两种颜色。 支持浅色与深色主题,遵循 prefers-reduced-motion。保留 MIT 许可声明。
更完整的提示词,包含调参、无障碍和接入步骤。