f32(n: number) → buffer return buffer
| arg | type | description |
|---|
| n | number | |
get(b: buffer, i: number) → number return buffer
| arg | type | description |
|---|
| b | buffer | |
| i | number | |
put(b: buffer, i: number, v: number) → void
| arg | type | description |
|---|
| b | buffer | |
| i | number | |
| v | number | |
smooth(e0: number, e1: number, x: number) → number
| arg | type | description |
|---|
| e0 | number | |
| e1 | number | |
| x | number | |
load(path: string, size: number?) → Img
Decode an image file to float planes (0..1) at most `size` px.
| arg | type | description |
|---|
| path | string | |
| size | number? | |
dup(b: buffer) → buffer local c
| arg | type | description |
|---|
| b | buffer | |
key(img: Img) → Img
Key the flat background out to alpha. The key colour is measured from the image corners; its bright channels (H) against its dark ones (L) give how much of a pixel is background, the background is unmixed out of the edge pixels so no rim of key colour is left, and the transparent area is filled with the nearby leaf colour so mipmaps carry no halo.
sep(c: { number }) → number
| arg | type | description |
|---|
| c | { number } | |
bleed(img: Img) → void
Fill fully transparent pixels with the colour of the nearest card pixels (8 dilation passes, then the card's mean), so filtering and mipmaps never pull the background in.
rgb2hsv(r: number, g: number, b: number) → void
| arg | type | description |
|---|
| r | number | |
| g | number | |
| b | number | |
hsv2rgb(hh: number, s: number, v: number) → void
| arg | type | description |
|---|
| hh | number | |
| s | number | |
| v | number | |
hash(x: number, y: number, seed: number) → number
| arg | type | description |
|---|
| x | number | |
| y | number | |
| seed | number | |
vnoise(x: number, y: number, cell: number, seed: number) → number
| arg | type | description |
|---|
| x | number | |
| y | number | |
| cell | number | |
| seed | number | |
hueLerp(a: number, b: number, t: number) → number
| arg | type | description |
|---|
| a | number | |
| b | number | |
| t | number | |
recolour(src: Img, rc: Recolour) → Img
Recolour the green (leafy) pixels of a card toward a season's palette. Twigs, flowers and berries (not green) are left alone; the noise varies the colour per leaf so an autumn cluster is mottled rather than flat.
| arg | type | description |
|---|
| src | Img | |
| rc | Recolour | |
normalFrom(img: Img, strength: number?) → buffer
A tangent-space normal map (green up) from the card's shading: brightness is read as height, so veins, midribs and overlapping leaves gain relief. Outside the cut-out it is flat.
| arg | type | description |
|---|
| img | Img | |
| strength | number? | |
H(xx: number, yy: number) → number
| arg | type | description |
|---|
| xx | number | |
| yy | number | |
toBytes(img: Img) → buffer
save(name: string, w: number, h: number, bytes: buffer, kind: string, wrap: string?) → any
Write rgba8 bytes as a texture asset in textures/ (PNG source kept). kind: "color" | "normalMap".
| arg | type | description |
|---|
| name | string | |
| w | number | |
| h | number | |
| bytes | buffer | |
| kind | string | |
| wrap | string? | |
bake(name: string, srcPath: string, opts: { seasons: { [string]: Recolour }?, fix: Recolour?, normalStrength: number? }?) → void
Bake one card: key the source picture, save `<name>_albedo` and `<name>_normal`, and a `<name>_<season>_albedo` for each recolour in opts.seasons. Returns the texture names written.
| arg | type | description |
|---|
| name | string | |
| srcPath | string | |
| opts | { seasons: { [string]: Recolour }?, fix: Recolour?, normalStrength: number? }? | |