效能
需注意幀率: 平均 60 fps,p5 59.5 · 長任務: 0 個,共 0 毫秒,最長 0 毫秒 · 原始碼 gzip 9.3 KB · 執行時 159 KB
GenerateMIT按鈕Bencho
由 Lorenzo Cabra 製作的按鈕 React 元件。依據 MIT 授權從 Bencho 原樣收錄,此處為即時預覽。
品質報告
等級和分數來自建置或測試時跑過的自動檢查。沒跑過的項目會標成「未檢測」,不會填假資料。
幀率: 平均 60 fps,p5 59.5 · 長任務: 0 個,共 0 毫秒,最長 0 毫秒 · 原始碼 gzip 9.3 KB · 執行時 159 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;
}
}
/* Generate.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.
*/
/* ══ Generate ══════════════════════════════════════════════
lab/Generate.tsx. A picture card and a pill under it. The
card is a photograph edge to edge, so it answers neither
Fill nor Stroke; the pill is the Step player's slab and
answers both. */
.gen {
font-family: var(--font-ui);
/* POSITIONED, and it is load-bearing on the canvas: a board's
grab halo is a positioned ::before, and a positioned layer
paints over every non-positioned sibling after it — so the
button pill, which is not positioned, sat UNDER the halo
and never heard a click. Making the root positioned puts
the whole block above it in paint order. */
position: relative;
display: flex;
flex-direction: column;
align-items: center;
gap: 12px;}
.gen-card {
position: relative;
width: 270px;
/* 330, down from the picture's own 360 (3:4). The print is
`cover`, so the frame trims a sliver of paper top and
bottom rather than squashing the flower */
height: 330px;
border-radius: 20px;
overflow: hidden;
/* white, the blank page. The print's own paper is a warm grey,
and the run carries the card from one to the other: the
haze fades up over the white, so the page greys as the
picture arrives rather than starting grey. */
background: var(--fill-slab, #ffffff);
/* the corner clips a canvas and an image, and Safari leaks
both past a radius without a layer of its own */
isolation: isolate;}
.gen-canvas,
.gen-print {
position: absolute;
inset: 0;
width: 100%;
height: 100%;}
.gen-print {
object-fit: cover;
user-select: none;
-webkit-user-drag: none;}
/* the filter's defs, out of the flow — an svg with no size is
300x150 of layout otherwise */
.gen-defs {
position: absolute;
width: 0;
height: 0;}
[data-stroke="on"] .gen-card {
box-shadow: 0 0 0 1px var(--pane-edge);}
/* ── the button, in the middle of the frame ─────────────────
Light grey on the white page. It answers the pointer by
size only — a little on hover, more on the press — and
leaves by shrinking and fading when the run starts. Every
colour here is the Fill control's, so Dark gives a dark
frame, a lifted pill and light ink. */
.gen-go {
position: absolute;
left: 50%;
top: 50%;
z-index: 2;
display: flex;
align-items: center;
gap: 8px;
height: 42px;
/* even now there is no icon on the left to balance */
padding: 0 20px;
border: 0;
border-radius: 20px;
background: color-mix(in srgb, var(--fill-on, #17181a) 6%, var(--fill-slab, #ffffff));
font: inherit;
font-size: 14px;
font-weight: 500;
color: var(--fill-on, #17181a);
cursor: pointer;
translate: -50% -50%;
transition: opacity 220ms ease, scale 220ms cubic-bezier(0.22, 1, 0.36, 1);
letter-spacing: -0.01em;}
.gen-go:hover:not(:disabled) { scale: 0.97; }
.gen-go:active:not(:disabled) { scale: 0.96; transition-duration: 160ms; }
.gen-go:focus-visible {
outline: none;
box-shadow: 0 0 0 2px var(--fill-slab, #ffffff), 0 0 0 4px rgba(var(--fill-on-rgb, 23, 24, 26), 0.45);}
/* gone while a picture is being made */
.gen[data-loading="true"] .gen-go {
opacity: 0;
scale: 0.9;
pointer-events: none;}
/* made: out of the way until the pointer is on the picture,
and WHITE over the print — the grey that sits quietly on a
blank page reads as a smudge on a grey halftone */
.gen[data-made="true"]:not([data-loading="true"]) .gen-go {
opacity: 0;
background: var(--fill-slab, #ffffff);}
.gen[data-made="true"]:not([data-loading="true"]) .gen-card:hover .gen-go,
.gen[data-made="true"]:not([data-loading="true"]) .gen-go:focus-visible {
opacity: 1;}
/* ── the count ──────────────────────────────────────────────
A small pill in the bottom-left corner, only while a run is
going (and for the beat it holds at 100). */
.gen-pct {
position: absolute;
left: 10px;
bottom: 10px;
z-index: 2;
display: grid;
place-items: center;
height: 22px;
padding: 0 8px;
border-radius: 999px;
background: color-mix(in srgb, var(--fill-slab, #ffffff) 80%, transparent);
-webkit-backdrop-filter: blur(8px);
backdrop-filter: blur(8px);
font-size: 11px;
font-weight: 500;
line-height: 1;
color: var(--fill-on, #17181a);
font-variant-numeric: tabular-nums;
opacity: 0;
translate: 0 4px;
transition: opacity 220ms ease, translate 220ms ease;
pointer-events: none;
letter-spacing: 0em;}
.gen[data-loading="true"] .gen-pct {
opacity: 1;
translate: 0 0;}
@media (prefers-reduced-motion: reduce) {
.gen-go,
.gen-pct { transition-duration: 160ms; }
}
/* ══ One-time code ═════════════════════════════════════════
lab/Otp.tsx. Everything that moves is written inline; what
is here is the material. Positioned at the root so the
canvas's grab halo does not paint over the field — see the
note on .gen. */
.otp {
position: relative;
font-family: var(--font-ui);
display: grid;
place-items: center;}
/* ══ Label input ═══════════════════════════════════════════
lab/LabelInput.tsx. Positioned at the root for the canvas
halo — see the note on .gen. */
.lbi {
position: relative;
font-family: var(--font-ui);
display: grid;
place-items: center;
/* room above the field for the lifted label */
padding-top: 12px;}
// bencho source (MIT). npm i motion react · Tailwind CSS v4
// ── blocks/generate/Generate.tsx (https://github.com/cabralorenzo/bencho/blob/c65992417427bb09e661674ffa800bef29adef49/blocks/generate/Generate.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, useId, useRef, useState } from "react";
/* ── 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;
/* A drawn placeholder: Bencho's photographs are licensed to
the site and do not travel. Point this at your own. */
const FLOWER: string = "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20800%20800%22%20width%3D%22800%22%20height%3D%22800%22%20preserveAspectRatio%3D%22xMidYMid%20slice%22%3E%0A%3Cdefs%3E%3ClinearGradient%20id%3D%22s%22%20x1%3D%220%22%20y1%3D%220%22%20x2%3D%220%22%20y2%3D%221%22%3E%3Cstop%20offset%3D%220%22%20stop-color%3D%22rgb%28239%2C239%2C241%29%22%2F%3E%3Cstop%20offset%3D%221%22%20stop-color%3D%22rgb%28176%2C176%2C178%29%22%2F%3E%3C%2FlinearGradient%3E%3C%2Fdefs%3E%0A%3Crect%20width%3D%22800%22%20height%3D%22800%22%20fill%3D%22url%28%23s%29%22%2F%3E%0A%3Ccircle%20cx%3D%22210%22%20cy%3D%22177%22%20r%3D%2272%22%20fill%3D%22rgb%28246%2C246%2C248%29%22%2F%3E%0A%3Cpath%20d%3D%22M0%2C800%20L0%2C488.1%20L100%2C432.9%20L200%2C437.7%20L300%2C493.2%20L400%2C492.3%20L500%2C436.8%20L600%2C433.7%20L700%2C489.1%20L800%2C496.0%20L800%2C800%20Z%22%20fill%3D%22rgb%28158%2C158%2C160%29%22%2F%3E%0A%3Cpath%20d%3D%22M0%2C800%20L0%2C585.5%20L100%2C550.7%20L200%2C548.8%20L300%2C582.2%20L400%2C607.6%20L500%2C592.0%20L600%2C555.6%20L700%2C545.7%20L800%2C575.1%20L800%2C800%20Z%22%20fill%3D%22rgb%28121%2C121%2C123%29%22%2F%3E%0A%3Cpath%20d%3D%22M0%2C800%20L0%2C680.5%20L100%2C710.5%20L200%2C697.2%20L300%2C666.2%20L400%2C677.0%20L500%2C708.9%20L600%2C700.6%20L700%2C668.1%20L800%2C673.8%20L800%2C800%20Z%22%20fill%3D%22rgb%2896%2C96%2C98%29%22%2F%3E%0A%3C%2Fsvg%3E";
/* ══ Generate ═════════════════════════════════════════════
A picture that is made in front of you, slowly. Press
Generate and the flower arrives the way a generated image
does — the large decisions first and the fine ones last —
under a glassy liquid surface that stills as it lands.
── THREE SCALES OF DETAIL, IN ORDER ───────────────────
· SHAPES. Heavily blurred and pushed hard in contrast, the
flower is a few clean glassy masses — where the dark is,
nothing more. The contrast is what makes them shapes
rather than fog.
· FORM. The blur lets go on a slow curve and the contrast
eases back to the print's own, so the petals find their
edges and their tones. A low drifting ripple keeps the
surface liquid while it happens.
· GRAIN. The halftone only comes in over the last quarter,
through the print itself. The finest detail is the last
thing decided, which is what makes it read as generated
rather than revealed.
It replaced a version built from halftone dots in passes,
coarse to fine. That read as pixels arriving rather than a
picture forming, and every stage of it was too busy.
── IDENTITY AT REST ────────────────────────────────────
The filter only exists while a run is going. At rest the
card is the print and nothing else, so a wall of these costs
one image each. */
const clamp = (v: number, a: number, b: number) => Math.min(b, Math.max(a, v));
const mix = (a: number, b: number, t: number) => a + (b - a) * t;
const smooth = (a: number, b: number, v: number) => {
const u = clamp((v - a) / (b - a), 0, 1);
return u * u * (3 - 2 * u);
};
/* the print's paper, as a luminance. Contrast turns about THIS
rather than mid-grey: about 0.5 the paper went to white and
the card was a glowing sheet that snapped back to grey at the
end. About the paper, the ground holds and the ink deepens. */
const PAPER = 0.9;
/* ── the count keeps its own time ─────────────────────────
A number climbing at one steady rate reads as a timer, not
as work. So the count runs on a curve of its own, re-rolled
every run: a quick start, a slow stretch, a burst, a stall,
another burst, and a crawl through the last tenth. The
picture still forms on the plain clock underneath — only
the number is uneven, which is how a real one behaves.
Knots are (time, value) pairs, both 0..1 and both rising,
so the count can never go backwards. Between two knots it
is half linear and half smoothstep: speed changes read as
easing rather than as corners, and never quite stop. */
type Knot = [number, number];
const r = (a: number, b: number) => a + Math.random() * (b - a);
const knots = (): Knot[] => [
[0, 0],
[r(0.1, 0.16), r(0.1, 0.16)], /* quick start */
[r(0.32, 0.38), r(0.22, 0.3)], /* slow stretch */
[r(0.44, 0.49), r(0.5, 0.6)], /* burst */
[r(0.56, 0.61), r(0.62, 0.68)], /* stall */
[r(0.68, 0.72), r(0.84, 0.88)], /* burst */
[1, 1], /* and the long last bit */
];
const along = (ks: Knot[], t: number) => {
for (let i = 1; i < ks.length; i++) {
const [t0, v0] = ks[i - 1];
const [t1, v1] = ks[i];
if (t > t1) continue;
const u = clamp((t - t0) / (t1 - t0), 0, 1);
return mix(v0, v1, mix(u, u * u * (3 - 2 * u), 0.5));
}
return 1;
};
export function Generate({
/* seconds from the press to the picture */
pace = 5,
/* how liquid the surface is while it forms, 0..100 */
ripple = 50,
/* the frame's corner, px. The button is a pill at every
setting — the frame is the picture, the pill is a control,
and squaring one is no reason to square the other. */
corner = 20,
}: {
pace?: number;
ripple?: number;
corner?: number;
} = {}) {
const still = stillness();
const id = `gen-${useId().replace(/:/g, "")}`;
const [t, setT] = useState(1);
const raf = useRef(0);
const curve = useRef<Knot[]>(knots());
const busy = t < 1;
/* ── 100 is held for a beat ──────────────────────────────
The run ending and the pill reading "Generate" again on
the same frame means nobody ever sees 100 — the count
would stop at 99 and vanish. So the pill stays a loader
for a moment after the picture lands. */
const [held, setHeld] = useState(false);
/* ── it starts EMPTY ─────────────────────────────────────
A plain frame of paper until the first run. A block about
making a picture that already has the picture in it has
answered its own question before anybody pressed it. Once
made, the print stays, and pressing again remakes it from
blank. */
const [made, setMade] = useState(false);
const hold = useRef(0);
const loading = busy || held;
/* 99 at most until the run has actually finished — the 100
belongs to the picture landing, not to the curve */
const pct = held ? 100 : Math.min(99, Math.floor(along(curve.current, t) * 100));
useEffect(() => () => {
cancelAnimationFrame(raf.current);
raf.current = 0;
window.clearTimeout(hold.current);
}, []);
const generate = () => {
if (loading) return;
const total = still ? 400 : Math.max(2, pace) * 1000;
let t0 = 0;
const tick = (now: number) => {
if (!t0) t0 = now;
const v = Math.min(1, (now - t0) / total);
setT(v);
if (v < 1) raf.current = requestAnimationFrame(tick);
else {
raf.current = 0;
setMade(true);
setHeld(true);
hold.current = window.setTimeout(() => setHeld(false), 650);
}
};
curve.current = knots();
setT(0);
raf.current = requestAnimationFrame(tick);
};
/* ── the three windows ───────────────────────────────────── */
/* one long rise, no pulse: the haze used to breathe while
nothing was decided, and a picture that dims and brightens
before it has started reads as hesitating */
const haze = smooth(0, 0.3, t);
const form = smooth(0.1, 0.82, t);
const grain = smooth(0.7, 1, t);
/* blur falls fast at first and then crawls through the small
radii, which is where the detail actually lives */
const sd = mix(20, 1.6, 1 - Math.pow(1 - form, 2.2));
const k = mix(2.4, 1, form);
const warp = (clamp(ripple, 0, 100) / 100) * 32 * Math.pow(1 - smooth(0.05, 0.9, t), 1.5);
/* a slow drift in the noise so the water moves rather than
sitting as a fixed distortion */
const f = 0.006 + 0.0018 * Math.sin(t * 4.4);
const cut = (PAPER - PAPER * k).toFixed(3);
return (
<div className="gen" data-busy={busy} data-loading={loading} data-made={made}>
<div className="gen-card" style={{ borderRadius: clamp(corner, 0, 40) }}>
{busy && !still && (
<>
<svg className="gen-defs" aria-hidden="true">
<filter id={id} x="-10%" y="-10%" width="120%" height="120%" colorInterpolationFilters="sRGB">
<feTurbulence type="fractalNoise" baseFrequency={`${f.toFixed(4)} ${(f * 1.3).toFixed(4)}`} numOctaves={2} seed={7} result="n" />
<feDisplacementMap in="SourceGraphic" in2="n" scale={warp.toFixed(2)} xChannelSelector="R" yChannelSelector="G" result="d" />
<feGaussianBlur in="d" stdDeviation={sd.toFixed(2)} />
<feComponentTransfer>
<feFuncR type="linear" slope={k.toFixed(3)} intercept={cut} />
<feFuncG type="linear" slope={k.toFixed(3)} intercept={cut} />
<feFuncB type="linear" slope={k.toFixed(3)} intercept={cut} />
</feComponentTransfer>
</filter>
</svg>
<img
className="gen-print"
src={FLOWER}
alt=""
draggable={false}
style={{
filter: `url(#${id})`,
opacity: haze * mix(0.7, 1, form),
scale: `${mix(1.04, 1, smooth(0, 0.9, t))}`,
}}
/>
</>
)}
{/* the print: the whole card at rest once made, and the
grain that arrives last during a run */}
{(made || busy) && <img
className="gen-print"
src={FLOWER}
alt="A flower, printed in halftone"
draggable={false}
style={busy ? {
opacity: still ? t : grain,
filter: still ? undefined : `blur(${mix(1.6, 0, grain).toFixed(2)}px)`,
} : undefined}
/>}
{/* ── the way in, in the middle of the page ───────────
On the blank frame it is the only thing there. Once a
picture is made it steps aside and only comes back
under the pointer, so the print is left clean. */}
<button
className="gen-go"
onClick={generate}
disabled={loading}
tabIndex={loading ? -1 : 0}
aria-label="Generate"
>
<span>Generate</span>
</button>
{/* ── and the count, small, in the corner ─────────────
Just the number going up. Held at 100 for a beat so
it is seen, then it leaves with the run. */}
<span className="gen-pct" role="status" aria-live="off">
{pct}%
</span>
</div>
</div>
);
}控制項 · HTML · CSS · JS
直接改程式碼,再用控制項微調,預覽會隨輸入即時更新。

線上編輯每個元件,用控制項微調,下載完整原始碼,複製進階提示詞。
一次性 $49暫定價格
測試模式:不會真的扣款。
免費:預覽、複製按鈕和課程說明。
清楚的形狀、一種強色和短促的按壓反饋,讓它有實體感。
主要操作、行動號召和工具欄。
改圓角、內邊距和懸停過渡的時長。
把 Bencho (github.com/cabralorenzo/bencho)(MIT)中的「生成按鈕」元件加入我的 React + Tailwind CSS 應用程式。原始檔:https://github.com/cabralorenzo/bencho/blob/c65992417427bb09e661674ffa800bef29adef49/blocks/generate/Generate.tsx。清楚的形狀、一種強色和短促的按壓反饋,讓它有實體感。 適用情境:主要操作、行動號召和工具欄。 可調參數:改圓角、內邊距和懸停過渡的時長。 支援淺色與深色主題,遵循 prefers-reduced-motion。保留 MIT 授權聲明。
更完整的提示詞,包含調參、無障礙和接入步驟。