nucleation 0.3.9 → 0.3.11

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.
package/Palette.d.ts CHANGED
@@ -66,6 +66,15 @@ export class Palette {
66
66
  */
67
67
  static wood(): Palette;
68
68
 
69
+ /**
70
+ * A copy of this palette with ordered dithering enabled: brushes
71
+ * snapping through it alternate between the two nearest blocks per
72
+ * voxel (4x4 Bayer threshold, deterministic in position), which
73
+ * reads as intermediate shades at a distance — the classic map-art
74
+ * trick. Ramp and list queries are unaffected.
75
+ */
76
+ dithered(): Palette;
77
+
69
78
  /**
70
79
  * A copy of this palette ordered by perceptual lightness (Oklab L,
71
80
  * dark → light). Combined with `block_ids_json`, gives a
@@ -111,6 +120,15 @@ export class Palette {
111
120
  */
112
121
  blockIdsJson(): string;
113
122
 
123
+ /**
124
+ * Position-aware dithered snap: the block for the given RGB at
125
+ * voxel (x, y, z), alternating between the two nearest palette
126
+ * blocks per position (4x4 Bayer) — the per-pixel entry point for
127
+ * pixel art and image mapping. Deterministic. Errors with
128
+ * `NotFound` on an empty palette.
129
+ */
130
+ closestBlockDithered(r: number, g: number, b: number, x: number, y: number, z: number): string;
131
+
114
132
  /**
115
133
  * The palette block whose color is closest (Oklab distance) to the
116
134
  * given RGB. Errors with `NotFound` on an empty palette.
package/Palette.mjs CHANGED
@@ -190,6 +190,26 @@ export class Palette {
190
190
  }
191
191
  }
192
192
 
193
+ /**
194
+ * A copy of this palette with ordered dithering enabled: brushes
195
+ * snapping through it alternate between the two nearest blocks per
196
+ * voxel (4x4 Bayer threshold, deterministic in position), which
197
+ * reads as intermediate shades at a distance — the classic map-art
198
+ * trick. Ramp and list queries are unaffected.
199
+ */
200
+ dithered() {
201
+
202
+ const result = wasm.Palette_dithered(this.ffiValue);
203
+
204
+ try {
205
+ return new Palette(diplomatRuntime.internalConstructor, result, []);
206
+ }
207
+
208
+ finally {
209
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
210
+ }
211
+ }
212
+
193
213
  /**
194
214
  * A copy of this palette ordered by perceptual lightness (Oklab L,
195
215
  * dark → light). Combined with `block_ids_json`, gives a
@@ -335,6 +355,36 @@ export class Palette {
335
355
  }
336
356
  }
337
357
 
358
+ /**
359
+ * Position-aware dithered snap: the block for the given RGB at
360
+ * voxel (x, y, z), alternating between the two nearest palette
361
+ * blocks per position (4x4 Bayer) — the per-pixel entry point for
362
+ * pixel art and image mapping. Deterministic. Errors with
363
+ * `NotFound` on an empty palette.
364
+ */
365
+ closestBlockDithered(r, g, b, x, y, z) {
366
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
367
+
368
+ const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
369
+
370
+
371
+ const result = wasm.Palette_closest_block_dithered(diplomatReceive.buffer, this.ffiValue, r, g, b, x, y, z, write.buffer);
372
+
373
+ try {
374
+ if (!diplomatReceive.resultFlag) {
375
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
376
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
377
+ }
378
+ return write.readString8();
379
+ }
380
+
381
+ finally {
382
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
383
+ diplomatReceive.free();
384
+ write.free();
385
+ }
386
+ }
387
+
338
388
  /**
339
389
  * The palette block whose color is closest (Oklab distance) to the
340
390
  * given RGB. Errors with `NotFound` on an empty palette.
package/nucleation.wasm CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nucleation",
3
- "version": "0.3.9",
3
+ "version": "0.3.11",
4
4
  "description": "A high-performance Minecraft schematic parser and utility library",
5
5
  "type": "module",
6
6
  "main": "index.mjs",