Components / Animations / Halftone Screen
Halftone Screen
An image in four-colour process halftone, the way a press prints it. Cyan, magenta, yellow and black are each screened on their own grid at 15°, 75°, 0° and 45°, which is what turns their interference into a rosette instead of a moiré. Coverage is dot area, not radius: past r = ½ a round dot is clipped by its cell, and the radius is solved from that clipped area, so 30% ink covers 30% of the paper. Hover for a loupe and press to lean in; Tab to it and the arrow keys carry the glass; on touch, tap for a look or hold and drag.
Usage
import HalftoneScreen from '@/components/halftone-screen'
<HalftoneScreen src={photo} alt="Describe the picture" cell={6} />Installation
npx shadcn@latest add https://morphiq.prathampatel.design/r/halftone-screen.jsonModel
A(r) = πr² − 4·(r²·acos(1/2r) − ½√(r² − ¼)), r > ½the area a round dot of radius r covers once its cell clips it
Props
| Property | Type | Default | Description |
|---|---|---|---|
src | string | — | Image URL. Cross-origin images need CORS for their pixels to be read. |
alt | string | '' | Names the picture, as on an <img>. Empty marks it decorative. A named picture with a loupe is a tab stop: arrows carry the glass, Space or Enter leans in, Escape puts it down. |
cell | number | 6 | Screen period, px. Smaller is a finer screen. |
angles | [number, number, number, number] | [15, 75, 0, 45] | Screen angle of each ink, degrees: [cyan, magenta, yellow, black]. |
gcr | number | 0.8 | Grey-component replacement, 0..1: how much shared grey prints as black. |
paper | string | '#f3eee3' | Paper colour. Any CSS colour. |
inks | [string, string, string, string] | ['#12a4d9', '#dd2a82', '#f7d51d', '#1b1a1f'] | Ink colours: [cyan, magenta, yellow, black]. |
fit | 'cover' | 'contain' | 'cover' | How the image fills the box. |
focusX | number | 0.5 | Horizontal alignment of the image within the box, 0..1. |
focusY | number | 0.5 | Vertical alignment of the image within the box, 0..1. |
loupe | number | 90 | Radius of the loupe under the pointer, finger or arrow keys, px. 0 turns it off. |
magnification | number | 3 | Loupe magnification. |
press | number | 1.5 | How much closer a held press (or Space / Enter) looks, × magnification. 1 turns it off. |
rise | number | 280 | Time for the glass to come up to its height, ms. 0 is at once. |
trail | number | 30 | How far the glass trails a moving hand, ms. 0 pins it to the pointer. |
resolution | number | 2 | Device-pixel-ratio cap for the canvas. |