@pixerate/editor 0.275.0 → 0.276.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/animation-editor/index.cjs +62 -62
- package/dist/animation-editor/index.js +6 -6
- package/dist/brushes/index.cjs +81 -70
- package/dist/brushes/index.js +17 -6
- package/dist/brushes/patch.d.cts +1 -1
- package/dist/brushes/patch.d.ts +1 -1
- package/dist/brushes/profiles.d.cts +2 -0
- package/dist/brushes/profiles.d.ts +2 -0
- package/dist/brushes/schema.d.cts +1 -0
- package/dist/brushes/schema.d.ts +1 -0
- package/dist/brushes/types.d.cts +22 -1
- package/dist/brushes/types.d.ts +22 -1
- package/dist/{brushstrokeRender-WGY4DZHF.js → brushstrokeRender-FK3ASUUJ.js} +5 -5
- package/dist/{brushstrokeRender-2RQL46WB.cjs → brushstrokeRender-I6MYFCOU.cjs} +21 -21
- package/dist/canvas/index.cjs +13 -13
- package/dist/canvas/index.js +1 -1
- package/dist/chart/contract.d.cts +3 -1
- package/dist/chart/contract.d.ts +3 -1
- package/dist/{chunk-Y2ISSVPH.js → chunk-4EM5NGCL.js} +167 -9
- package/dist/{chunk-Y354ETAE.cjs → chunk-5HR5CSLC.cjs} +49 -49
- package/dist/{chunk-LMG57L5A.js → chunk-CTHWXW5M.js} +121 -8
- package/dist/{chunk-43XJC3PP.js → chunk-CVBTJVRN.js} +1 -1
- package/dist/{chunk-RJGW3RQS.js → chunk-GHYJAMMS.js} +1 -1
- package/dist/{chunk-NIBFKXMD.cjs → chunk-IFWLZZCW.cjs} +619 -2
- package/dist/{chunk-G5TCMKX5.js → chunk-IJ6NSWKM.js} +2 -2
- package/dist/{chunk-C6VB7CPY.cjs → chunk-ISCAJBPQ.cjs} +1 -1
- package/dist/{chunk-W6JDUXP3.js → chunk-J23JOHPR.js} +1 -1
- package/dist/{chunk-IEEY5RJV.js → chunk-JNMNM3SL.js} +1 -1
- package/dist/{chunk-HVO6XCI4.js → chunk-JPB65KQ6.js} +1 -1
- package/dist/{chunk-ACTHSQOI.js → chunk-LDZOXESA.js} +618 -1
- package/dist/{chunk-DHC4E2DU.cjs → chunk-MITQGHN3.cjs} +121 -8
- package/dist/{chunk-STLTOISW.cjs → chunk-NPPMKMCU.cjs} +17 -17
- package/dist/{chunk-75SYKUOT.js → chunk-OS6OG7DN.js} +1 -1
- package/dist/{chunk-OLZXXAER.cjs → chunk-OY24XRYF.cjs} +408 -250
- package/dist/{chunk-6QNDGMK7.cjs → chunk-Q33V5PEF.cjs} +123 -42
- package/dist/{chunk-JDXWLCXF.cjs → chunk-QNNZA3V5.cjs} +2 -2
- package/dist/{chunk-T6KNJVBP.cjs → chunk-U26LUXCJ.cjs} +35 -35
- package/dist/{chunk-62MFUHSI.cjs → chunk-UQXULAMQ.cjs} +16 -16
- package/dist/{chunk-RAPNRK4R.cjs → chunk-X7XBEX3O.cjs} +88 -88
- package/dist/{chunk-MSWLJI4G.js → chunk-XMSH66VU.js} +2 -2
- package/dist/{chunk-ZM7IKQ4X.js → chunk-XVPQNX7O.js} +89 -8
- package/dist/{chunk-YYZC2EQO.cjs → chunk-ZIE6EJGR.cjs} +23 -23
- package/dist/image-editor/index.cjs +880 -852
- package/dist/image-editor/index.js +36 -8
- package/dist/paint/index.cjs +33 -5
- package/dist/paint/index.d.cts +1 -0
- package/dist/paint/index.d.ts +1 -0
- package/dist/paint/index.js +32 -4
- package/dist/paint/live-patterns.d.cts +149 -0
- package/dist/paint/live-patterns.d.ts +149 -0
- package/dist/paint/wet/world.d.cts +13 -0
- package/dist/paint/wet/world.d.ts +13 -0
- package/dist/paint-editor/brush-model.d.cts +7 -1
- package/dist/paint-editor/brush-model.d.ts +7 -1
- package/dist/paint-editor/controller.d.cts +52 -0
- package/dist/paint-editor/controller.d.ts +52 -0
- package/dist/paint-editor/index.cjs +850 -510
- package/dist/paint-editor/index.js +355 -15
- package/dist/paint-editor/ui.d.cts +5 -1
- package/dist/paint-editor/ui.d.ts +5 -1
- package/dist/paint-editor/wet-tools.d.cts +42 -0
- package/dist/paint-editor/wet-tools.d.ts +42 -0
- package/dist/paint-editor/wet.d.cts +22 -1
- package/dist/paint-editor/wet.d.ts +22 -1
- package/dist/vector/index.cjs +1002 -1002
- package/dist/vector/index.js +7 -7
- package/package.json +1 -1
- package/skills/pixerate-brushes/SKILL.md +1 -0
- package/skills/pixerate-paint-editor/SKILL.md +7 -1
- package/skills/pixerate-paint-editor/references/brush-facets.md +1 -0
- package/skills/pixerate-paint-editor/references/live-patterns.md +41 -0
- package/skills/pixerate-paint-watercolour/SKILL.md +8 -0
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
LivePatternField,
|
|
3
|
+
moveLivePatternSnapshot
|
|
4
|
+
} from "./chunk-LDZOXESA.js";
|
|
1
5
|
import {
|
|
2
6
|
TILE,
|
|
3
7
|
TiledSurface,
|
|
@@ -852,10 +856,30 @@ var noLight = () => new TiledSurface(1, /* @__PURE__ */ new Map(), 0);
|
|
|
852
856
|
function cloneGhost(g) {
|
|
853
857
|
return g ? { pigment: [...g.pigment], remaining: g.remaining, total: g.total, linger: g.linger, ...g.trigger === "agent" ? { trigger: "agent" } : {} } : null;
|
|
854
858
|
}
|
|
855
|
-
function newLane(id, index, params, flow, flowStrength, base, light, ghost) {
|
|
859
|
+
function newLane(id, index, params, flow, flowStrength, base, light, width, height, ghost, livePatterns) {
|
|
856
860
|
const l = light ?? noLight();
|
|
857
861
|
const g = cloneGhost(ghost);
|
|
858
|
-
return {
|
|
862
|
+
return {
|
|
863
|
+
id,
|
|
864
|
+
index,
|
|
865
|
+
params,
|
|
866
|
+
flow,
|
|
867
|
+
flowStrength,
|
|
868
|
+
base,
|
|
869
|
+
shaded: /* @__PURE__ */ new Map(),
|
|
870
|
+
urgent: /* @__PURE__ */ new Set(),
|
|
871
|
+
stamp: 1,
|
|
872
|
+
display: null,
|
|
873
|
+
shadedVersion: 0,
|
|
874
|
+
displayKey: "",
|
|
875
|
+
light: l,
|
|
876
|
+
lit: !g && l.tiles.size > 0,
|
|
877
|
+
ghost: g,
|
|
878
|
+
lightShaded: /* @__PURE__ */ new Map(),
|
|
879
|
+
lightDisplay: null,
|
|
880
|
+
lightKey: "",
|
|
881
|
+
livePatterns: livePatterns ?? new LivePatternField(width, height)
|
|
882
|
+
};
|
|
859
883
|
}
|
|
860
884
|
var WetWorldError = class extends Error {
|
|
861
885
|
constructor(message) {
|
|
@@ -1016,12 +1040,28 @@ var WetWorld = class {
|
|
|
1016
1040
|
if (options.params) this.setParams(id, options.params);
|
|
1017
1041
|
if (options.base) this.setBase(id, options.base);
|
|
1018
1042
|
if (options.light) this.setLight(id, options.light);
|
|
1043
|
+
if (options.livePatterns && existing.livePatterns !== options.livePatterns) {
|
|
1044
|
+
existing.livePatterns = options.livePatterns;
|
|
1045
|
+
this.touchAll(existing);
|
|
1046
|
+
}
|
|
1019
1047
|
if (options.ghost !== void 0) this.setGhost(id, options.ghost);
|
|
1020
1048
|
return;
|
|
1021
1049
|
}
|
|
1022
1050
|
const index = this.lanes.indexOf(null);
|
|
1023
1051
|
if (index < 0) throw new WetWorldError(`At most ${MAX_WET_LANES} layers can hold wet paint at once; dry one (dry_paint) first.`);
|
|
1024
|
-
this.lanes[index] = newLane(
|
|
1052
|
+
this.lanes[index] = newLane(
|
|
1053
|
+
id,
|
|
1054
|
+
index,
|
|
1055
|
+
normalizeWetParams(options.params ?? {}, DEFAULT_WET_PARAMS),
|
|
1056
|
+
options.flow ?? null,
|
|
1057
|
+
options.flow ? options.flowStrength ?? 1 : 0,
|
|
1058
|
+
options.base ?? new TiledSurface(4, /* @__PURE__ */ new Map(), 0),
|
|
1059
|
+
options.light,
|
|
1060
|
+
this.width,
|
|
1061
|
+
this.height,
|
|
1062
|
+
options.ghost,
|
|
1063
|
+
options.livePatterns
|
|
1064
|
+
);
|
|
1025
1065
|
this.pack(this.lanes[index]);
|
|
1026
1066
|
}
|
|
1027
1067
|
/** Drops a wet layer and its wet paint (nothing is baked). */
|
|
@@ -1041,6 +1081,52 @@ var WetWorld = class {
|
|
|
1041
1081
|
this.pack(lane);
|
|
1042
1082
|
return { ...lane.params };
|
|
1043
1083
|
}
|
|
1084
|
+
getLivePatterns(id) {
|
|
1085
|
+
return { ...this.laneOf(id).livePatterns.settings };
|
|
1086
|
+
}
|
|
1087
|
+
hasLivePatterns(id) {
|
|
1088
|
+
const lane = this.laneOf(id);
|
|
1089
|
+
return lane.livePatterns.enabled;
|
|
1090
|
+
}
|
|
1091
|
+
livePatternField(id) {
|
|
1092
|
+
return this.laneOf(id).livePatterns;
|
|
1093
|
+
}
|
|
1094
|
+
setLivePatterns(id, settings) {
|
|
1095
|
+
this.requireIdle();
|
|
1096
|
+
const lane = this.laneOf(id);
|
|
1097
|
+
const next = lane.livePatterns.configure(settings);
|
|
1098
|
+
this.touchAll(lane);
|
|
1099
|
+
return next;
|
|
1100
|
+
}
|
|
1101
|
+
seedLivePatterns(id, cx, cy, radius, seed = 1, strength = 1, settings) {
|
|
1102
|
+
this.requireIdle();
|
|
1103
|
+
const lane = this.laneOf(id);
|
|
1104
|
+
if (settings) lane.livePatterns.configure(settings);
|
|
1105
|
+
const count = lane.livePatterns.seedDisc(cx, cy, radius, seed, strength);
|
|
1106
|
+
if (count > 0) this.touchAll(lane);
|
|
1107
|
+
return count;
|
|
1108
|
+
}
|
|
1109
|
+
livePatternStats(id) {
|
|
1110
|
+
const lane = this.laneOf(id);
|
|
1111
|
+
return lane.livePatterns.stats((tx, ty, lx, ly) => this.isPatternCellWet(lane, tx, ty, lx, ly));
|
|
1112
|
+
}
|
|
1113
|
+
isPatternCellWet(lane, tx, ty, lx, ly) {
|
|
1114
|
+
const { tilesX, tilesY, perLane } = this.layout;
|
|
1115
|
+
if (tx < 0 || ty < 0 || tx >= tilesX || ty >= tilesY) return false;
|
|
1116
|
+
const slot = this.slotOf(lane.index * perLane + ty * tilesX + tx);
|
|
1117
|
+
if (slot < 0) return false;
|
|
1118
|
+
const cur = this.slotBase(slot) + this.parity * SET_PLANES * PLANE;
|
|
1119
|
+
const x0 = lx * 2 + 1;
|
|
1120
|
+
const y0 = ly * 2 + 1;
|
|
1121
|
+
const c00 = y0 * S2 + x0;
|
|
1122
|
+
const c10 = c00 + 1;
|
|
1123
|
+
const c01 = c00 + S2;
|
|
1124
|
+
const c11 = c01 + 1;
|
|
1125
|
+
const rhoBase = cur + P_RHO * PLANE;
|
|
1126
|
+
const swBase = cur + P_SW * PLANE;
|
|
1127
|
+
const f = this.f32;
|
|
1128
|
+
return f[rhoBase + c00] + f[swBase + c00] > DRY_EPS || f[rhoBase + c10] + f[swBase + c10] > DRY_EPS || f[rhoBase + c01] + f[swBase + c01] > DRY_EPS || f[rhoBase + c11] + f[swBase + c11] > DRY_EPS;
|
|
1129
|
+
}
|
|
1044
1130
|
getTilt() {
|
|
1045
1131
|
return { ...this.tilt };
|
|
1046
1132
|
}
|
|
@@ -1378,6 +1464,14 @@ var WetWorld = class {
|
|
|
1378
1464
|
const flagsBase = l.flags >> 2;
|
|
1379
1465
|
const lastBase = l.last >> 2;
|
|
1380
1466
|
const { tilesX, tilesY, perLane } = l;
|
|
1467
|
+
for (const lane of this.lanes) {
|
|
1468
|
+
if (!lane || !lane.livePatterns.enabled || lane.livePatterns.tiles.size === 0) continue;
|
|
1469
|
+
lane.livePatterns.step(
|
|
1470
|
+
n,
|
|
1471
|
+
(tx, ty, lx, ly) => this.isPatternCellWet(lane, tx, ty, lx, ly),
|
|
1472
|
+
(tx, ty) => this.slotOf(lane.index * perLane + ty * tilesX + tx) >= 0
|
|
1473
|
+
);
|
|
1474
|
+
}
|
|
1381
1475
|
const wakeups = [];
|
|
1382
1476
|
for (const key of this.active) {
|
|
1383
1477
|
const fl = this.u32[flagsBase + key];
|
|
@@ -2051,6 +2145,7 @@ var WetWorld = class {
|
|
|
2051
2145
|
}
|
|
2052
2146
|
const src = lane.base.tiles.get(tk)?.data ?? null;
|
|
2053
2147
|
const out = this.shadeSlot(key, src, all ? "bake-all" : "bake");
|
|
2148
|
+
if (lane.livePatterns.enabled) lane.livePatterns.markBaked(tx, ty);
|
|
2054
2149
|
if (!out) return lightChanged;
|
|
2055
2150
|
const tiles = new Map(lane.base.tiles);
|
|
2056
2151
|
const t = finishTile(out, 4, 0);
|
|
@@ -2086,7 +2181,7 @@ var WetWorld = class {
|
|
|
2086
2181
|
const h = Math.min(WET_TILE, this.height - ty * WET_TILE);
|
|
2087
2182
|
const lane = this.lanes[this.laneIndexOf(key)];
|
|
2088
2183
|
const lit = lane.lit && !lane.ghost;
|
|
2089
|
-
|
|
2184
|
+
let changed = shadeTile(
|
|
2090
2185
|
this.f32,
|
|
2091
2186
|
PLANE,
|
|
2092
2187
|
S2,
|
|
@@ -2103,6 +2198,9 @@ var WetWorld = class {
|
|
|
2103
2198
|
lit ? b + P_DL * PLANE : -1,
|
|
2104
2199
|
lit && mode !== "bake" ? cur + P_L * PLANE : -1
|
|
2105
2200
|
);
|
|
2201
|
+
if (lane.livePatterns.enabled && lane.livePatterns.tiles.size > 0) {
|
|
2202
|
+
changed = lane.livePatterns.shadeTile(tx, ty, out, w, h) || changed;
|
|
2203
|
+
}
|
|
2106
2204
|
return changed ? out : null;
|
|
2107
2205
|
}
|
|
2108
2206
|
/** The layer's pixels with all its wet paint dried where it is (the bake of "dry on save"); changes nothing. */
|
|
@@ -2550,7 +2648,11 @@ var WetWorld = class {
|
|
|
2550
2648
|
slots.set(key, { planes, last: this.u32[(this.layout.last >> 2) + key] });
|
|
2551
2649
|
bytes += planes.byteLength;
|
|
2552
2650
|
}
|
|
2553
|
-
const lanes = this.lanes.filter((l) => Boolean(l)).map((l) =>
|
|
2651
|
+
const lanes = this.lanes.filter((l) => Boolean(l)).map((l) => {
|
|
2652
|
+
const lp = l.livePatterns.snapshot();
|
|
2653
|
+
bytes += lp.bytes;
|
|
2654
|
+
return { id: l.id, index: l.index, params: { ...l.params }, flow: l.flow, flowStrength: l.flowStrength, base: l.base, light: l.light, lit: l.lit, ghost: cloneGhost(l.ghost), livePatterns: lp };
|
|
2655
|
+
});
|
|
2554
2656
|
return { clock: this.clock, tilt: { ...this.tilt }, lanes, slots, bytes };
|
|
2555
2657
|
}
|
|
2556
2658
|
/** Puts a snapshot back exactly (the simulation then continues as it would have). */
|
|
@@ -2560,8 +2662,9 @@ var WetWorld = class {
|
|
|
2560
2662
|
this.lanes.fill(null);
|
|
2561
2663
|
this.tilt = { ...snap.tilt };
|
|
2562
2664
|
for (const l of snap.lanes) {
|
|
2563
|
-
const lane = newLane(l.id, l.index, { ...l.params }, l.flow, l.flowStrength, l.base, l.light, l.ghost);
|
|
2665
|
+
const lane = newLane(l.id, l.index, { ...l.params }, l.flow, l.flowStrength, l.base, l.light, this.width, this.height, l.ghost);
|
|
2564
2666
|
lane.lit = !lane.ghost && (lane.lit || Boolean(l.lit));
|
|
2667
|
+
if (l.livePatterns) lane.livePatterns.restore(l.livePatterns);
|
|
2565
2668
|
this.lanes[l.index] = lane;
|
|
2566
2669
|
this.pack(this.lanes[l.index]);
|
|
2567
2670
|
}
|
|
@@ -2619,9 +2722,19 @@ function moveWetSnapshot(snap, from, to, dx, dy, lane = () => ({})) {
|
|
|
2619
2722
|
}
|
|
2620
2723
|
const lanes = snap.lanes.map((l) => {
|
|
2621
2724
|
const moved = lane(l);
|
|
2622
|
-
|
|
2725
|
+
const lp = l.livePatterns ? moveLivePatternSnapshot(l.livePatterns, to, tx0, ty0) : void 0;
|
|
2726
|
+
if (lp) bytes += lp.bytes;
|
|
2727
|
+
return { ...l, base: moved.base ?? l.base, light: moved.light ?? l.light, flow: moved.flow === void 0 ? l.flow : moved.flow, ...lp ? { livePatterns: lp } : {} };
|
|
2623
2728
|
});
|
|
2624
|
-
|
|
2729
|
+
let patterns;
|
|
2730
|
+
if (snap.patterns) {
|
|
2731
|
+
patterns = /* @__PURE__ */ new Map();
|
|
2732
|
+
for (const [id, p] of snap.patterns) {
|
|
2733
|
+
const mp = moveLivePatternSnapshot(p, to, tx0, ty0);
|
|
2734
|
+
patterns.set(id, mp);
|
|
2735
|
+
}
|
|
2736
|
+
}
|
|
2737
|
+
return { clock: snap.clock, tilt: { ...snap.tilt }, lanes, slots, ...patterns ? { patterns } : {}, bytes };
|
|
2625
2738
|
}
|
|
2626
2739
|
function unionRect(a, b) {
|
|
2627
2740
|
if (!a) return { ...b };
|