@ramme-io/kernel 7.1.0 → 7.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -38,6 +38,27 @@ export interface QuantizeResult {
|
|
|
38
38
|
/** One hex character per pixel, one line per row — feed to gridToSprite. */
|
|
39
39
|
grid: string;
|
|
40
40
|
}
|
|
41
|
+
export interface QuantizeOptions {
|
|
42
|
+
/**
|
|
43
|
+
* `'ordered'` scatters a fixed 4x4 pattern of small offsets over the picture
|
|
44
|
+
* before each pixel is matched to the palette, so a smooth area between two
|
|
45
|
+
* palette colours becomes a fine checker of both rather than a hard band.
|
|
46
|
+
* It is the look of an old game console or a GIF, which is what the owner
|
|
47
|
+
* asked photos on a board to look like (issue 214).
|
|
48
|
+
*
|
|
49
|
+
* Ordered (Bayer) rather than error diffusion (Floyd–Steinberg) on purpose:
|
|
50
|
+
* each pixel depends only on its own position, so the result is stable —
|
|
51
|
+
* moving the crop by one pixel does not reshuffle noise across the whole
|
|
52
|
+
* picture, and the same input always gives the same bytes, which the photo's
|
|
53
|
+
* hash depends on.
|
|
54
|
+
*
|
|
55
|
+
* The palette is chosen from the undithered picture either way; dithering
|
|
56
|
+
* only changes which entry each pixel is given.
|
|
57
|
+
*/
|
|
58
|
+
dither?: 'none' | 'ordered';
|
|
59
|
+
/** How far the pattern pushes a channel, 0–255. Higher is grainier. Default 32. */
|
|
60
|
+
ditherStrength?: number;
|
|
61
|
+
}
|
|
41
62
|
/**
|
|
42
63
|
* Reduce an RGBA buffer to a small palette and a grid of indices.
|
|
43
64
|
*
|
|
@@ -46,5 +67,5 @@ export interface QuantizeResult {
|
|
|
46
67
|
* dropped: a sprite has no alpha channel, so transparency has to become a
|
|
47
68
|
* colour, and entry 0 is the one a document is expected to use as its ground.
|
|
48
69
|
*/
|
|
49
|
-
export declare const quantize: (rgba: Uint8ClampedArray | number[], width: number, height: number, maxColors?: number) => QuantizeResult;
|
|
70
|
+
export declare const quantize: (rgba: Uint8ClampedArray | number[], width: number, height: number, maxColors?: number, options?: QuantizeOptions) => QuantizeResult;
|
|
50
71
|
//# sourceMappingURL=quantize.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quantize.d.ts","sourceRoot":"","sources":["../../../../src/apps/quantize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,0EAA0E;AAC1E,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC;AAEhC,MAAM,WAAW,cAAc;IAC7B,qEAAqE;IACrE,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,4EAA4E;IAC5E,IAAI,EAAE,MAAM,CAAC;CACd;
|
|
1
|
+
{"version":3,"file":"quantize.d.ts","sourceRoot":"","sources":["../../../../src/apps/quantize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,0EAA0E;AAC1E,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC;AAEhC,MAAM,WAAW,cAAc;IAC7B,qEAAqE;IACrE,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,4EAA4E;IAC5E,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,eAAe;IAC9B;;;;;;;;;;;;;;;OAeG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,mFAAmF;IACnF,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAyCD;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,GACnB,MAAM,iBAAiB,GAAG,MAAM,EAAE,EAClC,OAAO,MAAM,EACb,QAAQ,MAAM,EACd,kBAAc,EACd,UAAS,eAAoB,KAC5B,cAgGF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quantize.test.d.ts","sourceRoot":"","sources":["../../../../src/apps/quantize.test.ts"],"names":[],"mappings":""}
|