nucleation 0.3.1 → 0.3.2

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
@@ -59,6 +59,28 @@ export class Palette {
59
59
  */
60
60
  static grayscale(): Palette;
61
61
 
62
+ /**
63
+ * The planks family — a natural light→dark wood ramp.
64
+ */
65
+ static wood(): Palette;
66
+
67
+ /**
68
+ * A copy of this palette ordered by perceptual lightness (Oklab L,
69
+ * dark → light). Combined with `block_ids_json`, gives a
70
+ * ready-to-index ramp: `ids[i]` for intensity `i / (len - 1)`.
71
+ */
72
+ sortedByLightness(): Palette;
73
+
74
+ /**
75
+ * JSON array of exactly `steps` block ids sampling the color
76
+ * gradient from (`r1`,`g1`,`b1`) to (`r2`,`g2`,`b2`) in Oklab
77
+ * space, each step snapped to this palette's closest block. Built
78
+ * for value→block lookups (heatmaps, fractals): index the returned
79
+ * list by `intensity * (steps - 1)`. Entries may repeat on coarse
80
+ * palettes; errors with `NotFound` on an empty palette.
81
+ */
82
+ gradientIdsJson(r1: number, g1: number, b1: number, r2: number, g2: number, b2: number, steps: number): string;
83
+
62
84
  /**
63
85
  * Custom palette from a JSON array of block ids, e.g.
64
86
  * `["minecraft:stone", "minecraft:oak_planks"]`. Ids blockpedia has
package/Palette.mjs CHANGED
@@ -172,6 +172,71 @@ export class Palette {
172
172
  }
173
173
  }
174
174
 
175
+ /**
176
+ * The planks family — a natural light→dark wood ramp.
177
+ */
178
+ static wood() {
179
+
180
+ const result = wasm.Palette_wood();
181
+
182
+ try {
183
+ return new Palette(diplomatRuntime.internalConstructor, result, []);
184
+ }
185
+
186
+ finally {
187
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
188
+ }
189
+ }
190
+
191
+ /**
192
+ * A copy of this palette ordered by perceptual lightness (Oklab L,
193
+ * dark → light). Combined with `block_ids_json`, gives a
194
+ * ready-to-index ramp: `ids[i]` for intensity `i / (len - 1)`.
195
+ */
196
+ sortedByLightness() {
197
+
198
+ const result = wasm.Palette_sorted_by_lightness(this.ffiValue);
199
+
200
+ try {
201
+ return new Palette(diplomatRuntime.internalConstructor, result, []);
202
+ }
203
+
204
+ finally {
205
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
206
+ }
207
+ }
208
+
209
+ /**
210
+ * JSON array of exactly `steps` block ids sampling the color
211
+ * gradient from (`r1`,`g1`,`b1`) to (`r2`,`g2`,`b2`) in Oklab
212
+ * space, each step snapped to this palette's closest block. Built
213
+ * for value→block lookups (heatmaps, fractals): index the returned
214
+ * list by `intensity * (steps - 1)`. Entries may repeat on coarse
215
+ * palettes; errors with `NotFound` on an empty palette.
216
+ */
217
+ gradientIdsJson(r1, g1, b1, r2, g2, b2, steps) {
218
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
219
+
220
+ const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
221
+
222
+
223
+ const result = wasm.Palette_gradient_ids_json(diplomatReceive.buffer, this.ffiValue, r1, g1, b1, r2, g2, b2, steps, write.buffer);
224
+
225
+ try {
226
+ if (!diplomatReceive.resultFlag) {
227
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
228
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
229
+ }
230
+ return write.readString8();
231
+ }
232
+
233
+ finally {
234
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
235
+ diplomatReceive.free();
236
+ write.free();
237
+ }
238
+ }
239
+
175
240
  /**
176
241
  * Custom palette from a JSON array of block ids, e.g.
177
242
  * `["minecraft:stone", "minecraft:oak_planks"]`. Ids blockpedia has
package/nucleation.wasm CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nucleation",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "A high-performance Minecraft schematic parser and utility library",
5
5
  "type": "module",
6
6
  "main": "index.mjs",