Image
A picture or a capture, redrawn in five greys and the ember.
- Drawn with
- Canvas 2D
- Chain
- image → pixelate → image-dither → palette
- Code
- @forgeron/shaders: builtInPresets()["role-image"]
/01 → What it is
- Luminance through the 4×4 Bayer matrix to five greys; the ember only where the picture is warm.
- Cropped to cover the canvas, one dithered pixel per 3 CSS pixels: whatever made the picture, it comes out in the system.
/02 → Where Forgeron uses it
| Site | Where | Settings |
|---|---|---|
| forgeron.sh | Landing exploration D, the hero picture (not on a live page today) | canvas[data-dither-img="/lab/hero-forge.png"] data-px="3" |
/03 → Versions
- /01 Hero
pixel 3 · gain 1.1 - /02 Source
the picture, before - /03 Coarse
pixel 5
/04 → Use it
import { DitheredImage } from "@forgeron/ui";
<div style={{ height: 320 }}>
<DitheredImage src="/hero.png" pixel={3} />
</div>import { mountDitheredImage } from "@forgeron/ui";
mountDitheredImage(canvas, "/hero.png", { pixel: 3, gain: 1.1 });{
"$schema": "https://shaders.forgeron.sh/schema/preset.v1.json",
"version": 1,
"name": "role-image",
"source": {
"type": "image"
},
"passes": [
{
"type": "pixelate",
"size": 3
},
{
"type": "image-dither",
"gain": 1.1,
"greys": 5
},
{
"type": "palette",
"tones": [
{
"var": "--bg",
"fallback": "#0a0a0a"
},
{
"var": "--line-strong",
"fallback": "#2e2e2e"
},
{
"var": "--ink-dim",
"fallback": "#5e5e5e"
},
{
"var": "--ink-muted",
"fallback": "#8f8f8f"
},
{
"var": "--ink",
"fallback": "#ededed"
},
{
"var": "--accent",
"fallback": "#ff4f1f"
}
],
"transparent": []
}
]
}API → Options
| Option | Type | Default | Description |
|---|---|---|---|
src | string | — | The picture. On a load error the canvas hides itself. |
pixel | number | 3 | Side of one dithered pixel in CSS pixels. |
gain | number | 1.1 | Luminance gain before dithering. |