nucleation 0.3.10 → 0.3.12
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 +9 -0
- package/Palette.mjs +30 -0
- package/nucleation.wasm +0 -0
- package/package.json +1 -1
package/Palette.d.ts
CHANGED
|
@@ -120,6 +120,15 @@ export class Palette {
|
|
|
120
120
|
*/
|
|
121
121
|
blockIdsJson(): string;
|
|
122
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
|
+
|
|
123
132
|
/**
|
|
124
133
|
* The palette block whose color is closest (Oklab distance) to the
|
|
125
134
|
* given RGB. Errors with `NotFound` on an empty palette.
|
package/Palette.mjs
CHANGED
|
@@ -355,6 +355,36 @@ export class Palette {
|
|
|
355
355
|
}
|
|
356
356
|
}
|
|
357
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
|
+
|
|
358
388
|
/**
|
|
359
389
|
* The palette block whose color is closest (Oklab distance) to the
|
|
360
390
|
* given RGB. Errors with `NotFound` on an empty palette.
|
package/nucleation.wasm
CHANGED
|
Binary file
|