网点图像

New

把任意位图在 canvas 上渲染成印刷网点:明暗决定网点大小,网格可旋转(45° 才是印刷味),圆点或方点、疏密可调。再给一张彩色版,灰网点便在悬停时交叉淡入彩色版,每个点取它所在位置的颜色。点与点之间透明,可直接叠在任何表面上。

cell 4 · fine
cell 7 · 45° screen
cell 9 · square, 0°

Hover any plate: the grey screen crossfades to a colour one, each dot inked with the tone it sits on.

安装

用 shadcn CLI 添加,或手动复制源码。

$ bunx --bun shadcn add @uilab/halftone-image

API 参考

src
string

Source bitmap. Any image the browser can decode; it is screened, not displayed.

colorSrc?
string

Optional second plate revealed on hover. Same framing as `src` — usually the colour original against a desaturated `src`. Omit for a screen that never changes; on touch devices it is never rendered, since there is no hover.

alt
string

Describes the picture. The canvases are hidden from AT; the wrapper carries this.

cell?
number

Grid pitch in CSS px — the screen's coarseness. 4–6 reads as print, 10+ as a poster.

6
dotScale?
number

Largest dot as a fraction of `cell`. Above ~0.7 the darkest dots touch and the grid closes up.

0.62
angle?
number

Screen rotation in degrees. Print screens sit at 45° so the grid stops reading as rows.

45
shape?
"square" | "circle"
circle
invert?
boolean

Screen the inverse: dark dots for a light surface.

false
color?
string

Dot colour. Defaults to the wrapper's computed `color`, so a `text-*` class drives it and it follows the theme.

className?
string

Keep in mind

Some components on this site are inspired by or recreated from existing work across the web. I'm not here to take credit; just to learn, experiment, and sometimes push things a bit further. If something looks familiar and I forgot to mention you, reach out and I'll fix that right away.