Procedural engravings and the dither that prints them, in TypeScript with no runtime dependencies.

It is the engine behind every image on speyyman.github.io: generators that draw a fern, a sunflower, the moon and eight other subjects from a seed and a few numbers, and a dither that reduces any picture to a handful of tones. The golden tests check that it produces the site's plates bit for bit.
npm install plate-engine
ES modules only, with TypeScript types included. Runs in browsers, web workers and Node 20 or later.
import { generate, renderCPU, palettes, encodeBMP, dither, grayPalette } from 'plate-engine'
// Draw a fern into a 300 × 500 luminance buffer (0 = dark, 1 = light).
const lum = generate('fern', 300, 500, { seed: 7, params: { curl: 0.06 } })
// Dither it to three tones and paint it. Works in browsers, workers and Node.
const image = renderCPU(lum, 300, 500, { method: 'atkinson', palette: palettes.herbarium })
// Or keep the tone indices and save a 4-bit greyscale BMP for an e-paper panel.
const idx = dither(lum, 300, 500, { method: 'floyd-steinberg', levels: 16 })
const bmp = encodeBMP(idx, 300, 500, grayPalette(16), 4)
In a browser, renderAuto uses one shared WebGL1 context for the ordered methods and falls back to the CPU when WebGL is missing or the context is lost. imageToLuminance turns an <img>, ImageBitmap or canvas into a buffer, with the contrast curve the site uses for scanned engravings.
draw(width, height, rng, params) => Float32Array, and documents its parameters (label, description, default, range, step). Defaults reproduce the original plates. Write your own with defineGenerator.CompressionStream; without it the encoder writes valid uncompressed files.
A generator fills a Float32Array of luminance at cell resolution. Ordered methods compare each cell with a threshold from a tiled matrix: with L tones the value is split into L − 1 bands and the threshold picks between the two tones of its band. Error diffusion rounds each cell to the nearest tone and pushes the remainder onto neighbours that have not been visited yet. The blue-noise mask is generated by scripts/gen-blue-noise.mjs (void-and-cluster after Ulichney, 1993) and shipped as data, so nothing is computed at load time.
npm test runs 147 tests:
test/fixtures/site-art (commit recorded in its SOURCE.md), plus stored SHA-256 hashes.pngjs), BMPs parsed field by field, for every depth.npm run bench checks the WebGL output against the CPU output and fails on any difference.
npm run bench; see BENCHMARKS.md). Draw at a coarser cell size and enlarge, and run generators in a worker, as Plate Studio does.MIT. See LICENSE.