pixelkiln 0.144.2 → 0.146.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.
package/dist/cli.js CHANGED
@@ -3638,6 +3638,13 @@ var ParallaxLayerSchema = z.object({
3638
3638
  ctx.addIssue({ code: z.ZodIssueCode.custom, path: ["extend"], message: "extend repeats the bottom row, which foot thins out; use one or the other" });
3639
3639
  }
3640
3640
  });
3641
+ var ParallaxTimeSchema = z.object({
3642
+ /** A style id, for that style's palette, or a list of colours. */
3643
+ palette: z.union([z.string().min(1), z.array(HexColorSchema).min(2).max(256)]),
3644
+ /** Map only onto colours whose blue is at least their red, which leaves out a night palette's lamps and moon. */
3645
+ cool: z.boolean().optional()
3646
+ }).strict();
3647
+ var ParallaxTimeIdSchema = z.string().regex(/^[A-Za-z][A-Za-z0-9_-]{0,31}$/, "a time is letters, digits, - and _, starting with a letter");
3641
3648
  var ParallaxSetSchema = z.object({
3642
3649
  /** The game's view in pixels, [width, height]. */
3643
3650
  view: z.tuple([z.number().int().min(8).max(4096), z.number().int().min(8).max(4096)]),
@@ -3651,8 +3658,21 @@ var ParallaxSetSchema = z.object({
3651
3658
  * the picture, so it adds none.
3652
3659
  */
3653
3660
  palette: z.union([z.string().min(1), z.array(HexColorSchema).min(2).max(256)]).optional(),
3661
+ /**
3662
+ * Other times of day for the same set, by name: each swaps the set's
3663
+ * `palette` for another by luminance rank. Godot exports carry them in
3664
+ * one shader; Tiled and LDtk get a map per time.
3665
+ */
3666
+ times: z.record(ParallaxTimeIdSchema, ParallaxTimeSchema).optional(),
3654
3667
  layers: z.array(ParallaxLayerSchema).min(1).max(32)
3655
- }).strict();
3668
+ }).strict().superRefine((set, ctx) => {
3669
+ if (set.times && Object.keys(set.times).length && set.palette === void 0) {
3670
+ ctx.addIssue({ code: z.ZodIssueCode.custom, path: ["times"], message: "times swap the set's palette, so the set needs a palette" });
3671
+ }
3672
+ if (set.times && Object.keys(set.times).length > 15) {
3673
+ ctx.addIssue({ code: z.ZodIssueCode.custom, path: ["times"], message: "at most 15 times" });
3674
+ }
3675
+ });
3656
3676
  var ParallaxSetIdSchema = z.string().regex(/^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/, "a set id is letters, digits, - and _, starting with a letter or digit");
3657
3677
  var ManifestSchema = z.object({
3658
3678
  $schema: z.string().optional(),
@@ -16779,6 +16799,12 @@ ${issues}`);
16779
16799
  if (!style) unknownReferences.push(`parallax.${setId}.palette: unknown style "${set.palette}"`);
16780
16800
  else if (style.palette.length < 2) unknownReferences.push(`parallax.${setId}.palette: style "${set.palette}" has no palette`);
16781
16801
  }
16802
+ for (const [time, spec] of Object.entries(set.times ?? {})) {
16803
+ if (typeof spec.palette !== "string") continue;
16804
+ const style = parsed.data.styles[spec.palette];
16805
+ if (!style) unknownReferences.push(`parallax.${setId}.times.${time}.palette: unknown style "${spec.palette}"`);
16806
+ else if (style.palette.length < 2) unknownReferences.push(`parallax.${setId}.times.${time}.palette: style "${spec.palette}" has no palette`);
16807
+ }
16782
16808
  set.layers.forEach((layer, index) => {
16783
16809
  const at2 = `parallax.${setId}.layers.${index}`;
16784
16810
  const checkAsset = (where, ref) => {
@@ -35248,7 +35274,12 @@ var RecipeSchema = z18.object({
35248
35274
  sourceImage: RecipeBindingSchema.optional(),
35249
35275
  maskImage: RecipeBindingSchema.optional(),
35250
35276
  strength: RecipeBindingSchema.optional()
35251
- }).strict()
35277
+ }).catchall(RecipeBindingSchema),
35278
+ /** Frame-set options; required when the style's generator is `frames`. */
35279
+ frames: z18.object({
35280
+ vary: z18.string().min(1),
35281
+ seedStep: z18.number().int().optional()
35282
+ }).strict().optional()
35252
35283
  }).strict().optional(),
35253
35284
  quality: z18.object({
35254
35285
  stage: z18.enum(["composition-source", "production-candidate"]),
@@ -35342,11 +35373,27 @@ var RecipeSchema = z18.object({
35342
35373
  });
35343
35374
  return;
35344
35375
  }
35376
+ const frames = recipe.workflow.frames;
35377
+ if (recipe.style.generator === "frames" !== (frames !== void 0)) {
35378
+ context.addIssue({
35379
+ code: z18.ZodIssueCode.custom,
35380
+ path: ["workflow", "frames"],
35381
+ message: "is required for a frames style and only allowed there"
35382
+ });
35383
+ }
35384
+ if (frames && !Object.hasOwn(recipe.workflow.bindings, frames.vary)) {
35385
+ context.addIssue({
35386
+ code: z18.ZodIssueCode.custom,
35387
+ path: ["workflow", "frames", "vary"],
35388
+ message: "must name a workflow binding"
35389
+ });
35390
+ }
35345
35391
  const expected = {
35346
35392
  workflowFile: `${RECIPE_DIR_TOKEN}/${recipe.workflow.path}`,
35347
35393
  outputNodeId: recipe.workflow.outputNodeId,
35348
35394
  numImages: recipe.workflow.numImages,
35349
- bindings: recipe.workflow.bindings
35395
+ bindings: recipe.workflow.bindings,
35396
+ frames
35350
35397
  };
35351
35398
  if (JSON.stringify(canonical3(options)) !== JSON.stringify(canonical3(expected))) {
35352
35399
  context.addIssue({
@@ -35975,7 +36022,14 @@ async function resolveParallaxSet(manifest, manifestDir, lock, setId) {
35975
36022
  }
35976
36023
  layers.push(image);
35977
36024
  }
35978
- return { id: setId, view: [viewW, viewH], travel, climb, ...palette ? { palette } : {}, layers, warnings };
36025
+ const times = Object.entries(set.times ?? {}).map(([name, time]) => {
36026
+ const colours = typeof time.palette === "string" ? manifest.styles[time.palette]?.palette : time.palette;
36027
+ if (!colours?.length) throw new Error(`parallax ${setId}: time ${name}: style "${time.palette}" has no palette`);
36028
+ const resolved = { name, palette: colours, cool: time.cool ?? false };
36029
+ paletteSwap(palette, resolved, `parallax ${setId}: time ${name}`);
36030
+ return resolved;
36031
+ });
36032
+ return { id: setId, view: [viewW, viewH], travel, climb, ...palette ? { palette } : {}, ...times.length ? { times } : {}, layers, warnings };
35979
36033
  }
35980
36034
  function finishPicture(png, options, where = "picture") {
35981
36035
  let out = png;
@@ -36156,6 +36210,83 @@ function loopPicture(png, method, where = "picture") {
36156
36210
  }
36157
36211
  return { png: { width: w * 2, height: h, pixels }, loop: { method, from: w } };
36158
36212
  }
36213
+ var rgbKey = (r, g, b) => r << 16 | g << 8 | b;
36214
+ function sortedRgb(hexes) {
36215
+ const seen = /* @__PURE__ */ new Map();
36216
+ for (const hex2 of hexes) {
36217
+ const { r, g, b } = parseHex(hex2);
36218
+ seen.set(rgbKey(r, g, b), [r, g, b]);
36219
+ }
36220
+ return [...seen.values()].sort((a, b) => a[0] - b[0] || a[1] - b[1] || a[2] - b[2]);
36221
+ }
36222
+ var luminance = (c) => c[0] * 0.2126 + c[1] * 0.7152 + c[2] * 0.0722;
36223
+ function paletteSwap(from, time, where = "palette swap") {
36224
+ const source = sortedRgb(from);
36225
+ let target = sortedRgb(time.palette);
36226
+ if (time.cool) target = target.filter((c) => c[2] >= c[0]);
36227
+ if (!target.length) throw new Error(`${where}: no colour of the palette has blue at least its red, so cool leaves nothing to map onto`);
36228
+ const rank = (colours) => colours.map((c, i) => [i, luminance(c)]).sort((a, b) => a[1] - b[1] || a[0] - b[0]).map(([i]) => i);
36229
+ const fromOrder = rank(source);
36230
+ const toOrder = rank(target);
36231
+ const table = /* @__PURE__ */ new Map();
36232
+ fromOrder.forEach((i, r) => {
36233
+ const c = source[i];
36234
+ table.set(rgbKey(c[0], c[1], c[2]), target[toOrder[roundHalfEven(r / Math.max(fromOrder.length - 1, 1) * (toOrder.length - 1))]]);
36235
+ });
36236
+ return { source, table };
36237
+ }
36238
+ function nearestRgb(colours, r, g, b) {
36239
+ let best = colours[0];
36240
+ let bestDistance = Infinity;
36241
+ for (const c of colours) {
36242
+ const d = (r - c[0]) ** 2 + (g - c[1]) ** 2 + (b - c[2]) ** 2;
36243
+ if (d < bestDistance) {
36244
+ bestDistance = d;
36245
+ best = c;
36246
+ }
36247
+ }
36248
+ return best;
36249
+ }
36250
+ function recolourPicture(png, swap) {
36251
+ const pixels = Buffer.from(png.pixels);
36252
+ const done = /* @__PURE__ */ new Map();
36253
+ for (let p = 0; p < pixels.length; p += 4) {
36254
+ if (pixels[p + 3] === 0) continue;
36255
+ const key3 = rgbKey(pixels[p], pixels[p + 1], pixels[p + 2]);
36256
+ let out = done.get(key3);
36257
+ if (!out) {
36258
+ const snapped = nearestRgb(swap.source, pixels[p], pixels[p + 1], pixels[p + 2]);
36259
+ out = swap.table.get(rgbKey(snapped[0], snapped[1], snapped[2]));
36260
+ done.set(key3, out);
36261
+ }
36262
+ pixels[p] = out[0];
36263
+ pixels[p + 1] = out[1];
36264
+ pixels[p + 2] = out[2];
36265
+ }
36266
+ return { width: png.width, height: png.height, pixels };
36267
+ }
36268
+ function setAtTime(set, time) {
36269
+ const spec = set.times?.find((t) => t.name === time);
36270
+ if (!spec) throw new Error(`parallax ${set.id}: no time "${time}". ${set.times?.length ? `Known: ${set.times.map((t) => t.name).join(", ")}` : "The set has no times."}`);
36271
+ const swap = paletteSwap(set.palette, spec);
36272
+ return { ...set, id: `${set.id}.${time}`, times: void 0, layers: set.layers.map((layer) => ({ ...layer, png: recolourPicture(layer.png, swap) })) };
36273
+ }
36274
+ function timeColours(set) {
36275
+ const used = /* @__PURE__ */ new Map();
36276
+ for (const layer of set.layers) {
36277
+ const px = layer.png.pixels;
36278
+ for (let p = 0; p < px.length; p += 4) if (px[p + 3] !== 0) used.set(rgbKey(px[p], px[p + 1], px[p + 2]), [px[p], px[p + 1], px[p + 2]]);
36279
+ }
36280
+ const columns = [...used.values()].sort((a, b) => a[0] - b[0] || a[1] - b[1] || a[2] - b[2]);
36281
+ const rows = [columns, ...(set.times ?? []).map((time) => {
36282
+ const swap = paletteSwap(set.palette, time);
36283
+ return columns.map((c) => swap.table.get(rgbKey(...nearestRgb(swap.source, c[0], c[1], c[2]))));
36284
+ })];
36285
+ const width = Math.max(1, columns.length);
36286
+ const pixels = Buffer.alloc(width * rows.length * 4);
36287
+ rows.forEach((row, y) => row.forEach((c, x) => pixels.set([c[0], c[1], c[2], 255], (y * width + x) * 4)));
36288
+ return { width, height: rows.length, pixels };
36289
+ }
36159
36290
  async function readPicture(manifest, manifestDir, lock, setId, name, ref, warnings) {
36160
36291
  if (ref.file) {
36161
36292
  const file2 = path73.resolve(manifestDir, ref.file);
@@ -36346,11 +36477,23 @@ function godotNumber(value) {
36346
36477
  function exportGodot(set, base) {
36347
36478
  const [vw, vh] = set.view;
36348
36479
  const pictures = layerPngs(set, base);
36349
- const lines = [`[gd_scene load_steps=${pictures.length + 1} format=3]`, ""];
36480
+ const name = path73.basename(base);
36481
+ const times = set.times ?? [];
36482
+ const lines = [`[gd_scene load_steps=${pictures.length + 1 + (times.length ? 3 : 0)} format=3]`, ""];
36350
36483
  pictures.forEach(({ file }, index) => {
36351
36484
  lines.push(`[ext_resource type="Texture2D" path=${JSON.stringify(`./${file}`)} id="${index + 1}_layer"]`);
36352
36485
  });
36353
- lines.push("", `[node name=${JSON.stringify(path73.basename(base))} type="Node2D"]`, "texture_filter = 1");
36486
+ const extra = [];
36487
+ if (times.length) {
36488
+ const colours = timeColours(set);
36489
+ extra.push({ path: `${base}.colours.png`, data: encodeRgbaPng(colours.width, colours.height, colours.pixels) });
36490
+ extra.push({ path: `${base}.gdshader`, data: GODOT_TIMES_SHADER });
36491
+ lines.push(`[ext_resource type="Shader" path=${JSON.stringify(`./${name}.gdshader`)} id="times_shader"]`);
36492
+ lines.push(`[ext_resource type="Texture2D" path=${JSON.stringify(`./${name}.colours.png`)} id="times_colours"]`);
36493
+ lines.push("", '[sub_resource type="ShaderMaterial" id="times"]', 'shader = ExtResource("times_shader")', 'shader_parameter/colours = ExtResource("times_colours")');
36494
+ }
36495
+ lines.push("", `[node name=${JSON.stringify(name)} type="Node2D"]`, "texture_filter = 1");
36496
+ if (times.length) lines.push(`metadata/times = PackedStringArray(${times.map((t) => JSON.stringify(t.name)).join(", ")})`);
36354
36497
  pictures.forEach(({ layer }, index) => {
36355
36498
  lines.push("", `[node name=${JSON.stringify(layer.name)} type="Parallax2D" parent="."]`);
36356
36499
  lines.push(`scroll_scale = Vector2(${godotNumber(layer.speed)}, ${godotNumber(layer.speedY)})`);
@@ -36359,19 +36502,20 @@ function exportGodot(set, base) {
36359
36502
  if (layer.repeat || layer.repeatY) {
36360
36503
  lines.push(`repeat_size = Vector2(${layer.repeat ? layer.png.width : 0}, ${layer.repeatY ? layer.png.height : 0})`);
36361
36504
  const reach = (view, size) => 2 * (Math.ceil(view / size) + 1) - 1;
36362
- const times = Math.max(layer.repeat ? reach(vw, layer.png.width) : 1, layer.repeatY ? reach(vh, layer.png.height) : 1);
36363
- lines.push(`repeat_times = ${times}`);
36505
+ const times2 = Math.max(layer.repeat ? reach(vw, layer.png.width) : 1, layer.repeatY ? reach(vh, layer.png.height) : 1);
36506
+ lines.push(`repeat_times = ${times2}`);
36364
36507
  }
36365
36508
  lines.push("", `[node name="Sprite2D" type="Sprite2D" parent=${JSON.stringify(layer.name)}]`);
36366
36509
  lines.push(`texture = ExtResource("${index + 1}_layer")`, "centered = false");
36510
+ if (times.length) lines.push('material = SubResource("times")');
36367
36511
  const mod = (value, size) => (value % size + size) % size;
36368
36512
  const px = layer.repeat ? mod(layer.x, layer.png.width) : layer.x;
36369
36513
  const py = layer.repeatY ? mod(layer.y + set.climb, layer.png.height) : layer.y + set.climb;
36370
36514
  lines.push(`position = Vector2(${px}, ${py})`);
36371
36515
  });
36372
36516
  return {
36373
- files: [{ path: `${base}.tscn`, data: lines.join("\n") + "\n" }, ...pictures.map((p) => ({ path: path73.join(path73.dirname(base), p.file), data: p.png }))],
36374
- options: { format: "godot", start: [0, set.climb] }
36517
+ files: [{ path: `${base}.tscn`, data: lines.join("\n") + "\n" }, ...pictures.map((p) => ({ path: path73.join(path73.dirname(base), p.file), data: p.png })), ...extra],
36518
+ options: { format: "godot", start: [0, set.climb], ...times.length ? { shader: `${name}.gdshader` } : {} }
36375
36519
  };
36376
36520
  }
36377
36521
  function uuid(...parts) {
@@ -36610,15 +36754,52 @@ function tileEmpty(png, x0, y0, grid) {
36610
36754
  return true;
36611
36755
  }
36612
36756
  function exportParallax(set, format, base) {
36613
- if (format === "tiled") return exportTiled(set, base);
36614
36757
  if (format === "godot") return exportGodot(set, base);
36615
- return exportLdtk(set, base);
36758
+ const one = (s, b) => format === "tiled" ? exportTiled(s, b) : exportLdtk(s, b);
36759
+ const result = one({ ...set, times: void 0 }, base);
36760
+ if (!set.times?.length) return result;
36761
+ for (const time of set.times) {
36762
+ const timed = one(setAtTime(set, time.name), `${base}.${time.name}`);
36763
+ result.files.push(...timed.files);
36764
+ for (const warning of timed.options.warnings ?? []) {
36765
+ const warnings = result.options.warnings ?? [];
36766
+ if (!warnings.includes(warning)) result.options.warnings = [...warnings, warning];
36767
+ }
36768
+ }
36769
+ result.options.maps = [path73.basename(result.files[0].path), ...set.times.map((t) => `${path73.basename(base)}.${t.name}${path73.extname(result.files[0].path)}`)];
36770
+ return result;
36616
36771
  }
36772
+ var GODOT_TIMES_SHADER = `// Written by pixelkiln parallax export. Recolours the set to one of its times of day.
36773
+ // time = 0 draws the pictures as they are; time = n draws them at the n-th name in the
36774
+ // scene root's metadata/times. blend (0 to 1) mixes toward blend_to, for a fade between
36775
+ // two times. Every layer shares one material, so setting a parameter on it sets all of them.
36776
+ shader_type canvas_item;
36777
+
36778
+ uniform sampler2D colours : filter_nearest, repeat_disable;
36779
+ uniform int time = 0;
36780
+ uniform int blend_to = 0;
36781
+ uniform float blend : hint_range(0.0, 1.0) = 0.0;
36782
+
36783
+ void fragment() {
36784
+ vec4 drawn = texture(TEXTURE, UV);
36785
+ COLOR = drawn;
36786
+ int columns = textureSize(colours, 0).x;
36787
+ for (int i = 0; i < columns; i++) {
36788
+ if (all(lessThan(abs(texelFetch(colours, ivec2(i, 0), 0).rgb - drawn.rgb), vec3(0.5 / 255.0)))) {
36789
+ vec3 now = texelFetch(colours, ivec2(i, time), 0).rgb;
36790
+ vec3 next = texelFetch(colours, ivec2(i, blend_to), 0).rgb;
36791
+ COLOR = vec4(mix(now, next, blend), drawn.a);
36792
+ break;
36793
+ }
36794
+ }
36795
+ }
36796
+ `;
36617
36797
  function previewHtml(set, scale2 = 3) {
36618
36798
  const [vw, vh] = set.view;
36619
- const layers = set.layers.map((layer) => ({
36799
+ const timed = [set, ...(set.times ?? []).map((time) => setAtTime(set, time.name))];
36800
+ const layers = set.layers.map((layer, index) => ({
36620
36801
  name: layer.name,
36621
- src: `data:image/png;base64,${encodeRgbaPng(layer.png.width, layer.png.height, layer.png.pixels).toString("base64")}`,
36802
+ srcs: timed.map((s) => `data:image/png;base64,${encodeRgbaPng(s.layers[index].png.width, s.layers[index].png.height, s.layers[index].png.pixels).toString("base64")}`),
36622
36803
  w: layer.png.width,
36623
36804
  h: layer.png.height,
36624
36805
  x: layer.x,
@@ -36628,7 +36809,8 @@ function previewHtml(set, scale2 = 3) {
36628
36809
  repeat: layer.repeat,
36629
36810
  repeatY: layer.repeatY
36630
36811
  }));
36631
- const data = JSON.stringify({ view: [vw, vh], travel: set.travel, climb: set.climb, layers }).replace(/</g, "\\u003c");
36812
+ const times = ["as drawn", ...(set.times ?? []).map((time) => time.name)];
36813
+ const data = JSON.stringify({ view: [vw, vh], travel: set.travel, climb: set.climb, times, layers }).replace(/</g, "\\u003c");
36632
36814
  return `<!doctype html>
36633
36815
  <html lang="en">
36634
36816
  <head>
@@ -36650,13 +36832,17 @@ function previewHtml(set, scale2 = 3) {
36650
36832
  <main>
36651
36833
  <canvas id="view" width="${vw}" height="${vh}"></canvas>
36652
36834
  <label><button id="play" type="button">Pause</button> camera <input id="cam" type="range" min="0" max="1000" value="0"> <output id="pos"></output></label>
36835
+ <label id="times" hidden>time <select id="time"></select></label>
36653
36836
  <table><thead><tr><th>Layer</th><th>speed</th><th>speedY</th><th>repeat</th></tr></thead><tbody id="rows"></tbody></table>
36654
36837
  </main>
36655
36838
  <script>
36656
36839
  const set = ${data};
36657
36840
  const ctx = document.getElementById("view").getContext("2d");
36658
36841
  ctx.imageSmoothingEnabled = false;
36659
- const images = set.layers.map((layer) => Object.assign(new Image(), { src: layer.src }));
36842
+ const images = set.layers.map((layer) => layer.srcs.map((src) => Object.assign(new Image(), { src })));
36843
+ const pick = document.getElementById("time");
36844
+ set.times.forEach((name, i) => pick.add(new Option(name, i)));
36845
+ document.getElementById("times").hidden = set.times.length < 2;
36660
36846
  const rows = document.getElementById("rows");
36661
36847
  for (const layer of set.layers) {
36662
36848
  const tr = rows.insertRow();
@@ -36685,7 +36871,7 @@ function draw(u) {
36685
36871
  if (layer.repeat) for (let x = ((left % layer.w) + layer.w) % layer.w - layer.w; x < set.view[0]; x += layer.w) xs.push(x);
36686
36872
  const ys = layer.repeatY ? [] : [top];
36687
36873
  if (layer.repeatY) for (let y = ((top % layer.h) + layer.h) % layer.h - layer.h; y < set.view[1]; y += layer.h) ys.push(y);
36688
- for (const y of ys) for (const x of xs) ctx.drawImage(images[i], x, y);
36874
+ for (const y of ys) for (const x of xs) ctx.drawImage(images[i][pick.value | 0], x, y);
36689
36875
  });
36690
36876
  }
36691
36877
  function frame(now) {
@@ -36697,7 +36883,7 @@ function frame(now) {
36697
36883
  draw(slider.value / 1000);
36698
36884
  requestAnimationFrame(frame);
36699
36885
  }
36700
- Promise.all(images.map((image) => image.decode())).then(() => requestAnimationFrame(frame));
36886
+ Promise.all(images.flat().map((image) => image.decode())).then(() => requestAnimationFrame(frame));
36701
36887
  </script>
36702
36888
  </body>
36703
36889
  </html>
@@ -36738,27 +36924,30 @@ async function runParallax(args) {
36738
36924
  sources,
36739
36925
  options: { set: id, ...describe2, ...result.options }
36740
36926
  }, { force: args.force });
36741
- log(` ${id} (${format}): ${path74.relative(process.cwd(), result.files[0].path)} + ${result.files.length - 1} picture(s)`);
36927
+ log(` ${id} (${format}): ${path74.relative(process.cwd(), result.files[0].path)} + ${result.files.length - 1} more file(s)`);
36742
36928
  for (const warning of result.options.warnings ?? []) log(` warning: ${warning}`);
36743
36929
  }
36744
36930
  } else {
36745
36931
  const frames = args.frames ?? 3;
36746
- const strip = joinStripPng(
36747
- cameraPath(set, frames).map(([x, y]) => {
36748
- const frame = composeParallaxFrame(set, x, y);
36932
+ const strip = (s) => joinStripPng(
36933
+ cameraPath(s, frames).map(([x, y]) => {
36934
+ const frame = composeParallaxFrame(s, x, y);
36749
36935
  return encodeRgbaPng(frame.width, frame.height, frame.pixels);
36750
36936
  })
36751
36937
  );
36752
36938
  const base = path74.join(root, `${id}.preview`);
36753
36939
  await writeManagedArtifactBundle(`${base}.pixelkiln.json`, [
36754
36940
  { path: `${base}.html`, data: Buffer.from(previewHtml(set)) },
36755
- { path: `${base}.png`, data: strip }
36941
+ { path: `${base}.png`, data: strip(set) },
36942
+ // A strip for each time of day too, the same frames recoloured.
36943
+ ...(set.times ?? []).map((time) => ({ path: `${base}.${time.name}.png`, data: strip(setAtTime(set, time.name)) }))
36756
36944
  ], {
36757
36945
  kind: "parallax",
36758
36946
  sources,
36759
36947
  options: { set: id, ...describe2, preview: { frames } }
36760
36948
  }, { force: args.force });
36761
36949
  log(` ${id}: ${path74.relative(process.cwd(), base)}.html (scrolls in a browser) + .png (${frames} frames, start to end)`);
36950
+ if (set.times?.length) log(` times: ${set.times.map((time) => `${time.name} (${path74.basename(base)}.${time.name}.png)`).join(", ")}`);
36762
36951
  }
36763
36952
  for (const layer of set.layers) {
36764
36953
  const seam = (layer.seamRatio === void 0 ? "" : `, seam ${layer.seamRatio.toFixed(1)}`) + (layer.seamRatioY === void 0 ? "" : `, vertical seam ${layer.seamRatioY.toFixed(1)}`);
@@ -36785,7 +36974,8 @@ function setOptions(set) {
36785
36974
  ...layer.loop ? { loop: layer.loop } : {},
36786
36975
  ...layer.finish ?? {}
36787
36976
  })),
36788
- ...set.palette ? { palette: set.palette } : {}
36977
+ ...set.palette ? { palette: set.palette } : {},
36978
+ ...set.times ? { times: Object.fromEntries(set.times.map((time) => [time.name, { palette: time.palette, cool: time.cool }])) } : {}
36789
36979
  };
36790
36980
  }
36791
36981