@pixerate/editor 0.213.0 → 0.215.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/{chunk-UOGKSVRQ.cjs → chunk-B46UQUDC.cjs} +770 -733
- package/dist/{chunk-W3TOZTL7.js → chunk-F7Z2MKY2.js} +115 -4
- package/dist/{chunk-YBJXCQTR.js → chunk-QXY4YTRI.js} +738 -701
- package/dist/{chunk-H65IBXFI.cjs → chunk-S55JFWDA.cjs} +350 -239
- package/dist/{chunk-QYLWG22N.cjs → chunk-SS53NNZO.cjs} +304 -1
- package/dist/{chunk-LQ5SALHK.js → chunk-U7C655AM.js} +5 -311
- package/dist/{chunk-L52VMQZS.cjs → chunk-UC3PWFM3.cjs} +68 -374
- package/dist/{chunk-L3G23N5Y.js → chunk-ZNA3IQZF.js} +304 -1
- package/dist/image-editor/controller.d.cts +44 -0
- package/dist/image-editor/controller.d.ts +44 -0
- package/dist/image-editor/index.cjs +1768 -1140
- package/dist/image-editor/index.d.cts +1 -0
- package/dist/image-editor/index.d.ts +1 -0
- package/dist/image-editor/index.js +660 -32
- package/dist/image-editor/layers/edge-color.d.cts +27 -0
- package/dist/image-editor/layers/edge-color.d.ts +27 -0
- package/dist/image-editor/layers/serialize.d.cts +13 -0
- package/dist/image-editor/layers/serialize.d.ts +13 -0
- package/dist/image-editor/selection/index.d.cts +1 -0
- package/dist/image-editor/selection/index.d.ts +1 -0
- package/dist/image-editor/selection/inspect.d.cts +70 -0
- package/dist/image-editor/selection/inspect.d.ts +70 -0
- package/dist/image-editor/selection-worker.cjs +4 -4
- package/dist/image-editor/selection-worker.js +2 -2
- package/dist/paint-editor/index.cjs +79 -79
- package/dist/paint-editor/index.js +3 -3
- package/dist/raster/compositor.d.cts +10 -1
- package/dist/raster/compositor.d.ts +10 -1
- package/dist/raster/deep-compositor.d.cts +1 -1
- package/dist/raster/deep-compositor.d.ts +1 -1
- package/dist/raster/index.cjs +4 -2
- package/dist/raster/index.js +3 -1
- package/dist/raster/layers.d.cts +16 -0
- package/dist/raster/layers.d.ts +16 -0
- package/package.json +1 -1
- package/skills/pixerate-image-editor/SKILL.md +9 -6
- package/skills/pixerate-image-editor/references/paths.md +12 -0
- package/skills/pixerate-image-selection-masking/SKILL.md +17 -17
|
@@ -7,9 +7,9 @@ var _chunkZ64NRDEHcjs = require('../chunk-Z64NRDEH.cjs');
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkS55JFWDAcjs = require('../chunk-S55JFWDA.cjs');
|
|
11
11
|
require('../chunk-A2IS7EHE.cjs');
|
|
12
|
-
require('../chunk-
|
|
12
|
+
require('../chunk-SS53NNZO.cjs');
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
var _chunkPY4GWSE2cjs = require('../chunk-PY4GWSE2.cjs');
|
|
@@ -20,7 +20,7 @@ var _chunkPY4GWSE2cjs = require('../chunk-PY4GWSE2.cjs');
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
var
|
|
23
|
+
var _chunkB46UQUDCcjs = require('../chunk-B46UQUDC.cjs');
|
|
24
24
|
require('../chunk-QT26RHKK.cjs');
|
|
25
25
|
require('../chunk-K6PXS6DO.cjs');
|
|
26
26
|
|
|
@@ -1581,7 +1581,7 @@ var PROFILE = {
|
|
|
1581
1581
|
}
|
|
1582
1582
|
};
|
|
1583
1583
|
function createPaintCompositor() {
|
|
1584
|
-
return new (0,
|
|
1584
|
+
return new (0, _chunkB46UQUDCcjs.RasterCompositor)(PROFILE);
|
|
1585
1585
|
}
|
|
1586
1586
|
function downsampleRgba(data, width, height, tw, th) {
|
|
1587
1587
|
tw = Math.max(1, Math.round(tw));
|
|
@@ -1657,11 +1657,11 @@ function header(state, options) {
|
|
|
1657
1657
|
return out;
|
|
1658
1658
|
}
|
|
1659
1659
|
function serializePaintDocument(state, options = {}) {
|
|
1660
|
-
const { layers, assets } =
|
|
1660
|
+
const { layers, assets } = _chunkS55JFWDAcjs.serializeLayers.call(void 0, state.layers);
|
|
1661
1661
|
return { ...header(state, options), layers, assets };
|
|
1662
1662
|
}
|
|
1663
1663
|
async function serializePaintDocumentExternal(state, store, options = {}) {
|
|
1664
|
-
const { layers, assets } = await
|
|
1664
|
+
const { layers, assets } = await _chunkS55JFWDAcjs.serializeLayersExternal.call(void 0, state.layers, store);
|
|
1665
1665
|
return { ...header(state, options), layers, assets };
|
|
1666
1666
|
}
|
|
1667
1667
|
function paintLayersOnly(layers, problems) {
|
|
@@ -1698,9 +1698,9 @@ function deserializePaintDocument(raw) {
|
|
|
1698
1698
|
const canvas = normalizeCanvas({ width: r.width, height: r.height, dpi: _nullishCoalesce(r.dpi, () => ( void 0)) });
|
|
1699
1699
|
const paper = _chunkROVK6AXXcjs.normalizePaper.call(void 0, _nullishCoalesce(r.paper, () => ( {})));
|
|
1700
1700
|
const assets = r.assets && typeof r.assets === "object" ? r.assets : {};
|
|
1701
|
-
const layers = paintLayersOnly(
|
|
1701
|
+
const layers = paintLayersOnly(_chunkS55JFWDAcjs.deserializeLayers.call(void 0, r.layers, { assets, problems }), problems);
|
|
1702
1702
|
const wanted = typeof r.activeLayerId === "string" ? r.activeLayerId : null;
|
|
1703
|
-
const activeLayerId = wanted &&
|
|
1703
|
+
const activeLayerId = wanted && _chunkB46UQUDCcjs.findLayer.call(void 0, layers, wanted) ? wanted : _nullishCoalesce(_optionalChain([_chunkB46UQUDCcjs.flattenLayers.call(void 0, layers), 'access', _70 => _70.filter, 'call', _71 => _71((l) => l.type === "pixel"), 'access', _72 => _72.pop, 'call', _73 => _73(), 'optionalAccess', _74 => _74.id]), () => ( null));
|
|
1704
1704
|
const wetEvents = Array.isArray(r.wetEvents) ? r.wetEvents.filter((e) => e && typeof e === "object" && Number.isInteger(e.clock) && typeof e.kind === "string") : [];
|
|
1705
1705
|
const state = { canvas, paper, layers, activeLayerId, strokes: readStrokes(r.strokes, problems) };
|
|
1706
1706
|
if (wetEvents.length) state.wetEvents = wetEvents;
|
|
@@ -1714,7 +1714,7 @@ async function deserializePaintDocumentAsync(raw, store) {
|
|
|
1714
1714
|
if (!raw || typeof raw !== "object") throw new Error("Not a paint document: expected a JSON object.");
|
|
1715
1715
|
const r = raw;
|
|
1716
1716
|
const problems = [];
|
|
1717
|
-
const assets = await
|
|
1717
|
+
const assets = await _chunkS55JFWDAcjs.resolveExternalAssets.call(void 0, _nullishCoalesce(r.assets, () => ( {})), store, problems);
|
|
1718
1718
|
const loaded = deserializePaintDocument({ ...r, assets });
|
|
1719
1719
|
return { ...loaded, problems: [...problems, ...loaded.problems] };
|
|
1720
1720
|
}
|
|
@@ -3044,7 +3044,7 @@ function replayItems(doc) {
|
|
|
3044
3044
|
}
|
|
3045
3045
|
function emptiedLayers(layers) {
|
|
3046
3046
|
let out = [...layers];
|
|
3047
|
-
for (const l of
|
|
3047
|
+
for (const l of _chunkB46UQUDCcjs.flattenLayers.call(void 0, layers)) if (l.type === "pixel") out = _chunkB46UQUDCcjs.mapLayer.call(void 0, out, l.id, () => ({ ...l, surface: _chunk474IQG74cjs.emptySurface.call(void 0, 4), offset: { x: 0, y: 0 } }));
|
|
3048
3048
|
return out;
|
|
3049
3049
|
}
|
|
3050
3050
|
async function replayPainting(source, target, options = {}) {
|
|
@@ -3435,12 +3435,12 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
3435
3435
|
canvas: () => this.doc.canvas,
|
|
3436
3436
|
paper: () => this.doc.paper,
|
|
3437
3437
|
layerSurface: (id) => {
|
|
3438
|
-
const l = _optionalChain([
|
|
3438
|
+
const l = _optionalChain([_chunkB46UQUDCcjs.findLayer.call(void 0, this.doc.layers, id), 'optionalAccess', _162 => _162.layer]);
|
|
3439
3439
|
return isPixelLayer(l) ? l.surface : null;
|
|
3440
3440
|
},
|
|
3441
3441
|
updateSurfaces: (surfaces, rects) => {
|
|
3442
3442
|
let layers = this.doc.layers;
|
|
3443
|
-
for (const [id, surface] of surfaces) if (
|
|
3443
|
+
for (const [id, surface] of surfaces) if (_chunkB46UQUDCcjs.findLayer.call(void 0, layers, id)) layers = _chunkB46UQUDCcjs.mapLayer.call(void 0, layers, id, (l) => ({ ...l, surface }));
|
|
3444
3444
|
this.doc = { ...this.doc, layers };
|
|
3445
3445
|
this.emit(rects.length ? rects : "all");
|
|
3446
3446
|
},
|
|
@@ -3771,7 +3771,7 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
3771
3771
|
}
|
|
3772
3772
|
// --- Layers --------------------------------------------------------------------
|
|
3773
3773
|
getLayer(id) {
|
|
3774
|
-
return _optionalChain([
|
|
3774
|
+
return _optionalChain([_chunkB46UQUDCcjs.findLayer.call(void 0, this.doc.layers, id), 'optionalAccess', _177 => _177.layer]);
|
|
3775
3775
|
}
|
|
3776
3776
|
/** The active pixel layer (or `undefined`). */
|
|
3777
3777
|
getActiveLayer() {
|
|
@@ -3790,12 +3790,12 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
3790
3790
|
walk(this.doc.layers, null, 0);
|
|
3791
3791
|
return out;
|
|
3792
3792
|
}
|
|
3793
|
-
describeLayer(l, parentId = _nullishCoalesce(_optionalChain([
|
|
3793
|
+
describeLayer(l, parentId = _nullishCoalesce(_optionalChain([_chunkB46UQUDCcjs.findLayer.call(void 0, this.doc.layers, l.id), 'optionalAccess', _178 => _178.parent, 'optionalAccess', _179 => _179.id]), () => ( null)), depth = _nullishCoalesce(_optionalChain([_chunkB46UQUDCcjs.findLayer.call(void 0, this.doc.layers, l.id), 'optionalAccess', _180 => _180.path, 'access', _181 => _181.length]), () => ( 0))) {
|
|
3794
3794
|
let bounds = null;
|
|
3795
3795
|
if (l.type === "pixel") {
|
|
3796
3796
|
const b = _chunk474IQG74cjs.contentBounds.call(void 0, l.surface);
|
|
3797
3797
|
bounds = b ? { ...b, x: b.x + l.offset.x, y: b.y + l.offset.y } : null;
|
|
3798
|
-
} else for (const c of
|
|
3798
|
+
} else for (const c of _chunkB46UQUDCcjs.flattenLayers.call(void 0, l.children)) if (c.type === "pixel") bounds = unionRect(bounds, this.describeLayer(c, l.id, depth + 1).bounds);
|
|
3799
3799
|
return {
|
|
3800
3800
|
id: l.id,
|
|
3801
3801
|
name: l.name,
|
|
@@ -3822,7 +3822,7 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
3822
3822
|
if (!id) throw new PaintEditorError(`There is no active layer to ${what}; add one with add_layer.`);
|
|
3823
3823
|
const l = this.requireLayer(id);
|
|
3824
3824
|
if (!isPixelLayer(l)) throw new PaintEditorError(`Layer "${l.name}" is a group; ${what} a pixel layer inside it.`);
|
|
3825
|
-
if (
|
|
3825
|
+
if (_chunkB46UQUDCcjs.isLayerLocked.call(void 0, l, "pixels")) throw new PaintEditorError(`Layer "${l.name}" has its pixels locked; unlock it (update_layer locks) before you ${what} it.`);
|
|
3826
3826
|
if (!l.visible) throw new PaintEditorError(`Layer "${l.name}" is hidden; show it (update_layer visible true) before you ${what} it.`);
|
|
3827
3827
|
return l;
|
|
3828
3828
|
}
|
|
@@ -3835,7 +3835,7 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
3835
3835
|
/** Adds an empty pixel layer or group above `aboveId` (default: the active layer) and makes it active. */
|
|
3836
3836
|
addLayer(options = {}) {
|
|
3837
3837
|
this.requireIdle("adding a layer");
|
|
3838
|
-
const count =
|
|
3838
|
+
const count = _chunkB46UQUDCcjs.flattenLayers.call(void 0, this.doc.layers).length;
|
|
3839
3839
|
const type = _nullishCoalesce(options.type, () => ( "pixel"));
|
|
3840
3840
|
const name = _optionalChain([options, 'access', _182 => _182.name, 'optionalAccess', _183 => _183.trim, 'call', _184 => _184()]) || (type === "group" ? `Group ${count + 1}` : `Layer ${count + 1}`);
|
|
3841
3841
|
const layer = type === "group" ? { type: "group", id: newPaintLayerId(), name, visible: true, opacity: 1, blend: "pass-through", children: [] } : createPaintLayer(name);
|
|
@@ -3847,19 +3847,19 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
3847
3847
|
if (g.type !== "group") throw new PaintEditorError(`Layer "${g.name}" is not a group; pass a group id as parentId.`);
|
|
3848
3848
|
parentId = g.id;
|
|
3849
3849
|
} else if (above) {
|
|
3850
|
-
const loc =
|
|
3850
|
+
const loc = _chunkB46UQUDCcjs.findLayer.call(void 0, this.doc.layers, above);
|
|
3851
3851
|
if (!loc) throw new PaintEditorError(`Unknown layer "${above}". Call list_layers for the ids.`);
|
|
3852
3852
|
parentId = _nullishCoalesce(_optionalChain([loc, 'access', _185 => _185.parent, 'optionalAccess', _186 => _186.id]), () => ( null));
|
|
3853
3853
|
index = loc.index + 1;
|
|
3854
3854
|
}
|
|
3855
|
-
const layers =
|
|
3855
|
+
const layers = _chunkB46UQUDCcjs.insertLayer.call(void 0, this.doc.layers, layer, parentId, index);
|
|
3856
3856
|
this.commit(type === "group" ? "Add group" : "Add layer", { ...this.doc, layers, activeLayerId: layer.id });
|
|
3857
3857
|
return this.describeLayer(layer);
|
|
3858
3858
|
}
|
|
3859
3859
|
updateLayer(id, update) {
|
|
3860
3860
|
this.requireIdle("changing a layer");
|
|
3861
3861
|
const l = this.requireLayer(id);
|
|
3862
|
-
if (
|
|
3862
|
+
if (_chunkB46UQUDCcjs.isLayerLocked.call(void 0, l, "all") && Object.keys(update).some((k) => k !== "locks")) throw new PaintEditorError(`Layer "${l.name}" is fully locked; unlock it first (locks {all: false}).`);
|
|
3863
3863
|
if (update.opacity !== void 0 && !(update.opacity >= 0 && update.opacity <= 1)) throw new PaintEditorError(`opacity ${update.opacity} is out of range; use 0..1.`);
|
|
3864
3864
|
if (update.blend !== void 0 && !_chunkOLNIPTB3cjs.isBlendMode.call(void 0, update.blend) && !(l.type === "group" && update.blend === "pass-through")) {
|
|
3865
3865
|
throw new PaintEditorError(`Unknown blend mode "${update.blend}". Call get_canvas_info for the blend modes.`);
|
|
@@ -3875,31 +3875,31 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
3875
3875
|
const locks = { ..._nullishCoalesce(l.locks, () => ( {})), ...update.locks };
|
|
3876
3876
|
next.locks = Object.values(locks).some(Boolean) ? locks : void 0;
|
|
3877
3877
|
}
|
|
3878
|
-
this.commit("Layer properties", { ...this.doc, layers:
|
|
3878
|
+
this.commit("Layer properties", { ...this.doc, layers: _chunkB46UQUDCcjs.mapLayer.call(void 0, this.doc.layers, id, () => next) });
|
|
3879
3879
|
return this.describeLayer(next);
|
|
3880
3880
|
}
|
|
3881
3881
|
removeLayer(id) {
|
|
3882
3882
|
this.requireIdle("removing a layer");
|
|
3883
3883
|
const l = this.requireLayer(id);
|
|
3884
|
-
if (
|
|
3885
|
-
const wetIds = this.wet.wetLayerIds().filter((x) => x === id || l.type === "group" &&
|
|
3884
|
+
if (_chunkB46UQUDCcjs.isLayerLocked.call(void 0, l, "all")) throw new PaintEditorError(`Layer "${l.name}" is fully locked; unlock it before removing it.`);
|
|
3885
|
+
const wetIds = this.wet.wetLayerIds().filter((x) => x === id || l.type === "group" && _chunkB46UQUDCcjs.findLayer.call(void 0, l.children, x));
|
|
3886
3886
|
if (wetIds.length) {
|
|
3887
3887
|
this.beginWetOp();
|
|
3888
3888
|
for (const x of wetIds) this.wet.world.removeLane(x);
|
|
3889
3889
|
}
|
|
3890
|
-
const layers =
|
|
3890
|
+
const layers = _chunkB46UQUDCcjs.mapLayer.call(void 0, this.doc.layers, id, () => null);
|
|
3891
3891
|
let active = this.doc.activeLayerId;
|
|
3892
|
-
if (active && !
|
|
3893
|
-
this.commit("Remove layer", { ...this.doc, layers, activeLayerId: active, ...this.thickWithout(
|
|
3892
|
+
if (active && !_chunkB46UQUDCcjs.findLayer.call(void 0, layers, active)) active = _nullishCoalesce(_optionalChain([_chunkB46UQUDCcjs.flattenLayers.call(void 0, layers), 'access', _187 => _187.filter, 'call', _188 => _188((x) => x.type === "pixel"), 'access', _189 => _189.pop, 'call', _190 => _190(), 'optionalAccess', _191 => _191.id]), () => ( null));
|
|
3893
|
+
this.commit("Remove layer", { ...this.doc, layers, activeLayerId: active, ...this.thickWithout(_chunkB46UQUDCcjs.flattenLayers.call(void 0, [l]).map((x) => x.id)), ...this.stickersWithout(_chunkB46UQUDCcjs.flattenLayers.call(void 0, [l]).map((x) => x.id)) });
|
|
3894
3894
|
return { removed: id, activeLayerId: active };
|
|
3895
3895
|
}
|
|
3896
3896
|
duplicateLayer(id) {
|
|
3897
3897
|
this.requireIdle("duplicating a layer");
|
|
3898
|
-
if (
|
|
3898
|
+
if (_chunkB46UQUDCcjs.findLayer.call(void 0, this.doc.layers, id)) {
|
|
3899
3899
|
const inside = (l) => l.type === "group" ? l.children.flatMap(inside) : [l.id];
|
|
3900
|
-
this.dryLayersFirst(inside(
|
|
3900
|
+
this.dryLayersFirst(inside(_chunkB46UQUDCcjs.findLayer.call(void 0, this.doc.layers, id).layer));
|
|
3901
3901
|
}
|
|
3902
|
-
const loc =
|
|
3902
|
+
const loc = _chunkB46UQUDCcjs.findLayer.call(void 0, this.doc.layers, id);
|
|
3903
3903
|
if (!loc) throw new PaintEditorError(`Unknown layer "${id}". Call list_layers for the ids.`);
|
|
3904
3904
|
const thick = { ..._nullishCoalesce(this.doc.thick, () => ( {})) };
|
|
3905
3905
|
const stickers = { ..._nullishCoalesce(this.doc.stickers, () => ( {})) };
|
|
@@ -3910,43 +3910,43 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
3910
3910
|
return l.type === "group" ? { ...l, id: id2, children: l.children.map(copy) } : { ...l, id: id2 };
|
|
3911
3911
|
};
|
|
3912
3912
|
const dup = { ...copy(loc.layer), name: `${loc.layer.name} copy` };
|
|
3913
|
-
const layers =
|
|
3913
|
+
const layers = _chunkB46UQUDCcjs.insertLayer.call(void 0, this.doc.layers, dup, _nullishCoalesce(_optionalChain([loc, 'access', _192 => _192.parent, 'optionalAccess', _193 => _193.id]), () => ( null)), loc.index + 1);
|
|
3914
3914
|
this.commit("Duplicate layer", this.withWetEvents({ ...this.doc, layers, activeLayerId: dup.id, ...this.doc.thick ? { thick } : {}, ...this.doc.stickers ? { stickers } : {} }));
|
|
3915
3915
|
return this.describeLayer(dup);
|
|
3916
3916
|
}
|
|
3917
3917
|
/** Moves a layer to `index` (0 = bottom) within `parentId` (default its own parent; `null` = top level). */
|
|
3918
3918
|
moveLayer(id, index, parentId) {
|
|
3919
3919
|
this.requireIdle("moving a layer");
|
|
3920
|
-
const loc =
|
|
3920
|
+
const loc = _chunkB46UQUDCcjs.findLayer.call(void 0, this.doc.layers, id);
|
|
3921
3921
|
if (!loc) throw new PaintEditorError(`Unknown layer "${id}". Call list_layers for the ids.`);
|
|
3922
3922
|
const target = parentId === void 0 ? _nullishCoalesce(_optionalChain([loc, 'access', _194 => _194.parent, 'optionalAccess', _195 => _195.id]), () => ( null)) : parentId;
|
|
3923
3923
|
if (target) {
|
|
3924
3924
|
const g = this.requireLayer(target);
|
|
3925
3925
|
if (g.type !== "group") throw new PaintEditorError(`Layer "${g.name}" is not a group; pass a group id as parentId.`);
|
|
3926
|
-
if (target === id || loc.layer.type === "group" &&
|
|
3926
|
+
if (target === id || loc.layer.type === "group" && _chunkB46UQUDCcjs.findLayer.call(void 0, loc.layer.children, target)) throw new PaintEditorError("A group cannot move into itself.");
|
|
3927
3927
|
}
|
|
3928
|
-
const without =
|
|
3929
|
-
const siblings = target ?
|
|
3928
|
+
const without = _chunkB46UQUDCcjs.mapLayer.call(void 0, this.doc.layers, id, () => null);
|
|
3929
|
+
const siblings = target ? _chunkB46UQUDCcjs.findLayer.call(void 0, without, target).layer.children : without;
|
|
3930
3930
|
if (!Number.isInteger(index) || index < 0 || index > siblings.length) throw new PaintEditorError(`index ${index} is out of range; use 0..${siblings.length} (0 is the bottom).`);
|
|
3931
|
-
const layers =
|
|
3931
|
+
const layers = _chunkB46UQUDCcjs.insertLayer.call(void 0, without, loc.layer, target, index);
|
|
3932
3932
|
this.commit("Move layer", { ...this.doc, layers });
|
|
3933
3933
|
return this.describeLayer(loc.layer);
|
|
3934
3934
|
}
|
|
3935
3935
|
/** Merges a pixel layer into the pixel layer below it (keeping the lower one's settings). */
|
|
3936
3936
|
mergeDown(id) {
|
|
3937
3937
|
this.requireIdle("merging");
|
|
3938
|
-
const pre =
|
|
3938
|
+
const pre = _chunkB46UQUDCcjs.findLayer.call(void 0, this.doc.layers, id);
|
|
3939
3939
|
if (pre) {
|
|
3940
3940
|
const sib = pre.parent ? pre.parent.children : this.doc.layers;
|
|
3941
3941
|
this.dryLayersFirst([id, _optionalChain([sib, 'access', _196 => _196[pre.index - 1], 'optionalAccess', _197 => _197.id])].filter((x) => Boolean(x)));
|
|
3942
3942
|
}
|
|
3943
|
-
const loc =
|
|
3943
|
+
const loc = _chunkB46UQUDCcjs.findLayer.call(void 0, this.doc.layers, id);
|
|
3944
3944
|
if (!loc) throw new PaintEditorError(`Unknown layer "${id}". Call list_layers for the ids.`);
|
|
3945
3945
|
const siblings = loc.parent ? loc.parent.children : this.doc.layers;
|
|
3946
3946
|
const below = siblings[loc.index - 1];
|
|
3947
3947
|
const upper = loc.layer;
|
|
3948
3948
|
if (!isPixelLayer(upper) || !isPixelLayer(below)) throw new PaintEditorError("Merge down needs a pixel layer directly above another pixel layer in the same group.");
|
|
3949
|
-
if (
|
|
3949
|
+
if (_chunkB46UQUDCcjs.isLayerLocked.call(void 0, below, "pixels")) throw new PaintEditorError(`Layer "${below.name}" has its pixels locked; unlock it to merge into it.`);
|
|
3950
3950
|
const rect = unionRect(this.describeLayer(below).bounds, this.describeLayer(upper).bounds);
|
|
3951
3951
|
let surface = _chunk474IQG74cjs.emptySurface.call(void 0, 4);
|
|
3952
3952
|
if (rect) {
|
|
@@ -3956,7 +3956,7 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
3956
3956
|
surface = _chunk474IQG74cjs.surfaceFromPixels.call(void 0, { width: rect.width, height: rect.height, data: px }, 4, rect.x, rect.y);
|
|
3957
3957
|
}
|
|
3958
3958
|
const merged = { ...below, surface, offset: { x: 0, y: 0 } };
|
|
3959
|
-
const layers =
|
|
3959
|
+
const layers = _chunkB46UQUDCcjs.mapLayer.call(void 0, _chunkB46UQUDCcjs.mapLayer.call(void 0, this.doc.layers, upper.id, () => null), below.id, () => merged);
|
|
3960
3960
|
this.commit("Merge down", this.withWetEvents({ ...this.doc, layers, activeLayerId: below.id, ...this.thickWithout([upper.id]), ...this.stickersWithout([upper.id, below.id]) }));
|
|
3961
3961
|
return this.describeLayer(merged);
|
|
3962
3962
|
}
|
|
@@ -3969,7 +3969,7 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
3969
3969
|
this.wet.world.removeLane(l.id);
|
|
3970
3970
|
}
|
|
3971
3971
|
const bounds = this.describeLayer(l).bounds;
|
|
3972
|
-
this.commit("Clear layer", this.withPaintEvent({ ...this.doc, layers:
|
|
3972
|
+
this.commit("Clear layer", this.withPaintEvent({ ...this.doc, layers: _chunkB46UQUDCcjs.mapLayer.call(void 0, this.doc.layers, l.id, () => ({ ...l, surface: _chunk474IQG74cjs.emptySurface.call(void 0, 4) })), ...this.thickWithout([l.id]), ...this.stickersWithout([l.id]) }, { kind: "clear", layerId: l.id }));
|
|
3973
3973
|
return { layerId: l.id, bounds };
|
|
3974
3974
|
}
|
|
3975
3975
|
/**
|
|
@@ -4007,12 +4007,12 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
4007
4007
|
background: rgbaOf(this.doc.paper.color),
|
|
4008
4008
|
opacity,
|
|
4009
4009
|
blend,
|
|
4010
|
-
lockTransparency:
|
|
4010
|
+
lockTransparency: _chunkB46UQUDCcjs.isLayerLocked.call(void 0, l, "transparency"),
|
|
4011
4011
|
selection: null,
|
|
4012
4012
|
offset: l.offset
|
|
4013
4013
|
};
|
|
4014
4014
|
const surface = this.applyCoverage(l, coverage, rect, apply);
|
|
4015
|
-
this.commit("Fill layer", this.withPaintEvent(this.withWetEvents({ ...this.doc, layers:
|
|
4015
|
+
this.commit("Fill layer", this.withPaintEvent(this.withWetEvents({ ...this.doc, layers: _chunkB46UQUDCcjs.mapLayer.call(void 0, this.doc.layers, l.id, () => ({ ...l, surface })) }), { kind: "fill", layerId: l.id, data: { color, opacity, grain: grainAmount, pressure, blend } }));
|
|
4016
4016
|
return { layerId: l.id, bounds: rect };
|
|
4017
4017
|
}
|
|
4018
4018
|
applyCoverage(l, coverage, rect, apply) {
|
|
@@ -4053,7 +4053,7 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
4053
4053
|
}
|
|
4054
4054
|
/** The effect a layer is drawn from, or `undefined` for other layers. */
|
|
4055
4055
|
getEffectLayer(layerId) {
|
|
4056
|
-
return
|
|
4056
|
+
return _chunkB46UQUDCcjs.findLayer.call(void 0, this.doc.layers, layerId) ? _optionalChain([this, 'access', _206 => _206.doc, 'access', _207 => _207.effectLayers, 'optionalAccess', _208 => _208[layerId]]) : void 0;
|
|
4057
4057
|
}
|
|
4058
4058
|
/** The effect paper (without its pixels), or `null`. */
|
|
4059
4059
|
getPaperEffect() {
|
|
@@ -4181,10 +4181,10 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
4181
4181
|
const pixels = await this.renderEffectCanvas(d, values, options.time);
|
|
4182
4182
|
this.requireIdle("adding a layer");
|
|
4183
4183
|
const above = _nullishCoalesce(options.aboveId, () => ( this.doc.activeLayerId));
|
|
4184
|
-
const loc = above ?
|
|
4184
|
+
const loc = above ? _chunkB46UQUDCcjs.findLayer.call(void 0, this.doc.layers, above) : null;
|
|
4185
4185
|
if (options.aboveId !== void 0 && !loc) throw new PaintEditorError(`Layer "${options.aboveId}" was removed while the effect rendered.`);
|
|
4186
4186
|
const layer = { ...createPaintLayer(_optionalChain([options, 'access', _215 => _215.name, 'optionalAccess', _216 => _216.trim, 'call', _217 => _217()]) || d.name), surface: _chunk474IQG74cjs.surfaceFromPixels.call(void 0, pixels, 4), opacity: _nullishCoalesce(options.opacity, () => ( 1)), blend: _nullishCoalesce(options.blend, () => ( "normal")) };
|
|
4187
|
-
const layers =
|
|
4187
|
+
const layers = _chunkB46UQUDCcjs.insertLayer.call(void 0, this.doc.layers, layer, _nullishCoalesce(_optionalChain([loc, 'optionalAccess', _218 => _218.parent, 'optionalAccess', _219 => _219.id]), () => ( null)), loc ? loc.index + 1 : void 0);
|
|
4188
4188
|
const source = this.sourceOf(d, values, options.time);
|
|
4189
4189
|
this.commit("Add effect layer", { ...this.doc, layers, activeLayerId: layer.id, effectLayers: { ..._nullishCoalesce(this.doc.effectLayers, () => ( {})), [layer.id]: source } });
|
|
4190
4190
|
return { layer: this.describeLayer(layer), source };
|
|
@@ -4208,7 +4208,7 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
4208
4208
|
this.requireIdle("changing an effect layer");
|
|
4209
4209
|
if (!isPixelLayer(now)) throw new PaintEditorError(`Layer "${l.name}" was removed while the effect rendered.`);
|
|
4210
4210
|
const source = this.sourceOf(d, values, time);
|
|
4211
|
-
this.commitOrAmend("Effect layer", { ...this.doc, layers:
|
|
4211
|
+
this.commitOrAmend("Effect layer", { ...this.doc, layers: _chunkB46UQUDCcjs.mapLayer.call(void 0, this.doc.layers, l.id, () => ({ ...now, surface: _chunk474IQG74cjs.surfaceFromPixels.call(void 0, pixels, 4), offset: { x: 0, y: 0 } })), effectLayers: { ..._nullishCoalesce(this.doc.effectLayers, () => ( {})), [l.id]: source } }, commitToHistory);
|
|
4212
4212
|
return source;
|
|
4213
4213
|
}
|
|
4214
4214
|
/** Turns an effect layer into a plain pixel layer, keeping its pixels (one undo step). */
|
|
@@ -4236,9 +4236,9 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
4236
4236
|
const rect = this.canvasRectOf(now);
|
|
4237
4237
|
const before = _chunk474IQG74cjs.readRegion.call(void 0, now.surface, rect);
|
|
4238
4238
|
let after = overPixels(before, pixels.data, _nullishCoalesce(options.opacity, () => ( 1)));
|
|
4239
|
-
if (options.lockTransparency ||
|
|
4239
|
+
if (options.lockTransparency || _chunkB46UQUDCcjs.isLayerLocked.call(void 0, now, "transparency")) after = mixPixels(before, after, 1);
|
|
4240
4240
|
const surface = _chunk474IQG74cjs.writeRegion.call(void 0, now.surface, rect, after);
|
|
4241
|
-
this.commit("Effect fill", { ...this.doc, layers:
|
|
4241
|
+
this.commit("Effect fill", { ...this.doc, layers: _chunkB46UQUDCcjs.mapLayer.call(void 0, this.doc.layers, now.id, () => ({ ...now, surface })) });
|
|
4242
4242
|
return { layerId: now.id, source: this.sourceOf(d, values, options.time) };
|
|
4243
4243
|
}
|
|
4244
4244
|
/**
|
|
@@ -4275,7 +4275,7 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
4275
4275
|
const out = await this.effectsRenderer.render(this.effects.require(), d.id, { width: rect.width, height: rect.height }, { time: _nullishCoalesce(options.time, () => ( 0)), values, inputs });
|
|
4276
4276
|
const now = this.sameLayerAfterRender(l);
|
|
4277
4277
|
const surface = _chunk474IQG74cjs.writeRegion.call(void 0, now.surface, rect, mixPixels(before, out.data, amount));
|
|
4278
|
-
this.commit("Light effect", { ...this.doc, layers:
|
|
4278
|
+
this.commit("Light effect", { ...this.doc, layers: _chunkB46UQUDCcjs.mapLayer.call(void 0, this.doc.layers, now.id, () => ({ ...now, surface })) });
|
|
4279
4279
|
return { layerId: now.id, source: this.sourceOf(d, values, options.time), amount };
|
|
4280
4280
|
}
|
|
4281
4281
|
// --- Brushes -------------------------------------------------------------------
|
|
@@ -4514,11 +4514,11 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
4514
4514
|
let layer = (() => {
|
|
4515
4515
|
const id = _nullishCoalesce(init.layerId, () => ( doc.activeLayerId));
|
|
4516
4516
|
if (!id) throw new PaintEditorError("There is no active layer to paint on; add one with add_layer.");
|
|
4517
|
-
const loc =
|
|
4517
|
+
const loc = _chunkB46UQUDCcjs.findLayer.call(void 0, doc.layers, id);
|
|
4518
4518
|
if (!loc) throw new PaintEditorError(`Unknown layer "${id}". Call list_layers for the ids.`);
|
|
4519
4519
|
const l = loc.layer;
|
|
4520
4520
|
if (!isPixelLayer(l)) throw new PaintEditorError(`Layer "${l.name}" is a group; paint on a pixel layer inside it.`);
|
|
4521
|
-
if (
|
|
4521
|
+
if (_chunkB46UQUDCcjs.isLayerLocked.call(void 0, l, "pixels")) throw new PaintEditorError(`Layer "${l.name}" has its pixels locked; unlock it (update_layer locks) to paint on it.`);
|
|
4522
4522
|
if (!l.visible) throw new PaintEditorError(`Layer "${l.name}" is hidden; show it (update_layer visible true) to paint on it.`);
|
|
4523
4523
|
return l;
|
|
4524
4524
|
})();
|
|
@@ -4534,8 +4534,8 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
4534
4534
|
this.requireWetIdle("painting");
|
|
4535
4535
|
if (layer.offset.x || layer.offset.y) {
|
|
4536
4536
|
const moved = { ...layer, surface: _chunk474IQG74cjs.translateSurface.call(void 0, layer.surface, layer.offset.x, layer.offset.y), offset: { x: 0, y: 0 } };
|
|
4537
|
-
this.doc = { ...this.doc, layers:
|
|
4538
|
-
if (doc !== this.doc) doc = { ...doc, layers:
|
|
4537
|
+
this.doc = { ...this.doc, layers: _chunkB46UQUDCcjs.mapLayer.call(void 0, this.doc.layers, layer.id, () => moved) };
|
|
4538
|
+
if (doc !== this.doc) doc = { ...doc, layers: _chunkB46UQUDCcjs.mapLayer.call(void 0, doc.layers, layer.id, () => moved) };
|
|
4539
4539
|
layer = moved;
|
|
4540
4540
|
}
|
|
4541
4541
|
if (!this.wet.wetLayerIds().includes(layer.id) && this.wet.wetLayerIds().length >= _chunkKWNMBMKGcjs.MAX_WET_LANES) {
|
|
@@ -4568,7 +4568,7 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
4568
4568
|
wet = { driver, surface: () => world.display(id).surface };
|
|
4569
4569
|
} else if (this.wet.wetLayerIds().includes(layer.id)) {
|
|
4570
4570
|
this.dryLayersFirst([layer.id]);
|
|
4571
|
-
const dried =
|
|
4571
|
+
const dried = _chunkB46UQUDCcjs.findLayer.call(void 0, this.doc.layers, layer.id).layer;
|
|
4572
4572
|
layer = dried;
|
|
4573
4573
|
}
|
|
4574
4574
|
let color = init.color === void 0 ? this.color : parseColor(init.color);
|
|
@@ -4587,7 +4587,7 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
4587
4587
|
layerId: layer.id,
|
|
4588
4588
|
surface: layer.surface,
|
|
4589
4589
|
offset: layer.offset,
|
|
4590
|
-
lockTransparency:
|
|
4590
|
+
lockTransparency: _chunkB46UQUDCcjs.isLayerLocked.call(void 0, layer, "transparency"),
|
|
4591
4591
|
brush,
|
|
4592
4592
|
color: rgba,
|
|
4593
4593
|
background: rgbaOf(doc.paper.color),
|
|
@@ -4682,7 +4682,7 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
4682
4682
|
const thick = ch ? { ..._nullishCoalesce(this.doc.thick, () => ( {})), [l.id]: ch } : this.doc.thick;
|
|
4683
4683
|
const sprayed = s.stickers();
|
|
4684
4684
|
const stickers = sprayed ? { ..._nullishCoalesce(this.doc.stickers, () => ( {})), [l.id]: [..._nullishCoalesce(_optionalChain([this, 'access', _242 => _242.doc, 'access', _243 => _243.stickers, 'optionalAccess', _244 => _244[l.id]]), () => ( [])), ...sprayed] } : this.doc.stickers;
|
|
4685
|
-
this.commit(`${brush.name} stroke`, this.withWetEvents({ ...this.doc, layers:
|
|
4685
|
+
this.commit(`${brush.name} stroke`, this.withWetEvents({ ...this.doc, layers: _chunkB46UQUDCcjs.mapLayer.call(void 0, this.doc.layers, l.id, () => ({ ...l, surface })), strokes: [...this.doc.strokes, stroke], ...thick ? { thick } : {}, ...stickers ? { stickers } : {} }), wetStroke ? before : this.doc);
|
|
4686
4686
|
}
|
|
4687
4687
|
};
|
|
4688
4688
|
let session;
|
|
@@ -4710,13 +4710,13 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
4710
4710
|
if (cancelled || !surface) return;
|
|
4711
4711
|
const stroke = this.record(s);
|
|
4712
4712
|
s.result.strokeId = stroke.id;
|
|
4713
|
-
const l =
|
|
4713
|
+
const l = _chunkB46UQUDCcjs.findLayer.call(void 0, out.layers, s.layerId).layer;
|
|
4714
4714
|
const offset = s.init.wet ? { x: 0, y: 0 } : l.offset;
|
|
4715
4715
|
const ch = s.thickChannels();
|
|
4716
4716
|
const sprayed = s.stickers();
|
|
4717
4717
|
out = {
|
|
4718
4718
|
...out,
|
|
4719
|
-
layers:
|
|
4719
|
+
layers: _chunkB46UQUDCcjs.mapLayer.call(void 0, out.layers, l.id, () => ({ ...l, surface, offset })),
|
|
4720
4720
|
strokes: [...out.strokes, stroke],
|
|
4721
4721
|
...ch ? { thick: { ..._nullishCoalesce(out.thick, () => ( {})), [l.id]: ch } } : {},
|
|
4722
4722
|
...sprayed ? { stickers: { ..._nullishCoalesce(out.stickers, () => ( {})), [l.id]: [..._nullishCoalesce(_optionalChain([out, 'access', _245 => _245.stickers, 'optionalAccess', _246 => _246[l.id]]), () => ( [])), ...sprayed] } } : {}
|
|
@@ -4731,8 +4731,8 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
4731
4731
|
if (this.wet.instantDry && result.strokeId) {
|
|
4732
4732
|
this.wet.dry(session.layerId);
|
|
4733
4733
|
this.logWet({ kind: "dry", layerId: session.layerId, at: out.strokes.length });
|
|
4734
|
-
const dried =
|
|
4735
|
-
out = { ...out, layers:
|
|
4734
|
+
const dried = _chunkB46UQUDCcjs.findLayer.call(void 0, this.doc.layers, session.layerId).layer.surface;
|
|
4735
|
+
out = { ...out, layers: _chunkB46UQUDCcjs.mapLayer.call(void 0, out.layers, session.layerId, (l) => ({ ...l, surface: dried })) };
|
|
4736
4736
|
}
|
|
4737
4737
|
result.wet = this.wet.isWet(session.layerId);
|
|
4738
4738
|
}
|
|
@@ -4810,7 +4810,7 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
4810
4810
|
brush = _chunkROVK6AXXcjs.normalizePaintBrush.call(void 0, { tip: { ...b.tip, size: b.tip.size * (v.brush.tip.size / s.brush.tip.size) } }, b);
|
|
4811
4811
|
}
|
|
4812
4812
|
const layerId = _nullishCoalesce(options.layerId, () => ( s.layerId));
|
|
4813
|
-
if (!
|
|
4813
|
+
if (!_chunkB46UQUDCcjs.findLayer.call(void 0, doc.layers, layerId)) throw new PaintEditorError(`Stroke "${s.id}" was painted on layer "${layerId}", which no longer exists; pass layerId to replay it elsewhere.`);
|
|
4814
4814
|
let load = s.load;
|
|
4815
4815
|
if (load && options.color !== void 0 && load.reservoir) {
|
|
4816
4816
|
const [r, g, b] = _chunkROVK6AXXcjs.hexToRgb8.call(void 0, options.color);
|
|
@@ -5027,7 +5027,7 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
5027
5027
|
wetPaper(options = {}) {
|
|
5028
5028
|
this.requireIdle("wetting the paper");
|
|
5029
5029
|
const l = this.wetLayer(options.layerId, "wet the paper of");
|
|
5030
|
-
if (
|
|
5030
|
+
if (_chunkB46UQUDCcjs.isLayerLocked.call(void 0, l, "pixels")) throw new PaintEditorError(`Layer "${l.name}" has its pixels locked; unlock it first.`);
|
|
5031
5031
|
const amount = _nullishCoalesce(options.amount, () => ( 1));
|
|
5032
5032
|
if (!(amount > 0 && amount <= 1)) throw new PaintEditorError(`amount ${amount} is out of range; use above 0 up to 1.`);
|
|
5033
5033
|
const rect = _nullishCoalesce(this.checkRect(options.rect), () => ( { x: 0, y: 0, width: this.doc.canvas.width, height: this.doc.canvas.height }));
|
|
@@ -5111,7 +5111,7 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
5111
5111
|
const live = this.live;
|
|
5112
5112
|
if (!live) return this.doc.layers;
|
|
5113
5113
|
if (_optionalChain([this, 'access', _256 => _256.liveLayers, 'optionalAccess', _257 => _257.key]) === live.surface) return this.liveLayers.layers;
|
|
5114
|
-
const layers =
|
|
5114
|
+
const layers = _chunkB46UQUDCcjs.mapLayer.call(void 0, this.doc.layers, live.layerId, (l) => ({ ...l, surface: live.surface }));
|
|
5115
5115
|
this.liveLayers = { key: live.surface, layers };
|
|
5116
5116
|
return layers;
|
|
5117
5117
|
}
|
|
@@ -5148,7 +5148,7 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
5148
5148
|
let out = layers;
|
|
5149
5149
|
for (const id of ids) {
|
|
5150
5150
|
const baked = this.wet.bakedSurface(id);
|
|
5151
|
-
if (baked &&
|
|
5151
|
+
if (baked && _chunkB46UQUDCcjs.findLayer.call(void 0, out, id)) out = _chunkB46UQUDCcjs.mapLayer.call(void 0, out, id, (l) => ({ ...l, surface: baked }));
|
|
5152
5152
|
}
|
|
5153
5153
|
return out;
|
|
5154
5154
|
}
|
|
@@ -5161,12 +5161,12 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
5161
5161
|
const ids = /* @__PURE__ */ new Set([...Object.keys(_nullishCoalesce(thick, () => ( {}))), ...live ? [live.layerId] : []]);
|
|
5162
5162
|
for (const id of ids) {
|
|
5163
5163
|
const ch = _optionalChain([live, 'optionalAccess', _260 => _260.layerId]) === id ? live.channels : _optionalChain([thick, 'optionalAccess', _261 => _261[id]]);
|
|
5164
|
-
const l = ch && _optionalChain([
|
|
5164
|
+
const l = ch && _optionalChain([_chunkB46UQUDCcjs.findLayer.call(void 0, out, id), 'optionalAccess', _262 => _262.layer]);
|
|
5165
5165
|
if (!ch || !isPixelLayer(l)) continue;
|
|
5166
5166
|
let cache = this.litCaches.get(id);
|
|
5167
5167
|
if (!cache) this.litCaches.set(id, cache = new LitCache());
|
|
5168
5168
|
const lit = cache.lit(l.surface, ch, this.lighting);
|
|
5169
|
-
if (lit !== l.surface) out =
|
|
5169
|
+
if (lit !== l.surface) out = _chunkB46UQUDCcjs.mapLayer.call(void 0, out, id, () => ({ ...l, surface: lit }));
|
|
5170
5170
|
}
|
|
5171
5171
|
return out;
|
|
5172
5172
|
}
|
|
@@ -5174,7 +5174,7 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
5174
5174
|
let layers = this.litLayers((_nullishCoalesce(options.wet, () => ( "display"))) === "dried" ? this.driedLayers() : this.currentLayers());
|
|
5175
5175
|
if (options.layerIds) {
|
|
5176
5176
|
const picked = [];
|
|
5177
|
-
for (const id of options.layerIds) picked.push(_nullishCoalesce(_optionalChain([
|
|
5177
|
+
for (const id of options.layerIds) picked.push(_nullishCoalesce(_optionalChain([_chunkB46UQUDCcjs.findLayer.call(void 0, layers, id), 'optionalAccess', _263 => _263.layer]), () => ( this.requireLayer(id))));
|
|
5178
5178
|
layers = picked.map((l) => ({ ...l, visible: true }));
|
|
5179
5179
|
}
|
|
5180
5180
|
const under = options.paper === false ? [] : [paperNode(this.doc.paper, this.lighting)];
|
|
@@ -5218,7 +5218,7 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
5218
5218
|
/** Wet settings saved with the document (`null` when they are all defaults). */
|
|
5219
5219
|
wetJSON() {
|
|
5220
5220
|
const layers = {};
|
|
5221
|
-
for (const [id, set] of this.wet.settings) if (
|
|
5221
|
+
for (const [id, set] of this.wet.settings) if (_chunkB46UQUDCcjs.findLayer.call(void 0, this.doc.layers, id)) layers[id] = { params: { ...set.params }, flow: { ...set.flow } };
|
|
5222
5222
|
const flat = this.wet.tilt.angle === 0;
|
|
5223
5223
|
if (!Object.keys(layers).length && flat) return void 0;
|
|
5224
5224
|
return { tilt: { ...this.wet.tilt }, layers };
|
|
@@ -5244,17 +5244,17 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
5244
5244
|
const ext = { ...this.extensions };
|
|
5245
5245
|
const channels = {};
|
|
5246
5246
|
for (const [id, ch] of Object.entries(_nullishCoalesce(this.doc.thick, () => ( {})))) {
|
|
5247
|
-
if (!
|
|
5247
|
+
if (!_chunkB46UQUDCcjs.findLayer.call(void 0, this.doc.layers, id)) continue;
|
|
5248
5248
|
const saved = thickToJSON(ch);
|
|
5249
5249
|
if (saved) channels[id] = saved;
|
|
5250
5250
|
}
|
|
5251
5251
|
if (Object.keys(channels).length) ext.layerChannels = channels;
|
|
5252
5252
|
else delete ext.layerChannels;
|
|
5253
5253
|
const stickers = {};
|
|
5254
|
-
for (const [id, list] of Object.entries(_nullishCoalesce(this.doc.stickers, () => ( {})))) if (list.length &&
|
|
5254
|
+
for (const [id, list] of Object.entries(_nullishCoalesce(this.doc.stickers, () => ( {})))) if (list.length && _chunkB46UQUDCcjs.findLayer.call(void 0, this.doc.layers, id)) stickers[id] = list.map((x) => ({ ...x }));
|
|
5255
5255
|
if (Object.keys(stickers).length) ext.stickers = stickers;
|
|
5256
5256
|
else delete ext.stickers;
|
|
5257
|
-
const effectLayers = effectLayersToJSON(_nullishCoalesce(this.doc.effectLayers, () => ( {})), (id) => isPixelLayer(_optionalChain([
|
|
5257
|
+
const effectLayers = effectLayersToJSON(_nullishCoalesce(this.doc.effectLayers, () => ( {})), (id) => isPixelLayer(_optionalChain([_chunkB46UQUDCcjs.findLayer.call(void 0, this.doc.layers, id), 'optionalAccess', _266 => _266.layer])));
|
|
5258
5258
|
if (effectLayers) ext.effectLayers = effectLayers;
|
|
5259
5259
|
else delete ext.effectLayers;
|
|
5260
5260
|
if (this.doc.paperEffect) ext.paperEffect = paperEffectToJSON(this.doc.paperEffect);
|
|
@@ -5270,7 +5270,7 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
5270
5270
|
if (ext.stickers && typeof ext.stickers === "object") {
|
|
5271
5271
|
const stickers = {};
|
|
5272
5272
|
for (const [id, list] of Object.entries(ext.stickers)) {
|
|
5273
|
-
if (!
|
|
5273
|
+
if (!_chunkB46UQUDCcjs.findLayer.call(void 0, state.layers, id) || !Array.isArray(list)) continue;
|
|
5274
5274
|
const ok = list.filter((x) => x && typeof x.id === "string" && _chunkROVK6AXXcjs.STAMP_KINDS.includes(x.stamp) && Number.isFinite(x.x) && Number.isFinite(x.y) && x.size > 0);
|
|
5275
5275
|
if (ok.length !== list.length) problems.push(`Some stickers of layer "${id}" could not be read; they were dropped.`);
|
|
5276
5276
|
stickers[id] = ok.map((x) => ({ ...x }));
|
|
@@ -5280,7 +5280,7 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
5280
5280
|
if (ext.effectLayers && typeof ext.effectLayers === "object") {
|
|
5281
5281
|
const effectLayers = {};
|
|
5282
5282
|
for (const [id, v] of Object.entries(ext.effectLayers)) {
|
|
5283
|
-
if (!isPixelLayer(_optionalChain([
|
|
5283
|
+
if (!isPixelLayer(_optionalChain([_chunkB46UQUDCcjs.findLayer.call(void 0, state.layers, id), 'optionalAccess', _267 => _267.layer]))) continue;
|
|
5284
5284
|
const source = readPaintEffectSource(v);
|
|
5285
5285
|
if (source) effectLayers[id] = source;
|
|
5286
5286
|
else problems.push(`The effect of layer "${id}" could not be read; it loads as a plain layer.`);
|
|
@@ -5298,7 +5298,7 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
5298
5298
|
if (!raw || typeof raw !== "object") return state;
|
|
5299
5299
|
const thick = {};
|
|
5300
5300
|
for (const [id, v] of Object.entries(raw)) {
|
|
5301
|
-
if (!
|
|
5301
|
+
if (!_chunkB46UQUDCcjs.findLayer.call(void 0, state.layers, id)) continue;
|
|
5302
5302
|
try {
|
|
5303
5303
|
thick[id] = thickFromJSON(v);
|
|
5304
5304
|
} catch (e) {
|
|
@@ -5413,7 +5413,7 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
5413
5413
|
return next.type === "group" ? { ...next, children: toStandard(next.children) } : next;
|
|
5414
5414
|
});
|
|
5415
5415
|
const layers = toStandard(dried);
|
|
5416
|
-
const result =
|
|
5416
|
+
const result = _chunkS55JFWDAcjs.exportPsd.call(void 0, { width, height, layers: [paperLayer, ...layers], merged, resolution: dpi });
|
|
5417
5417
|
for (const [mode, names] of changed) {
|
|
5418
5418
|
const label = _nullishCoalesce(_optionalChain([_chunkOLNIPTB3cjs.BLEND_MODES, 'access', _271 => _271.find, 'call', _272 => _272((m) => m.id === mode), 'optionalAccess', _273 => _273.label]), () => ( mode));
|
|
5419
5419
|
const std = _nullishCoalesce(_optionalChain([_chunkOLNIPTB3cjs.BLEND_MODES, 'access', _274 => _274.find, 'call', _275 => _275((m) => m.id === _chunkOLNIPTB3cjs.standardBlendMode.call(void 0, mode)), 'optionalAccess', _276 => _276.label]), () => ( _chunkOLNIPTB3cjs.standardBlendMode.call(void 0, mode)));
|
|
@@ -5663,9 +5663,9 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
5663
5663
|
}
|
|
5664
5664
|
/** Replaces a layer's stickers and redraws its pixels from them (one undo step). */
|
|
5665
5665
|
commitStickers(label, layer, stickers) {
|
|
5666
|
-
if (
|
|
5666
|
+
if (_chunkB46UQUDCcjs.isLayerLocked.call(void 0, layer, "pixels")) throw new PaintEditorError(`Layer "${layer.name}" has its pixels locked; unlock it first.`);
|
|
5667
5667
|
const surface = _chunkROVK6AXXcjs.stickerSurface.call(void 0, stickers);
|
|
5668
|
-
const doc = { ...this.doc, layers:
|
|
5668
|
+
const doc = { ...this.doc, layers: _chunkB46UQUDCcjs.mapLayer.call(void 0, this.doc.layers, layer.id, () => ({ ...layer, surface, offset: { x: 0, y: 0 } })), stickers: { ..._nullishCoalesce(this.doc.stickers, () => ( {})), [layer.id]: stickers } };
|
|
5669
5669
|
this.commit(label, this.withPaintEvent(doc, { kind: "stickers", layerId: layer.id, data: { stickers: stickers.map((s) => ({ ...s })) } }));
|
|
5670
5670
|
}
|
|
5671
5671
|
/** Moves, turns, resizes, recolours or restamps one sticker (one undo step). Returns it. */
|
|
@@ -5918,7 +5918,7 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
5918
5918
|
}
|
|
5919
5919
|
/** A layer's tile surface (live while stroking), for thumbnails. */
|
|
5920
5920
|
layerSurface(id) {
|
|
5921
|
-
const l = _optionalChain([
|
|
5921
|
+
const l = _optionalChain([_chunkB46UQUDCcjs.findLayer.call(void 0, this.currentLayers(), id), 'optionalAccess', _299 => _299.layer]);
|
|
5922
5922
|
return isPixelLayer(l) ? l.surface : null;
|
|
5923
5923
|
}
|
|
5924
5924
|
}, _class10);
|
|
@@ -5928,7 +5928,7 @@ var moveRect = (r, dx, dy) => ({ ...r, x: r.x + dx, y: r.y + dy });
|
|
|
5928
5928
|
function shiftDocument(doc, dx, dy) {
|
|
5929
5929
|
if (!dx && !dy) return doc;
|
|
5930
5930
|
let layers = doc.layers;
|
|
5931
|
-
for (const l of
|
|
5931
|
+
for (const l of _chunkB46UQUDCcjs.flattenLayers.call(void 0, doc.layers)) if (l.type === "pixel") layers = _chunkB46UQUDCcjs.mapLayer.call(void 0, layers, l.id, () => ({ ...l, offset: movePoint(l.offset, dx, dy) }));
|
|
5932
5932
|
const m = [1, 0, 0, 1, dx, dy];
|
|
5933
5933
|
const moveStickers = (list) => list.map((s) => ({ ...s, x: Math.round((s.x + dx) * 100) / 100, y: Math.round((s.y + dy) * 100) / 100 }));
|
|
5934
5934
|
const out = {
|
|
@@ -7,9 +7,9 @@ import {
|
|
|
7
7
|
resolveExternalAssets,
|
|
8
8
|
serializeLayers,
|
|
9
9
|
serializeLayersExternal
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-F7Z2MKY2.js";
|
|
11
11
|
import "../chunk-3CI7FRMK.js";
|
|
12
|
-
import "../chunk-
|
|
12
|
+
import "../chunk-ZNA3IQZF.js";
|
|
13
13
|
import {
|
|
14
14
|
EffectRendererPool
|
|
15
15
|
} from "../chunk-EHLOCVWB.js";
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
insertLayer,
|
|
21
21
|
isLayerLocked,
|
|
22
22
|
mapLayer
|
|
23
|
-
} from "../chunk-
|
|
23
|
+
} from "../chunk-QXY4YTRI.js";
|
|
24
24
|
import "../chunk-OHKOFKBY.js";
|
|
25
25
|
import "../chunk-ZIF4UJJ6.js";
|
|
26
26
|
import {
|
|
@@ -29,7 +29,7 @@ import { type BlendMode } from './blend.cjs';
|
|
|
29
29
|
import { type GlobalLight, type LayerEffects } from './effects/model.cjs';
|
|
30
30
|
import { type EffectPattern } from './effects/patterns.cjs';
|
|
31
31
|
import { type EffectCompositeInput } from './effects/render.cjs';
|
|
32
|
-
import type { RasterMask, RasterNode } from './layers.cjs';
|
|
32
|
+
import type { RasterMask, RasterNode, LayerEdgeColor } from './layers.cjs';
|
|
33
33
|
import { type PixelSurface, type RasterRect, type TileKey, type TiledSurface } from './surface.cjs';
|
|
34
34
|
/** What the compositor needs from its host besides the layers. */
|
|
35
35
|
export interface RasterSources {
|
|
@@ -61,9 +61,18 @@ export interface CompositorLayer extends RasterNode {
|
|
|
61
61
|
fillOpacity?: number;
|
|
62
62
|
/** Layer effects. */
|
|
63
63
|
effects?: LayerEffects;
|
|
64
|
+
/** Edge colour; the engine applies `ambient` (the profile's pixel filters handle the rest). */
|
|
65
|
+
edge?: LayerEdgeColor;
|
|
64
66
|
/** Groups. */
|
|
65
67
|
children?: readonly CompositorLayer[];
|
|
66
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* Live edge cast (`LayerEdgeColor.ambient`): pulls straight RGBA `content` toward `below` (the
|
|
71
|
+
* composite behind it, same size) or a fixed colour, by `amount × (1 − α)` where α is the content's
|
|
72
|
+
* alpha times `coverage` (its mask). Opaque and invisible pixels are unchanged. `max` is 255 for
|
|
73
|
+
* bytes or 1 for float samples; `color` is in the same units.
|
|
74
|
+
*/
|
|
75
|
+
export declare function applyEdgeAmbient(content: Uint8ClampedArray | Float32Array, below: ArrayLike<number>, coverage: ArrayLike<number> | null, amount: number, color: readonly [number, number, number] | null, max: number): void;
|
|
67
76
|
/** A pixel layer's filters as the engine runs them. */
|
|
68
77
|
export interface PixelFilterSpec {
|
|
69
78
|
/** Identifies the settings (part of the cache key). */
|