Morphiq

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.json

Model

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

PropertyTypeDefaultDescription
srcstring—Image URL. Cross-origin images need CORS for their pixels to be read.
altstring''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.
cellnumber6Screen 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].
gcrnumber0.8Grey-component replacement, 0..1: how much shared grey prints as black.
paperstring'#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.
focusXnumber0.5Horizontal alignment of the image within the box, 0..1.
focusYnumber0.5Vertical alignment of the image within the box, 0..1.
loupenumber90Radius of the loupe under the pointer, finger or arrow keys, px. 0 turns it off.
magnificationnumber3Loupe magnification.
pressnumber1.5How much closer a held press (or Space / Enter) looks, × magnification. 1 turns it off.
risenumber280Time for the glass to come up to its height, ms. 0 is at once.
trailnumber30How far the glass trails a moving hand, ms. 0 pins it to the pointer.
resolutionnumber2Device-pixel-ratio cap for the canvas.