@pixerate/editor 0.105.0 → 0.107.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-DS7KDKPX.js → chunk-3PHA3UKI.js} +2 -2
- package/dist/{chunk-ZID226ZG.cjs → chunk-FRD3FUXI.cjs} +172 -172
- package/dist/{chunk-ZID226ZG.cjs.map → chunk-FRD3FUXI.cjs.map} +1 -1
- package/dist/{chunk-67FRIOPZ.js → chunk-G4BIYE6R.js} +2 -2
- package/dist/{chunk-PV42JITT.cjs → chunk-HUFQD4CB.cjs} +44 -44
- package/dist/{chunk-PV42JITT.cjs.map → chunk-HUFQD4CB.cjs.map} +1 -1
- package/dist/{chunk-4X5MIVCE.js → chunk-SOROZ2BF.js} +3 -3
- package/dist/{chunk-CRMAXIUV.cjs → chunk-SZ6KMZNM.cjs} +157 -8
- package/dist/chunk-SZ6KMZNM.cjs.map +1 -0
- package/dist/{chunk-WSTEXEKD.cjs → chunk-T3QZ6S47.cjs} +92 -92
- package/dist/{chunk-WSTEXEKD.cjs.map → chunk-T3QZ6S47.cjs.map} +1 -1
- package/dist/{chunk-HEW6KDNI.js → chunk-WMBIJCHA.js} +155 -6
- package/dist/chunk-WMBIJCHA.js.map +1 -0
- package/dist/{compositor-Bc3PNP3C.d.cts → compositor-D92URMlm.d.cts} +1 -1
- package/dist/{compositor-BsYYllvR.d.ts → compositor-Kt_M4ruo.d.ts} +1 -1
- package/dist/{export-_m3Es4ru.d.cts → export-JGWQEPJn.d.cts} +3 -3
- package/dist/{export-iMrop3Jm.d.ts → export-a9bnF7Cl.d.ts} +3 -3
- package/dist/image-editor/index.cjs +831 -632
- package/dist/image-editor/index.cjs.map +1 -1
- package/dist/image-editor/index.d.cts +42 -9
- package/dist/image-editor/index.d.ts +42 -9
- package/dist/image-editor/index.js +203 -4
- package/dist/image-editor/index.js.map +1 -1
- package/dist/{mixer-C1M1Nua_.d.cts → mixer-5ziHU8OS.d.cts} +1 -1
- package/dist/{mixer-Cu5a9Bzd.d.ts → mixer-DNqiYXYQ.d.ts} +1 -1
- package/dist/paint/index.cjs +3 -3
- package/dist/paint/index.d.cts +2 -2
- package/dist/paint/index.d.ts +2 -2
- package/dist/paint/index.js +2 -2
- package/dist/paint-editor/index.cjs +175 -127
- package/dist/paint-editor/index.cjs.map +1 -1
- package/dist/paint-editor/index.d.cts +18 -7
- package/dist/paint-editor/index.d.ts +18 -7
- package/dist/paint-editor/index.js +59 -11
- package/dist/paint-editor/index.js.map +1 -1
- package/dist/raster/index.cjs +11 -3
- package/dist/raster/index.cjs.map +1 -1
- package/dist/raster/index.d.cts +4 -4
- package/dist/raster/index.d.ts +4 -4
- package/dist/raster/index.js +10 -2
- package/dist/{surface-BBJN9wxg.d.ts → surface-CkKOHGPm.d.cts} +20 -2
- package/dist/{surface-BBJN9wxg.d.cts → surface-CkKOHGPm.d.ts} +20 -2
- package/package.json +1 -1
- package/skills/pixerate-paint-editor/SKILL.md +21 -1
- package/dist/chunk-CRMAXIUV.cjs.map +0 -1
- package/dist/chunk-HEW6KDNI.js.map +0 -1
- /package/dist/{chunk-DS7KDKPX.js.map → chunk-3PHA3UKI.js.map} +0 -0
- /package/dist/{chunk-67FRIOPZ.js.map → chunk-G4BIYE6R.js.map} +0 -0
- /package/dist/{chunk-4X5MIVCE.js.map → chunk-SOROZ2BF.js.map} +0 -0
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkFRD3FUXIcjs = require('../chunk-FRD3FUXI.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
@@ -17,7 +17,7 @@ var _chunkZID226ZGcjs = require('../chunk-ZID226ZG.cjs');
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
var
|
|
20
|
+
var _chunkT3QZ6S47cjs = require('../chunk-T3QZ6S47.cjs');
|
|
21
21
|
require('../chunk-MUUXNRU4.cjs');
|
|
22
22
|
|
|
23
23
|
|
|
@@ -35,7 +35,7 @@ require('../chunk-MUUXNRU4.cjs');
|
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
|
|
38
|
-
var
|
|
38
|
+
var _chunkHUFQD4CBcjs = require('../chunk-HUFQD4CB.cjs');
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
|
|
@@ -50,7 +50,10 @@ var _chunkPV42JITTcjs = require('../chunk-PV42JITT.cjs');
|
|
|
50
50
|
|
|
51
51
|
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
var _chunkSZ6KMZNMcjs = require('../chunk-SZ6KMZNM.cjs');
|
|
54
57
|
require('../chunk-DWGZUSES.cjs');
|
|
55
58
|
|
|
56
59
|
// src/paint-editor/noise.ts
|
|
@@ -400,7 +403,7 @@ function newPaintLayerId() {
|
|
|
400
403
|
return `pl${Date.now().toString(36)}${(nextId++).toString(36)}`;
|
|
401
404
|
}
|
|
402
405
|
function createPaintLayer(name, id = newPaintLayerId()) {
|
|
403
|
-
return { type: "pixel", id, name, visible: true, opacity: 1, blend: "normal", surface:
|
|
406
|
+
return { type: "pixel", id, name, visible: true, opacity: 1, blend: "normal", surface: _chunkSZ6KMZNMcjs.emptySurface.call(void 0, 4), offset: { x: 0, y: 0 } };
|
|
404
407
|
}
|
|
405
408
|
var PaintDocumentError = class extends Error {
|
|
406
409
|
constructor(message) {
|
|
@@ -468,12 +471,12 @@ function normalizePaintBrush(raw = {}, base) {
|
|
|
468
471
|
name: typeof raw.name === "string" && raw.name.trim() ? raw.name.trim().slice(0, 80) : b.name,
|
|
469
472
|
category: PAINT_BRUSH_CATEGORIES.includes(raw.category) ? raw.category : b.category,
|
|
470
473
|
engine: PAINT_BRUSH_ENGINES.includes(raw.engine) ? raw.engine : b.engine,
|
|
471
|
-
tip:
|
|
474
|
+
tip: _chunkHUFQD4CBcjs.normalizeBrush.call(void 0, { ...b.tip, ..._nullishCoalesce(raw.tip, () => ( {})) }),
|
|
472
475
|
grain: unit2(raw.grain, b.grain),
|
|
473
476
|
pressureSmoothing: range(raw.pressureSmoothing, 0, 0.95, b.pressureSmoothing),
|
|
474
477
|
rotation: BRUSH_ROTATIONS.includes(raw.rotation) ? raw.rotation : b.rotation,
|
|
475
478
|
dynamics: normalizeDynamics(_nullishCoalesce(raw.dynamics, () => ( {})), b.dynamics),
|
|
476
|
-
mixer:
|
|
479
|
+
mixer: _chunkHUFQD4CBcjs.normalizeMixer.call(void 0, { ...b.mixer, ..._nullishCoalesce(raw.mixer, () => ( {})) }),
|
|
477
480
|
loadsColor: typeof raw.loadsColor === "boolean" ? raw.loadsColor : b.loadsColor,
|
|
478
481
|
...raw.builtin ? { builtin: true } : {}
|
|
479
482
|
};
|
|
@@ -483,12 +486,12 @@ var BASE_BRUSH = {
|
|
|
483
486
|
name: "Round",
|
|
484
487
|
category: "custom",
|
|
485
488
|
engine: "dab",
|
|
486
|
-
tip: { ...
|
|
489
|
+
tip: { ..._chunkHUFQD4CBcjs.DEFAULT_BRUSH },
|
|
487
490
|
grain: 0,
|
|
488
491
|
pressureSmoothing: 0,
|
|
489
492
|
rotation: "fixed",
|
|
490
493
|
dynamics: { ...DEFAULT_DYNAMICS },
|
|
491
|
-
mixer: { ...
|
|
494
|
+
mixer: { ..._chunkHUFQD4CBcjs.DEFAULT_MIXER },
|
|
492
495
|
loadsColor: true
|
|
493
496
|
};
|
|
494
497
|
var builtin = (init) => ({ ...normalizePaintBrush(init), builtin: true });
|
|
@@ -865,7 +868,7 @@ var DryStroke = (_class5 = class {
|
|
|
865
868
|
}
|
|
866
869
|
|
|
867
870
|
|
|
868
|
-
__init12() {this.coverage = new (0,
|
|
871
|
+
__init12() {this.coverage = new (0, _chunkHUFQD4CBcjs.CoverageMap)()}
|
|
869
872
|
__init13() {this.dabCount = 0}
|
|
870
873
|
|
|
871
874
|
|
|
@@ -899,11 +902,11 @@ var DryStroke = (_class5 = class {
|
|
|
899
902
|
const hardness = this.brush.tip.hardness;
|
|
900
903
|
const grain = this.options.grain;
|
|
901
904
|
for (const d of dabs) {
|
|
902
|
-
const rect =
|
|
905
|
+
const rect = _chunkHUFQD4CBcjs.dabRect.call(void 0, d, hardness);
|
|
903
906
|
const n = rect.width * rect.height;
|
|
904
907
|
if (this.buf.length < n) this.buf = new Float32Array(n);
|
|
905
908
|
const vals = this.buf.subarray(0, n);
|
|
906
|
-
|
|
909
|
+
_chunkHUFQD4CBcjs.rasterizeDab.call(void 0, d, hardness, rect, vals);
|
|
907
910
|
if (this.depth > 0 && grain) {
|
|
908
911
|
for (let yy = 0, k = 0; yy < rect.height; yy++) {
|
|
909
912
|
const y = rect.y + yy + 0.5;
|
|
@@ -928,7 +931,7 @@ function toStrokePoint(p) {
|
|
|
928
931
|
|
|
929
932
|
// src/paint-editor/stroke.ts
|
|
930
933
|
function defaultTile(surface) {
|
|
931
|
-
const data = new Uint8ClampedArray(
|
|
934
|
+
const data = new Uint8ClampedArray(_chunkSZ6KMZNMcjs.TILE * _chunkSZ6KMZNMcjs.TILE * surface.channels);
|
|
932
935
|
if (surface.defaultValue) data.fill(surface.defaultValue);
|
|
933
936
|
return data;
|
|
934
937
|
}
|
|
@@ -967,7 +970,7 @@ var PaintStrokeSession = (_class6 = class {
|
|
|
967
970
|
if (brush.engine === "mixer") {
|
|
968
971
|
this.mixerSmoother = new PenSmoother(brush.tip.smoothing, brush.pressureSmoothing);
|
|
969
972
|
const load = init.mixerLoad;
|
|
970
|
-
for (let i = 0; i < this.copies.length; i++) this.mixers.push(new (0,
|
|
973
|
+
for (let i = 0; i < this.copies.length; i++) this.mixers.push(new (0, _chunkHUFQD4CBcjs.MixerStroke)(mixerTip(brush), brush.mixer, load, this.mixerTarget()));
|
|
971
974
|
} else {
|
|
972
975
|
this.dry = new DryStroke(brush, { grain: init.grain, paperDepth: init.paperDepth, seed: init.seed, copies: this.copies });
|
|
973
976
|
}
|
|
@@ -995,9 +998,9 @@ var PaintStrokeSession = (_class6 = class {
|
|
|
995
998
|
offset: this.init.offset,
|
|
996
999
|
lockTransparency: this.init.lockTransparency,
|
|
997
1000
|
selection: null,
|
|
998
|
-
readTile: (tx, ty) => _nullishCoalesce(_optionalChain([this, 'access', _4 => _4.live, 'access', _5 => _5.get, 'call', _6 => _6(
|
|
1001
|
+
readTile: (tx, ty) => _nullishCoalesce(_optionalChain([this, 'access', _4 => _4.live, 'access', _5 => _5.get, 'call', _6 => _6(_chunkSZ6KMZNMcjs.tileKey.call(void 0, tx, ty)), 'optionalAccess', _7 => _7.data]), () => ( null)),
|
|
999
1002
|
writeTile: (tx, ty) => {
|
|
1000
|
-
const key =
|
|
1003
|
+
const key = _chunkSZ6KMZNMcjs.tileKey.call(void 0, tx, ty);
|
|
1001
1004
|
if (!this.touched.has(key)) {
|
|
1002
1005
|
const src = _nullishCoalesce(_optionalChain([this, 'access', _8 => _8.base, 'access', _9 => _9.tiles, 'access', _10 => _10.get, 'call', _11 => _11(key), 'optionalAccess', _12 => _12.data]), () => ( defaultTile(this.base)));
|
|
1003
1006
|
this.live.set(key, { data: new Uint8ClampedArray(src), uniform: null });
|
|
@@ -1035,14 +1038,14 @@ var PaintStrokeSession = (_class6 = class {
|
|
|
1035
1038
|
if (!this.dry) {
|
|
1036
1039
|
for (const key of this.fresh) this.live.set(key, { data: this.live.get(key).data, uniform: null });
|
|
1037
1040
|
this.fresh.clear();
|
|
1038
|
-
this.host.update(this.layerId, new (0,
|
|
1041
|
+
this.host.update(this.layerId, new (0, _chunkSZ6KMZNMcjs.TiledSurface)(ch, new Map(this.live), this.base.defaultValue), rects);
|
|
1039
1042
|
return;
|
|
1040
1043
|
}
|
|
1041
1044
|
const off = this.init.offset;
|
|
1042
1045
|
const regions = /* @__PURE__ */ new Map();
|
|
1043
1046
|
for (const r of rects) {
|
|
1044
|
-
for (const t of
|
|
1045
|
-
const key =
|
|
1047
|
+
for (const t of _chunkSZ6KMZNMcjs.tilesInRect.call(void 0, { x: r.x - off.x, y: r.y - off.y, width: r.width, height: r.height })) {
|
|
1048
|
+
const key = _chunkSZ6KMZNMcjs.tileKey.call(void 0, t.tx, t.ty);
|
|
1046
1049
|
const cur = regions.get(key);
|
|
1047
1050
|
regions.set(key, { tx: t.tx, ty: t.ty, r: cur ? union(cur.r, r) : r });
|
|
1048
1051
|
}
|
|
@@ -1051,10 +1054,10 @@ var PaintStrokeSession = (_class6 = class {
|
|
|
1051
1054
|
const src = _nullishCoalesce(_optionalChain([this, 'access', _13 => _13.base, 'access', _14 => _14.tiles, 'access', _15 => _15.get, 'call', _16 => _16(key), 'optionalAccess', _17 => _17.data]), () => ( defaultTile(this.base)));
|
|
1052
1055
|
const prev = this.touched.has(key) ? _optionalChain([this, 'access', _18 => _18.live, 'access', _19 => _19.get, 'call', _20 => _20(key), 'optionalAccess', _21 => _21.data]) : void 0;
|
|
1053
1056
|
this.touched.add(key);
|
|
1054
|
-
const data =
|
|
1057
|
+
const data = _chunkHUFQD4CBcjs.applyStrokeToTile.call(void 0, this.dry.coverage, src, ch, tx, ty, this.apply, prev ? { into: prev, region: r } : {});
|
|
1055
1058
|
this.live.set(key, { data, uniform: null });
|
|
1056
1059
|
}
|
|
1057
|
-
this.host.update(this.layerId, new (0,
|
|
1060
|
+
this.host.update(this.layerId, new (0, _chunkSZ6KMZNMcjs.TiledSurface)(ch, new Map(this.live), this.base.defaultValue), rects);
|
|
1058
1061
|
}
|
|
1059
1062
|
/** Ends the stroke (one undo step) and returns what changed. */
|
|
1060
1063
|
end() {
|
|
@@ -1071,19 +1074,19 @@ var PaintStrokeSession = (_class6 = class {
|
|
|
1071
1074
|
const tiles = new Map(this.base.tiles);
|
|
1072
1075
|
let changed = false;
|
|
1073
1076
|
for (const key of this.touched) {
|
|
1074
|
-
const tile =
|
|
1077
|
+
const tile = _chunkSZ6KMZNMcjs.finishTile.call(void 0, this.live.get(key).data, ch, this.base.defaultValue);
|
|
1075
1078
|
const prev = this.base.tiles.get(key);
|
|
1076
1079
|
if (tile) tiles.set(key, tile);
|
|
1077
1080
|
else tiles.delete(key);
|
|
1078
1081
|
if (!sameTile(prev, tile)) changed = true;
|
|
1079
1082
|
}
|
|
1080
|
-
const surface = changed ? new (0,
|
|
1083
|
+
const surface = changed ? new (0, _chunkSZ6KMZNMcjs.TiledSurface)(ch, tiles, this.base.defaultValue) : null;
|
|
1081
1084
|
const dabs = this.dry ? this.dry.dabCount : this.mixers.reduce((n, m) => n + m.dabCount, 0);
|
|
1082
1085
|
this.result = { layerId: this.layerId, bounds: changed ? this.bounds : null, dabs, strokeId: null };
|
|
1083
1086
|
if (this.mixers.length) {
|
|
1084
1087
|
const brush = this.init.brush;
|
|
1085
1088
|
let load = this.mixers[0].load;
|
|
1086
|
-
if (brush.mixer.cleanEachStroke) load =
|
|
1089
|
+
if (brush.mixer.cleanEachStroke) load = _chunkHUFQD4CBcjs.cleanMixer.call(void 0, load);
|
|
1087
1090
|
this.result.mixerLoad = load;
|
|
1088
1091
|
}
|
|
1089
1092
|
this.host.commit(this, surface, false);
|
|
@@ -1098,7 +1101,7 @@ var PaintStrokeSession = (_class6 = class {
|
|
|
1098
1101
|
}, _class6);
|
|
1099
1102
|
function mixerLoadForStroke(brush, current, color) {
|
|
1100
1103
|
if (!brush.loadsColor) return { reservoir: null, amount: 0, pickup: brush.mixer.cleanEachStroke ? null : current.pickup };
|
|
1101
|
-
if (brush.mixer.loadEachStroke || !current.reservoir) return
|
|
1104
|
+
if (brush.mixer.loadEachStroke || !current.reservoir) return _chunkHUFQD4CBcjs.loadMixer.call(void 0, current, color);
|
|
1102
1105
|
return current;
|
|
1103
1106
|
}
|
|
1104
1107
|
|
|
@@ -1265,7 +1268,7 @@ var PROFILE = {
|
|
|
1265
1268
|
}
|
|
1266
1269
|
};
|
|
1267
1270
|
function createPaintCompositor() {
|
|
1268
|
-
return new (0,
|
|
1271
|
+
return new (0, _chunkT3QZ6S47cjs.RasterCompositor)(PROFILE);
|
|
1269
1272
|
}
|
|
1270
1273
|
function downsampleRgba(data, width, height, tw, th) {
|
|
1271
1274
|
tw = Math.max(1, Math.round(tw));
|
|
@@ -1336,11 +1339,11 @@ function header(state, options) {
|
|
|
1336
1339
|
return out;
|
|
1337
1340
|
}
|
|
1338
1341
|
function serializePaintDocument(state, options = {}) {
|
|
1339
|
-
const { layers, assets } =
|
|
1342
|
+
const { layers, assets } = _chunkFRD3FUXIcjs.serializeLayers.call(void 0, state.layers);
|
|
1340
1343
|
return { ...header(state, options), layers, assets };
|
|
1341
1344
|
}
|
|
1342
1345
|
async function serializePaintDocumentExternal(state, store, options = {}) {
|
|
1343
|
-
const { layers, assets } = await
|
|
1346
|
+
const { layers, assets } = await _chunkFRD3FUXIcjs.serializeLayersExternal.call(void 0, state.layers, store);
|
|
1344
1347
|
return { ...header(state, options), layers, assets };
|
|
1345
1348
|
}
|
|
1346
1349
|
function paintLayersOnly(layers, problems) {
|
|
@@ -1377,16 +1380,16 @@ function deserializePaintDocument(raw) {
|
|
|
1377
1380
|
const canvas = normalizeCanvas({ width: r.width, height: r.height, dpi: _nullishCoalesce(r.dpi, () => ( void 0)) });
|
|
1378
1381
|
const paper = normalizePaper(_nullishCoalesce(r.paper, () => ( {})));
|
|
1379
1382
|
const assets = r.assets && typeof r.assets === "object" ? r.assets : {};
|
|
1380
|
-
const layers = paintLayersOnly(
|
|
1383
|
+
const layers = paintLayersOnly(_chunkFRD3FUXIcjs.deserializeLayers.call(void 0, r.layers, { assets, problems }), problems);
|
|
1381
1384
|
const wanted = typeof r.activeLayerId === "string" ? r.activeLayerId : null;
|
|
1382
|
-
const activeLayerId = wanted &&
|
|
1385
|
+
const activeLayerId = wanted && _chunkT3QZ6S47cjs.findLayer.call(void 0, layers, wanted) ? wanted : _nullishCoalesce(_optionalChain([_chunkT3QZ6S47cjs.flattenLayers.call(void 0, layers), 'access', _25 => _25.filter, 'call', _26 => _26((l) => l.type === "pixel"), 'access', _27 => _27.pop, 'call', _28 => _28(), 'optionalAccess', _29 => _29.id]), () => ( null));
|
|
1383
1386
|
return { state: { canvas, paper, layers, activeLayerId, strokes: readStrokes(r.strokes, problems) }, extensions: documentExtensions(r), guides: r.guides, swatches: r.swatches, problems };
|
|
1384
1387
|
}
|
|
1385
1388
|
async function deserializePaintDocumentAsync(raw, store) {
|
|
1386
1389
|
if (!raw || typeof raw !== "object") throw new Error("Not a paint document: expected a JSON object.");
|
|
1387
1390
|
const r = raw;
|
|
1388
1391
|
const problems = [];
|
|
1389
|
-
const assets = await
|
|
1392
|
+
const assets = await _chunkFRD3FUXIcjs.resolveExternalAssets.call(void 0, _nullishCoalesce(r.assets, () => ( {})), store, problems);
|
|
1390
1393
|
const loaded = deserializePaintDocument({ ...r, assets });
|
|
1391
1394
|
return { ...loaded, problems: [...problems, ...loaded.problems] };
|
|
1392
1395
|
}
|
|
@@ -1565,7 +1568,7 @@ function paintTestStroke(surface, brush, paper, color, width, height) {
|
|
|
1565
1568
|
colorHex: color,
|
|
1566
1569
|
affineCopies: [],
|
|
1567
1570
|
copies: [IDENTITY_COPY],
|
|
1568
|
-
mixerLoad: brush.engine === "mixer" ? mixerLoadForStroke(brush,
|
|
1571
|
+
mixerLoad: brush.engine === "mixer" ? mixerLoadForStroke(brush, _chunkHUFQD4CBcjs.EMPTY_MIXER_LOAD, [r / 255, g / 255, b / 255]) : _chunkHUFQD4CBcjs.EMPTY_MIXER_LOAD
|
|
1569
1572
|
}
|
|
1570
1573
|
);
|
|
1571
1574
|
session.push(thumbnailStroke(width, height));
|
|
@@ -1578,13 +1581,13 @@ function renderBrushThumbnail(brush, options) {
|
|
|
1578
1581
|
const maxSize = height * 0.42;
|
|
1579
1582
|
const b = brush.tip.size > maxSize ? normalizePaintBrush({ tip: { ...brush.tip, size: maxSize } }, brush) : brush;
|
|
1580
1583
|
const rgba = [...hexToRgb8(options.color), 255];
|
|
1581
|
-
let surface =
|
|
1584
|
+
let surface = _chunkSZ6KMZNMcjs.emptySurface.call(void 0, 4);
|
|
1582
1585
|
if (b.engine === "eraser") {
|
|
1583
|
-
surface =
|
|
1586
|
+
surface = _chunkSZ6KMZNMcjs.fillRect.call(void 0, surface, { x: 0, y: 0, width, height }, rgba);
|
|
1584
1587
|
} else if (b.engine === "mixer" && !b.loadsColor) {
|
|
1585
1588
|
const half = Math.ceil(height / 2);
|
|
1586
|
-
surface =
|
|
1587
|
-
surface =
|
|
1589
|
+
surface = _chunkSZ6KMZNMcjs.fillRect.call(void 0, surface, { x: 0, y: 0, width, height: half }, rgba);
|
|
1590
|
+
surface = _chunkSZ6KMZNMcjs.fillRect.call(void 0, surface, { x: 0, y: half, width, height: height - half }, [232, 196, 64, 255]);
|
|
1588
1591
|
}
|
|
1589
1592
|
surface = paintTestStroke(surface, b, options.paper, options.color, width, height);
|
|
1590
1593
|
const layer = { type: "pixel", id: "thumbnail", name: "thumbnail", visible: true, opacity: 1, blend: "normal", surface, offset: { x: 0, y: 0 } };
|
|
@@ -1912,7 +1915,7 @@ var PAD_KNIFE = normalizePaintBrush({
|
|
|
1912
1915
|
var MixingPad = (_class8 = class {constructor() { _class8.prototype.__init29.call(this);_class8.prototype.__init30.call(this);_class8.prototype.__init31.call(this);_class8.prototype.__init32.call(this); }
|
|
1913
1916
|
__init29() {this.width = MIXING_PAD_WIDTH}
|
|
1914
1917
|
__init30() {this.height = MIXING_PAD_HEIGHT}
|
|
1915
|
-
__init31() {this.surface =
|
|
1918
|
+
__init31() {this.surface = _chunkSZ6KMZNMcjs.emptySurface.call(void 0, 4)}
|
|
1916
1919
|
/** Increments on every change (for redrawing). */
|
|
1917
1920
|
__init32() {this.version = 0}
|
|
1918
1921
|
/** Paints (`paint`, with `color`) or smears (`knife`) through `points` in pad pixels. */
|
|
@@ -1944,7 +1947,7 @@ var MixingPad = (_class8 = class {constructor() { _class8.prototype.__init29.cal
|
|
|
1944
1947
|
colorHex: options.color,
|
|
1945
1948
|
affineCopies: [],
|
|
1946
1949
|
copies: [IDENTITY_COPY],
|
|
1947
|
-
mixerLoad: mixerLoadForStroke(brush,
|
|
1950
|
+
mixerLoad: mixerLoadForStroke(brush, _chunkHUFQD4CBcjs.EMPTY_MIXER_LOAD, [r / 255, g / 255, b / 255])
|
|
1948
1951
|
}
|
|
1949
1952
|
);
|
|
1950
1953
|
session.push(points);
|
|
@@ -1963,7 +1966,7 @@ var MixingPad = (_class8 = class {constructor() { _class8.prototype.__init29.cal
|
|
|
1963
1966
|
const y0 = Math.max(0, Math.floor(y) - r);
|
|
1964
1967
|
const x1 = Math.min(this.width, Math.floor(x) + r + 1);
|
|
1965
1968
|
const y1 = Math.min(this.height, Math.floor(y) + r + 1);
|
|
1966
|
-
const px =
|
|
1969
|
+
const px = _chunkSZ6KMZNMcjs.readRegion.call(void 0, this.surface, { x: x0, y: y0, width: x1 - x0, height: y1 - y0 });
|
|
1967
1970
|
let R = 0;
|
|
1968
1971
|
let G = 0;
|
|
1969
1972
|
let B = 0;
|
|
@@ -1980,12 +1983,12 @@ var MixingPad = (_class8 = class {constructor() { _class8.prototype.__init29.cal
|
|
|
1980
1983
|
return `#${hex(R)}${hex(G)}${hex(B)}`;
|
|
1981
1984
|
}
|
|
1982
1985
|
clear() {
|
|
1983
|
-
this.surface =
|
|
1986
|
+
this.surface = _chunkSZ6KMZNMcjs.emptySurface.call(void 0, 4);
|
|
1984
1987
|
this.version++;
|
|
1985
1988
|
}
|
|
1986
1989
|
/** The pad over white, `width × height` RGBA. */
|
|
1987
1990
|
pixels() {
|
|
1988
|
-
const px =
|
|
1991
|
+
const px = _chunkSZ6KMZNMcjs.readRegion.call(void 0, this.surface, { x: 0, y: 0, width: this.width, height: this.height });
|
|
1989
1992
|
for (let i = 0; i < px.length; i += 4) {
|
|
1990
1993
|
const a = px[i + 3] / 255;
|
|
1991
1994
|
px[i] = Math.round(px[i] * a + 255 * (1 - a));
|
|
@@ -2034,7 +2037,7 @@ var PaintEditorController = (_class9 = class {
|
|
|
2034
2037
|
|
|
2035
2038
|
|
|
2036
2039
|
__init36() {this.secondaryColor = "#ffffff"}
|
|
2037
|
-
__init37() {this.mixerLoad =
|
|
2040
|
+
__init37() {this.mixerLoad = _chunkHUFQD4CBcjs.EMPTY_MIXER_LOAD}
|
|
2038
2041
|
__init38() {this.view = { ...DEFAULT_VIEW, pan: { ...DEFAULT_VIEW.pan } }}
|
|
2039
2042
|
|
|
2040
2043
|
|
|
@@ -2204,7 +2207,7 @@ var PaintEditorController = (_class9 = class {
|
|
|
2204
2207
|
}
|
|
2205
2208
|
// --- Layers --------------------------------------------------------------------
|
|
2206
2209
|
getLayer(id) {
|
|
2207
|
-
return _optionalChain([
|
|
2210
|
+
return _optionalChain([_chunkT3QZ6S47cjs.findLayer.call(void 0, this.doc.layers, id), 'optionalAccess', _35 => _35.layer]);
|
|
2208
2211
|
}
|
|
2209
2212
|
/** The active pixel layer (or `undefined`). */
|
|
2210
2213
|
getActiveLayer() {
|
|
@@ -2223,12 +2226,12 @@ var PaintEditorController = (_class9 = class {
|
|
|
2223
2226
|
walk(this.doc.layers, null, 0);
|
|
2224
2227
|
return out;
|
|
2225
2228
|
}
|
|
2226
|
-
describeLayer(l, parentId = _nullishCoalesce(_optionalChain([
|
|
2229
|
+
describeLayer(l, parentId = _nullishCoalesce(_optionalChain([_chunkT3QZ6S47cjs.findLayer.call(void 0, this.doc.layers, l.id), 'optionalAccess', _36 => _36.parent, 'optionalAccess', _37 => _37.id]), () => ( null)), depth = _nullishCoalesce(_optionalChain([_chunkT3QZ6S47cjs.findLayer.call(void 0, this.doc.layers, l.id), 'optionalAccess', _38 => _38.path, 'access', _39 => _39.length]), () => ( 0))) {
|
|
2227
2230
|
let bounds = null;
|
|
2228
2231
|
if (l.type === "pixel") {
|
|
2229
|
-
const b =
|
|
2232
|
+
const b = _chunkSZ6KMZNMcjs.contentBounds.call(void 0, l.surface);
|
|
2230
2233
|
bounds = b ? { ...b, x: b.x + l.offset.x, y: b.y + l.offset.y } : null;
|
|
2231
|
-
} else for (const c of
|
|
2234
|
+
} else for (const c of _chunkT3QZ6S47cjs.flattenLayers.call(void 0, l.children)) if (c.type === "pixel") bounds = unionRect(bounds, this.describeLayer(c, l.id, depth + 1).bounds);
|
|
2232
2235
|
return {
|
|
2233
2236
|
id: l.id,
|
|
2234
2237
|
name: l.name,
|
|
@@ -2255,7 +2258,7 @@ var PaintEditorController = (_class9 = class {
|
|
|
2255
2258
|
if (!id) throw new PaintEditorError(`There is no active layer to ${what}; add one with add_layer.`);
|
|
2256
2259
|
const l = this.requireLayer(id);
|
|
2257
2260
|
if (!isPixelLayer(l)) throw new PaintEditorError(`Layer "${l.name}" is a group; ${what} a pixel layer inside it.`);
|
|
2258
|
-
if (
|
|
2261
|
+
if (_chunkT3QZ6S47cjs.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.`);
|
|
2259
2262
|
if (!l.visible) throw new PaintEditorError(`Layer "${l.name}" is hidden; show it (update_layer visible true) before you ${what} it.`);
|
|
2260
2263
|
return l;
|
|
2261
2264
|
}
|
|
@@ -2268,7 +2271,7 @@ var PaintEditorController = (_class9 = class {
|
|
|
2268
2271
|
/** Adds an empty pixel layer or group above `aboveId` (default: the active layer) and makes it active. */
|
|
2269
2272
|
addLayer(options = {}) {
|
|
2270
2273
|
this.requireIdle("adding a layer");
|
|
2271
|
-
const count =
|
|
2274
|
+
const count = _chunkT3QZ6S47cjs.flattenLayers.call(void 0, this.doc.layers).length;
|
|
2272
2275
|
const type = _nullishCoalesce(options.type, () => ( "pixel"));
|
|
2273
2276
|
const name = _optionalChain([options, 'access', _40 => _40.name, 'optionalAccess', _41 => _41.trim, 'call', _42 => _42()]) || (type === "group" ? `Group ${count + 1}` : `Layer ${count + 1}`);
|
|
2274
2277
|
const layer = type === "group" ? { type: "group", id: newPaintLayerId(), name, visible: true, opacity: 1, blend: "pass-through", children: [] } : createPaintLayer(name);
|
|
@@ -2280,21 +2283,21 @@ var PaintEditorController = (_class9 = class {
|
|
|
2280
2283
|
if (g.type !== "group") throw new PaintEditorError(`Layer "${g.name}" is not a group; pass a group id as parentId.`);
|
|
2281
2284
|
parentId = g.id;
|
|
2282
2285
|
} else if (above) {
|
|
2283
|
-
const loc =
|
|
2286
|
+
const loc = _chunkT3QZ6S47cjs.findLayer.call(void 0, this.doc.layers, above);
|
|
2284
2287
|
if (!loc) throw new PaintEditorError(`Unknown layer "${above}". Call list_layers for the ids.`);
|
|
2285
2288
|
parentId = _nullishCoalesce(_optionalChain([loc, 'access', _43 => _43.parent, 'optionalAccess', _44 => _44.id]), () => ( null));
|
|
2286
2289
|
index = loc.index + 1;
|
|
2287
2290
|
}
|
|
2288
|
-
const layers =
|
|
2291
|
+
const layers = _chunkT3QZ6S47cjs.insertLayer.call(void 0, this.doc.layers, layer, parentId, index);
|
|
2289
2292
|
this.commit(type === "group" ? "Add group" : "Add layer", { ...this.doc, layers, activeLayerId: layer.id });
|
|
2290
2293
|
return this.describeLayer(layer);
|
|
2291
2294
|
}
|
|
2292
2295
|
updateLayer(id, update) {
|
|
2293
2296
|
this.requireIdle("changing a layer");
|
|
2294
2297
|
const l = this.requireLayer(id);
|
|
2295
|
-
if (
|
|
2298
|
+
if (_chunkT3QZ6S47cjs.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}).`);
|
|
2296
2299
|
if (update.opacity !== void 0 && !(update.opacity >= 0 && update.opacity <= 1)) throw new PaintEditorError(`opacity ${update.opacity} is out of range; use 0..1.`);
|
|
2297
|
-
if (update.blend !== void 0 && !
|
|
2300
|
+
if (update.blend !== void 0 && !_chunkSZ6KMZNMcjs.isBlendMode.call(void 0, update.blend) && !(l.type === "group" && update.blend === "pass-through")) {
|
|
2298
2301
|
throw new PaintEditorError(`Unknown blend mode "${update.blend}". Call get_canvas_info for the blend modes.`);
|
|
2299
2302
|
}
|
|
2300
2303
|
if (update.name !== void 0 && !update.name.trim()) throw new PaintEditorError("name is empty; give the layer a name.");
|
|
@@ -2308,66 +2311,66 @@ var PaintEditorController = (_class9 = class {
|
|
|
2308
2311
|
const locks = { ..._nullishCoalesce(l.locks, () => ( {})), ...update.locks };
|
|
2309
2312
|
next.locks = Object.values(locks).some(Boolean) ? locks : void 0;
|
|
2310
2313
|
}
|
|
2311
|
-
this.commit("Layer properties", { ...this.doc, layers:
|
|
2314
|
+
this.commit("Layer properties", { ...this.doc, layers: _chunkT3QZ6S47cjs.mapLayer.call(void 0, this.doc.layers, id, () => next) });
|
|
2312
2315
|
return this.describeLayer(next);
|
|
2313
2316
|
}
|
|
2314
2317
|
removeLayer(id) {
|
|
2315
2318
|
this.requireIdle("removing a layer");
|
|
2316
2319
|
const l = this.requireLayer(id);
|
|
2317
|
-
if (
|
|
2318
|
-
const layers =
|
|
2320
|
+
if (_chunkT3QZ6S47cjs.isLayerLocked.call(void 0, l, "all")) throw new PaintEditorError(`Layer "${l.name}" is fully locked; unlock it before removing it.`);
|
|
2321
|
+
const layers = _chunkT3QZ6S47cjs.mapLayer.call(void 0, this.doc.layers, id, () => null);
|
|
2319
2322
|
let active = this.doc.activeLayerId;
|
|
2320
|
-
if (active && !
|
|
2323
|
+
if (active && !_chunkT3QZ6S47cjs.findLayer.call(void 0, layers, active)) active = _nullishCoalesce(_optionalChain([_chunkT3QZ6S47cjs.flattenLayers.call(void 0, layers), 'access', _45 => _45.filter, 'call', _46 => _46((x) => x.type === "pixel"), 'access', _47 => _47.pop, 'call', _48 => _48(), 'optionalAccess', _49 => _49.id]), () => ( null));
|
|
2321
2324
|
this.commit("Remove layer", { ...this.doc, layers, activeLayerId: active });
|
|
2322
2325
|
return { removed: id, activeLayerId: active };
|
|
2323
2326
|
}
|
|
2324
2327
|
duplicateLayer(id) {
|
|
2325
2328
|
this.requireIdle("duplicating a layer");
|
|
2326
|
-
const loc =
|
|
2329
|
+
const loc = _chunkT3QZ6S47cjs.findLayer.call(void 0, this.doc.layers, id);
|
|
2327
2330
|
if (!loc) throw new PaintEditorError(`Unknown layer "${id}". Call list_layers for the ids.`);
|
|
2328
2331
|
const copy = (l) => l.type === "group" ? { ...l, id: newPaintLayerId(), children: l.children.map(copy) } : { ...l, id: newPaintLayerId() };
|
|
2329
2332
|
const dup = { ...copy(loc.layer), name: `${loc.layer.name} copy` };
|
|
2330
|
-
const layers =
|
|
2333
|
+
const layers = _chunkT3QZ6S47cjs.insertLayer.call(void 0, this.doc.layers, dup, _nullishCoalesce(_optionalChain([loc, 'access', _50 => _50.parent, 'optionalAccess', _51 => _51.id]), () => ( null)), loc.index + 1);
|
|
2331
2334
|
this.commit("Duplicate layer", { ...this.doc, layers, activeLayerId: dup.id });
|
|
2332
2335
|
return this.describeLayer(dup);
|
|
2333
2336
|
}
|
|
2334
2337
|
/** Moves a layer to `index` (0 = bottom) within `parentId` (default its own parent; `null` = top level). */
|
|
2335
2338
|
moveLayer(id, index, parentId) {
|
|
2336
2339
|
this.requireIdle("moving a layer");
|
|
2337
|
-
const loc =
|
|
2340
|
+
const loc = _chunkT3QZ6S47cjs.findLayer.call(void 0, this.doc.layers, id);
|
|
2338
2341
|
if (!loc) throw new PaintEditorError(`Unknown layer "${id}". Call list_layers for the ids.`);
|
|
2339
2342
|
const target = parentId === void 0 ? _nullishCoalesce(_optionalChain([loc, 'access', _52 => _52.parent, 'optionalAccess', _53 => _53.id]), () => ( null)) : parentId;
|
|
2340
2343
|
if (target) {
|
|
2341
2344
|
const g = this.requireLayer(target);
|
|
2342
2345
|
if (g.type !== "group") throw new PaintEditorError(`Layer "${g.name}" is not a group; pass a group id as parentId.`);
|
|
2343
|
-
if (target === id || loc.layer.type === "group" &&
|
|
2346
|
+
if (target === id || loc.layer.type === "group" && _chunkT3QZ6S47cjs.findLayer.call(void 0, loc.layer.children, target)) throw new PaintEditorError("A group cannot move into itself.");
|
|
2344
2347
|
}
|
|
2345
|
-
const without =
|
|
2346
|
-
const siblings = target ?
|
|
2348
|
+
const without = _chunkT3QZ6S47cjs.mapLayer.call(void 0, this.doc.layers, id, () => null);
|
|
2349
|
+
const siblings = target ? _chunkT3QZ6S47cjs.findLayer.call(void 0, without, target).layer.children : without;
|
|
2347
2350
|
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).`);
|
|
2348
|
-
const layers =
|
|
2351
|
+
const layers = _chunkT3QZ6S47cjs.insertLayer.call(void 0, without, loc.layer, target, index);
|
|
2349
2352
|
this.commit("Move layer", { ...this.doc, layers });
|
|
2350
2353
|
return this.describeLayer(loc.layer);
|
|
2351
2354
|
}
|
|
2352
2355
|
/** Merges a pixel layer into the pixel layer below it (keeping the lower one's settings). */
|
|
2353
2356
|
mergeDown(id) {
|
|
2354
2357
|
this.requireIdle("merging");
|
|
2355
|
-
const loc =
|
|
2358
|
+
const loc = _chunkT3QZ6S47cjs.findLayer.call(void 0, this.doc.layers, id);
|
|
2356
2359
|
if (!loc) throw new PaintEditorError(`Unknown layer "${id}". Call list_layers for the ids.`);
|
|
2357
2360
|
const siblings = loc.parent ? loc.parent.children : this.doc.layers;
|
|
2358
2361
|
const below = siblings[loc.index - 1];
|
|
2359
2362
|
const upper = loc.layer;
|
|
2360
2363
|
if (!isPixelLayer(upper) || !isPixelLayer(below)) throw new PaintEditorError("Merge down needs a pixel layer directly above another pixel layer in the same group.");
|
|
2361
|
-
if (
|
|
2364
|
+
if (_chunkT3QZ6S47cjs.isLayerLocked.call(void 0, below, "pixels")) throw new PaintEditorError(`Layer "${below.name}" has its pixels locked; unlock it to merge into it.`);
|
|
2362
2365
|
const rect = unionRect(this.describeLayer(below).bounds, this.describeLayer(upper).bounds);
|
|
2363
|
-
let surface =
|
|
2366
|
+
let surface = _chunkSZ6KMZNMcjs.emptySurface.call(void 0, 4);
|
|
2364
2367
|
if (rect) {
|
|
2365
2368
|
const base = { ...below, opacity: 1, blend: "normal", visible: true, clipped: void 0, mask: void 0 };
|
|
2366
2369
|
const px = createPaintCompositor().composite([base, upper.visible ? upper : { ...upper, opacity: 0 }], rect, this.sources());
|
|
2367
|
-
surface =
|
|
2370
|
+
surface = _chunkSZ6KMZNMcjs.surfaceFromPixels.call(void 0, { width: rect.width, height: rect.height, data: px }, 4, rect.x, rect.y);
|
|
2368
2371
|
}
|
|
2369
2372
|
const merged = { ...below, surface, offset: { x: 0, y: 0 } };
|
|
2370
|
-
const layers =
|
|
2373
|
+
const layers = _chunkT3QZ6S47cjs.mapLayer.call(void 0, _chunkT3QZ6S47cjs.mapLayer.call(void 0, this.doc.layers, upper.id, () => null), below.id, () => merged);
|
|
2371
2374
|
this.commit("Merge down", { ...this.doc, layers, activeLayerId: below.id });
|
|
2372
2375
|
return this.describeLayer(merged);
|
|
2373
2376
|
}
|
|
@@ -2376,7 +2379,7 @@ var PaintEditorController = (_class9 = class {
|
|
|
2376
2379
|
this.requireIdle("clearing");
|
|
2377
2380
|
const l = this.paintTarget(layerId, "clear");
|
|
2378
2381
|
const bounds = this.describeLayer(l).bounds;
|
|
2379
|
-
this.commit("Clear layer", { ...this.doc, layers:
|
|
2382
|
+
this.commit("Clear layer", { ...this.doc, layers: _chunkT3QZ6S47cjs.mapLayer.call(void 0, this.doc.layers, l.id, () => ({ ...l, surface: _chunkSZ6KMZNMcjs.emptySurface.call(void 0, 4) })) });
|
|
2380
2383
|
return { layerId: l.id, bounds };
|
|
2381
2384
|
}
|
|
2382
2385
|
/**
|
|
@@ -2393,14 +2396,14 @@ var PaintEditorController = (_class9 = class {
|
|
|
2393
2396
|
if (!(grainAmount >= 0 && grainAmount <= 1)) throw new PaintEditorError(`grain ${grainAmount} is out of range; use 0..1.`);
|
|
2394
2397
|
const pressure = _nullishCoalesce(options.pressure, () => ( 0.5));
|
|
2395
2398
|
const blend = _nullishCoalesce(options.blend, () => ( "normal"));
|
|
2396
|
-
if (!
|
|
2399
|
+
if (!_chunkSZ6KMZNMcjs.isBlendMode.call(void 0, blend)) throw new PaintEditorError(`Unknown blend mode "${blend}".`);
|
|
2397
2400
|
const { width, height } = this.doc.canvas;
|
|
2398
2401
|
const rect = { x: 0, y: 0, width, height };
|
|
2399
|
-
const coverage = new (0,
|
|
2402
|
+
const coverage = new (0, _chunkHUFQD4CBcjs.CoverageMap)();
|
|
2400
2403
|
const depth = grainAmount * this.doc.paper.depth;
|
|
2401
2404
|
const grain = depth > 0 ? paperGrain(this.doc.paper) : null;
|
|
2402
|
-
for (const { tx, ty } of
|
|
2403
|
-
const r = { x: tx *
|
|
2405
|
+
for (const { tx, ty } of _chunkSZ6KMZNMcjs.tilesInRect.call(void 0, rect)) {
|
|
2406
|
+
const r = { x: tx * _chunkSZ6KMZNMcjs.TILE, y: ty * _chunkSZ6KMZNMcjs.TILE, width: Math.min(_chunkSZ6KMZNMcjs.TILE, width - tx * _chunkSZ6KMZNMcjs.TILE), height: Math.min(_chunkSZ6KMZNMcjs.TILE, height - ty * _chunkSZ6KMZNMcjs.TILE) };
|
|
2404
2407
|
const vals = new Float32Array(r.width * r.height);
|
|
2405
2408
|
for (let y = 0, k = 0; y < r.height; y++) for (let x = 0; x < r.width; x++, k++) vals[k] = grain ? grainCatch(grain.at(r.x + x + 0.5, r.y + y + 0.5), depth, pressure) : 1;
|
|
2406
2409
|
coverage.accumulate(r, vals, 1);
|
|
@@ -2411,25 +2414,25 @@ var PaintEditorController = (_class9 = class {
|
|
|
2411
2414
|
background: rgbaOf(this.doc.paper.color),
|
|
2412
2415
|
opacity,
|
|
2413
2416
|
blend,
|
|
2414
|
-
lockTransparency:
|
|
2417
|
+
lockTransparency: _chunkT3QZ6S47cjs.isLayerLocked.call(void 0, l, "transparency"),
|
|
2415
2418
|
selection: null,
|
|
2416
2419
|
offset: l.offset
|
|
2417
2420
|
};
|
|
2418
2421
|
const surface = this.applyCoverage(l, coverage, rect, apply);
|
|
2419
|
-
this.commit("Fill layer", { ...this.doc, layers:
|
|
2422
|
+
this.commit("Fill layer", { ...this.doc, layers: _chunkT3QZ6S47cjs.mapLayer.call(void 0, this.doc.layers, l.id, () => ({ ...l, surface })) });
|
|
2420
2423
|
return { layerId: l.id, bounds: rect };
|
|
2421
2424
|
}
|
|
2422
2425
|
applyCoverage(l, coverage, rect, apply) {
|
|
2423
2426
|
const base = l.surface;
|
|
2424
2427
|
const tiles = new Map(base.tiles);
|
|
2425
|
-
for (const { tx, ty } of
|
|
2426
|
-
const key =
|
|
2427
|
-
const src = _nullishCoalesce(_optionalChain([base, 'access', _54 => _54.tiles, 'access', _55 => _55.get, 'call', _56 => _56(key), 'optionalAccess', _57 => _57.data]), () => ( new Uint8ClampedArray(
|
|
2428
|
-
const tile =
|
|
2428
|
+
for (const { tx, ty } of _chunkSZ6KMZNMcjs.tilesInRect.call(void 0, { x: rect.x - l.offset.x, y: rect.y - l.offset.y, width: rect.width, height: rect.height })) {
|
|
2429
|
+
const key = _chunkSZ6KMZNMcjs.tileKey.call(void 0, tx, ty);
|
|
2430
|
+
const src = _nullishCoalesce(_optionalChain([base, 'access', _54 => _54.tiles, 'access', _55 => _55.get, 'call', _56 => _56(key), 'optionalAccess', _57 => _57.data]), () => ( new Uint8ClampedArray(_chunkSZ6KMZNMcjs.TILE * _chunkSZ6KMZNMcjs.TILE * 4)));
|
|
2431
|
+
const tile = _chunkSZ6KMZNMcjs.finishTile.call(void 0, _chunkHUFQD4CBcjs.applyStrokeToTile.call(void 0, coverage, src, 4, tx, ty, apply), 4, 0);
|
|
2429
2432
|
if (tile) tiles.set(key, tile);
|
|
2430
2433
|
else tiles.delete(key);
|
|
2431
2434
|
}
|
|
2432
|
-
return new (0,
|
|
2435
|
+
return new (0, _chunkSZ6KMZNMcjs.TiledSurface)(4, tiles, 0);
|
|
2433
2436
|
}
|
|
2434
2437
|
// --- Brushes -------------------------------------------------------------------
|
|
2435
2438
|
findBrush(id) {
|
|
@@ -2549,7 +2552,7 @@ var PaintEditorController = (_class9 = class {
|
|
|
2549
2552
|
if (options.layerId !== void 0) {
|
|
2550
2553
|
const l = this.requireLayer(options.layerId);
|
|
2551
2554
|
if (!isPixelLayer(l)) throw new PaintEditorError(`Layer "${l.name}" is a group; pick from a pixel layer or the composite.`);
|
|
2552
|
-
const [r, g, b, a] =
|
|
2555
|
+
const [r, g, b, a] = _chunkSZ6KMZNMcjs.readPixel.call(void 0, l.surface, px - l.offset.x, py - l.offset.y);
|
|
2553
2556
|
return { color: rgbToHex(r, g, b), alpha: Math.round(a / 255 * 1e3) / 1e3 };
|
|
2554
2557
|
}
|
|
2555
2558
|
const d = this.exportCompositor.composite(this.renderLayers({}), { x: px, y: py, width: 1, height: 1 }, this.sources());
|
|
@@ -2559,13 +2562,13 @@ var PaintEditorController = (_class9 = class {
|
|
|
2559
2562
|
/** Fills the Mixer Brush reservoir with a colour (default the editor colour). */
|
|
2560
2563
|
loadMixerBrush(color) {
|
|
2561
2564
|
const [r, g, b] = hexToRgb8(color === void 0 ? this.color : parseColor(color));
|
|
2562
|
-
this.mixerLoad =
|
|
2565
|
+
this.mixerLoad = _chunkHUFQD4CBcjs.loadMixer.call(void 0, this.mixerLoad, [r / 255, g / 255, b / 255]);
|
|
2563
2566
|
this.emit([]);
|
|
2564
2567
|
return this.mixerLoad;
|
|
2565
2568
|
}
|
|
2566
2569
|
/** Empties the pickup well (and with `emptyReservoir` the loaded paint too). */
|
|
2567
2570
|
cleanMixerBrush(emptyReservoir = false) {
|
|
2568
|
-
this.mixerLoad = emptyReservoir ?
|
|
2571
|
+
this.mixerLoad = emptyReservoir ? _chunkHUFQD4CBcjs.EMPTY_MIXER_LOAD : _chunkHUFQD4CBcjs.cleanMixer.call(void 0, this.mixerLoad);
|
|
2569
2572
|
this.emit([]);
|
|
2570
2573
|
return this.mixerLoad;
|
|
2571
2574
|
}
|
|
@@ -2599,11 +2602,11 @@ var PaintEditorController = (_class9 = class {
|
|
|
2599
2602
|
const layer = (() => {
|
|
2600
2603
|
const id = _nullishCoalesce(init.layerId, () => ( doc.activeLayerId));
|
|
2601
2604
|
if (!id) throw new PaintEditorError("There is no active layer to paint on; add one with add_layer.");
|
|
2602
|
-
const loc =
|
|
2605
|
+
const loc = _chunkT3QZ6S47cjs.findLayer.call(void 0, doc.layers, id);
|
|
2603
2606
|
if (!loc) throw new PaintEditorError(`Unknown layer "${id}". Call list_layers for the ids.`);
|
|
2604
2607
|
const l = loc.layer;
|
|
2605
2608
|
if (!isPixelLayer(l)) throw new PaintEditorError(`Layer "${l.name}" is a group; paint on a pixel layer inside it.`);
|
|
2606
|
-
if (
|
|
2609
|
+
if (_chunkT3QZ6S47cjs.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.`);
|
|
2607
2610
|
if (!l.visible) throw new PaintEditorError(`Layer "${l.name}" is hidden; show it (update_layer visible true) to paint on it.`);
|
|
2608
2611
|
return l;
|
|
2609
2612
|
})();
|
|
@@ -2620,7 +2623,7 @@ var PaintEditorController = (_class9 = class {
|
|
|
2620
2623
|
layerId: layer.id,
|
|
2621
2624
|
surface: layer.surface,
|
|
2622
2625
|
offset: layer.offset,
|
|
2623
|
-
lockTransparency:
|
|
2626
|
+
lockTransparency: _chunkT3QZ6S47cjs.isLayerLocked.call(void 0, layer, "transparency"),
|
|
2624
2627
|
brush,
|
|
2625
2628
|
color: rgba,
|
|
2626
2629
|
background: rgbaOf(doc.paper.color),
|
|
@@ -2631,7 +2634,7 @@ var PaintEditorController = (_class9 = class {
|
|
|
2631
2634
|
affineCopies: copies,
|
|
2632
2635
|
copies: [IDENTITY_AFFINE, ...copies].map(affineCopy),
|
|
2633
2636
|
inputFilter: snapper ? (p) => snapper.snap(p) : void 0,
|
|
2634
|
-
mixerLoad: brush.engine === "mixer" ? mixerLoadForStroke(brush, this.mixerLoad, [rgba[0] / 255, rgba[1] / 255, rgba[2] / 255]) :
|
|
2637
|
+
mixerLoad: brush.engine === "mixer" ? mixerLoadForStroke(brush, this.mixerLoad, [rgba[0] / 255, rgba[1] / 255, rgba[2] / 255]) : _chunkHUFQD4CBcjs.EMPTY_MIXER_LOAD
|
|
2635
2638
|
});
|
|
2636
2639
|
return session;
|
|
2637
2640
|
}
|
|
@@ -2672,7 +2675,7 @@ var PaintEditorController = (_class9 = class {
|
|
|
2672
2675
|
const stroke = this.record(s);
|
|
2673
2676
|
s.result.strokeId = stroke.id;
|
|
2674
2677
|
const l = this.getLayer(s.layerId);
|
|
2675
|
-
this.commit(`${brush.name} stroke`, { ...this.doc, layers:
|
|
2678
|
+
this.commit(`${brush.name} stroke`, { ...this.doc, layers: _chunkT3QZ6S47cjs.mapLayer.call(void 0, this.doc.layers, l.id, () => ({ ...l, surface })), strokes: [...this.doc.strokes, stroke] });
|
|
2676
2679
|
}
|
|
2677
2680
|
};
|
|
2678
2681
|
const session = this.sessionFor(this.doc, { snapToPerspective: true, ...init }, host);
|
|
@@ -2694,8 +2697,8 @@ var PaintEditorController = (_class9 = class {
|
|
|
2694
2697
|
if (cancelled || !surface) return;
|
|
2695
2698
|
const stroke = this.record(s);
|
|
2696
2699
|
s.result.strokeId = stroke.id;
|
|
2697
|
-
const l =
|
|
2698
|
-
out = { ...out, layers:
|
|
2700
|
+
const l = _chunkT3QZ6S47cjs.findLayer.call(void 0, out.layers, s.layerId).layer;
|
|
2701
|
+
out = { ...out, layers: _chunkT3QZ6S47cjs.mapLayer.call(void 0, out.layers, l.id, () => ({ ...l, surface })), strokes: [...out.strokes, stroke] };
|
|
2699
2702
|
}
|
|
2700
2703
|
};
|
|
2701
2704
|
const session = this.sessionFor(doc, init, host);
|
|
@@ -2766,7 +2769,7 @@ var PaintEditorController = (_class9 = class {
|
|
|
2766
2769
|
brush = normalizePaintBrush({ tip: { ...b.tip, size: b.tip.size * (v.brush.tip.size / s.brush.tip.size) } }, b);
|
|
2767
2770
|
}
|
|
2768
2771
|
const layerId = _nullishCoalesce(options.layerId, () => ( s.layerId));
|
|
2769
|
-
if (!
|
|
2772
|
+
if (!_chunkT3QZ6S47cjs.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.`);
|
|
2770
2773
|
const run = this.runStroke(doc, { layerId, color: _nullishCoalesce(options.color, () => ( s.color)), brush, seed: s.seed, copies: _nullishCoalesce(v.copies, () => ( [])) }, v.points);
|
|
2771
2774
|
doc = run.doc;
|
|
2772
2775
|
bounds = unionRect(bounds, run.result.bounds);
|
|
@@ -2786,7 +2789,7 @@ var PaintEditorController = (_class9 = class {
|
|
|
2786
2789
|
const live = this.live;
|
|
2787
2790
|
if (!live) return this.doc.layers;
|
|
2788
2791
|
if (_optionalChain([this, 'access', _63 => _63.liveLayers, 'optionalAccess', _64 => _64.key]) === live.surface) return this.liveLayers.layers;
|
|
2789
|
-
const layers =
|
|
2792
|
+
const layers = _chunkT3QZ6S47cjs.mapLayer.call(void 0, this.doc.layers, live.layerId, (l) => ({ ...l, surface: live.surface }));
|
|
2790
2793
|
this.liveLayers = { key: live.surface, layers };
|
|
2791
2794
|
return layers;
|
|
2792
2795
|
}
|
|
@@ -2890,7 +2893,7 @@ var PaintEditorController = (_class9 = class {
|
|
|
2890
2893
|
/** The canvas as PNG bytes (paper included by default; `scale` below 1 shrinks it). */
|
|
2891
2894
|
exportPng(options = {}) {
|
|
2892
2895
|
const img = this.scaled(options);
|
|
2893
|
-
return
|
|
2896
|
+
return _chunkT3QZ6S47cjs.encodePng.call(void 0, img.width, img.height, img.data);
|
|
2894
2897
|
}
|
|
2895
2898
|
scaled(options) {
|
|
2896
2899
|
const full = this.compositePixels(options);
|
|
@@ -2932,19 +2935,32 @@ var PaintEditorController = (_class9 = class {
|
|
|
2932
2935
|
opacity: 1,
|
|
2933
2936
|
blend: "normal",
|
|
2934
2937
|
locks: { all: true },
|
|
2935
|
-
surface:
|
|
2938
|
+
surface: _chunkSZ6KMZNMcjs.surfaceFromPixels.call(void 0, paperPixels, 4),
|
|
2936
2939
|
offset: { x: 0, y: 0 }
|
|
2937
2940
|
};
|
|
2938
2941
|
const merged = this.compositePixels({ paper: true }).data;
|
|
2939
|
-
const
|
|
2940
|
-
const
|
|
2941
|
-
|
|
2942
|
+
const changed = /* @__PURE__ */ new Map();
|
|
2943
|
+
const toStandard = (layers2) => layers2.map((l) => {
|
|
2944
|
+
const blend = l.blend === "pass-through" ? l.blend : _chunkSZ6KMZNMcjs.standardBlendMode.call(void 0, l.blend);
|
|
2945
|
+
if (blend !== l.blend) changed.set(l.blend, [..._nullishCoalesce(changed.get(l.blend), () => ( [])), l.name]);
|
|
2946
|
+
const next = blend === l.blend ? l : { ...l, blend };
|
|
2947
|
+
return next.type === "group" ? { ...next, children: toStandard(next.children) } : next;
|
|
2948
|
+
});
|
|
2949
|
+
const layers = toStandard(this.doc.layers);
|
|
2950
|
+
const result = _chunkFRD3FUXIcjs.exportPsd.call(void 0, { width, height, layers: [paperLayer, ...layers], merged, resolution: dpi });
|
|
2951
|
+
for (const [mode, names] of changed) {
|
|
2952
|
+
const label = _nullishCoalesce(_optionalChain([_chunkSZ6KMZNMcjs.BLEND_MODES, 'access', _72 => _72.find, 'call', _73 => _73((m) => m.id === mode), 'optionalAccess', _74 => _74.label]), () => ( mode));
|
|
2953
|
+
const std = _nullishCoalesce(_optionalChain([_chunkSZ6KMZNMcjs.BLEND_MODES, 'access', _75 => _75.find, 'call', _76 => _76((m) => m.id === _chunkSZ6KMZNMcjs.standardBlendMode.call(void 0, mode)), 'optionalAccess', _77 => _77.label]), () => ( _chunkSZ6KMZNMcjs.standardBlendMode.call(void 0, mode)));
|
|
2954
|
+
const list = names.map((n) => `"${n}"`).join(", ");
|
|
2955
|
+
const one = names.length === 1;
|
|
2956
|
+
result.warnings.push(`${label} blending has no PSD equivalent; ${list} ${one ? "was" : "were"} written as ${std}, the nearest Photoshop mode, so ${one ? "it looks" : "they look"} different in Photoshop (the merged image is exact).`);
|
|
2957
|
+
}
|
|
2942
2958
|
return result;
|
|
2943
2959
|
}
|
|
2944
2960
|
/** `render_preview` as a base64 PNG. */
|
|
2945
2961
|
previewPngBase64(options = {}) {
|
|
2946
2962
|
const img = this.renderPreview(options);
|
|
2947
|
-
return { data:
|
|
2963
|
+
return { data: _chunkT3QZ6S47cjs.bytesToBase64.call(void 0, _chunkT3QZ6S47cjs.encodePng.call(void 0, img.width, img.height, img.data)), width: img.width, height: img.height };
|
|
2948
2964
|
}
|
|
2949
2965
|
// --- Guides --------------------------------------------------------------------
|
|
2950
2966
|
setGuides(next) {
|
|
@@ -2982,17 +2998,17 @@ var PaintEditorController = (_class9 = class {
|
|
|
2982
2998
|
pixels = this.decodeImage(input.png.trim().startsWith("data:") ? input.png.trim() : `data:image/png;base64,${input.png.trim()}`, what);
|
|
2983
2999
|
} else throw new PaintEditorError(`${what}: pass png (a PNG as base64 or a data URL) or pixels.`);
|
|
2984
3000
|
if (pixels.width > MAX_IMAGE_SIDE || pixels.height > MAX_IMAGE_SIDE) throw new PaintEditorError(`${what} is ${pixels.width}\xD7${pixels.height}; the limit is ${MAX_IMAGE_SIDE} px per side.`);
|
|
2985
|
-
const src =
|
|
3001
|
+
const src = _chunkT3QZ6S47cjs.pngDataUrl.call(void 0, pixels.width, pixels.height, pixels.data);
|
|
2986
3002
|
this.imagePixels.set(src, pixels);
|
|
2987
3003
|
return { src, pixels };
|
|
2988
3004
|
}
|
|
2989
3005
|
decodeImage(src, what = "Image") {
|
|
2990
3006
|
const cached = this.imagePixels.get(src);
|
|
2991
3007
|
if (cached) return cached;
|
|
2992
|
-
const parsed =
|
|
3008
|
+
const parsed = _chunkT3QZ6S47cjs.parseDataUrl.call(void 0, src);
|
|
2993
3009
|
if (!parsed) throw new PaintEditorError(`${what} is not a data URL or base64 PNG.`);
|
|
2994
3010
|
try {
|
|
2995
|
-
const png =
|
|
3011
|
+
const png = _chunkT3QZ6S47cjs.decodePng.call(void 0, parsed.bytes);
|
|
2996
3012
|
const px = { width: png.width, height: png.height, data: png.data };
|
|
2997
3013
|
this.imagePixels.set(src, px);
|
|
2998
3014
|
return px;
|
|
@@ -3050,7 +3066,7 @@ var PaintEditorController = (_class9 = class {
|
|
|
3050
3066
|
const { src, pixels } = this.importImage(options, "The reference image");
|
|
3051
3067
|
const ref = {
|
|
3052
3068
|
id: `ref${this.nextReferenceId++}`,
|
|
3053
|
-
name: _optionalChain([options, 'access',
|
|
3069
|
+
name: _optionalChain([options, 'access', _78 => _78.name, 'optionalAccess', _79 => _79.trim, 'call', _80 => _80()]) || `Reference ${this.guides.references.length + 1}`,
|
|
3054
3070
|
src,
|
|
3055
3071
|
width: pixels.width,
|
|
3056
3072
|
height: pixels.height,
|
|
@@ -3129,7 +3145,7 @@ var PaintEditorController = (_class9 = class {
|
|
|
3129
3145
|
try {
|
|
3130
3146
|
const px = this.decodeImage(ref.src, `Reference "${ref.name}"`);
|
|
3131
3147
|
guides.references.push({ id: ref.id, name: String(_nullishCoalesce(ref.name, () => ( ref.id))), src: ref.src, width: px.width, height: px.height, x: Number(ref.x) || 0, y: Number(ref.y) || 0, displayWidth: Number(ref.displayWidth) || 240, visible: ref.visible !== false });
|
|
3132
|
-
const n = Number(_nullishCoalesce(_optionalChain([/^ref(\d+)$/, 'access',
|
|
3148
|
+
const n = Number(_nullishCoalesce(_optionalChain([/^ref(\d+)$/, 'access', _81 => _81.exec, 'call', _82 => _82(ref.id), 'optionalAccess', _83 => _83[1]]), () => ( 0)));
|
|
3133
3149
|
if (n >= this.nextReferenceId) this.nextReferenceId = n + 1;
|
|
3134
3150
|
} catch (e) {
|
|
3135
3151
|
problems.push(e.message);
|
|
@@ -3149,7 +3165,7 @@ var PaintEditorController = (_class9 = class {
|
|
|
3149
3165
|
}
|
|
3150
3166
|
addSwatch(color, name) {
|
|
3151
3167
|
const c = parseColor(color);
|
|
3152
|
-
this.swatches = [...this.swatches, _optionalChain([name, 'optionalAccess',
|
|
3168
|
+
this.swatches = [...this.swatches, _optionalChain([name, 'optionalAccess', _84 => _84.trim, 'call', _85 => _85()]) ? { color: c, name: name.trim() } : { color: c }];
|
|
3153
3169
|
this.emit([]);
|
|
3154
3170
|
return this.swatches;
|
|
3155
3171
|
}
|
|
@@ -3197,7 +3213,7 @@ var PaintEditorController = (_class9 = class {
|
|
|
3197
3213
|
}
|
|
3198
3214
|
/** A layer's tile surface (live while stroking), for thumbnails. */
|
|
3199
3215
|
layerSurface(id) {
|
|
3200
|
-
const l = _optionalChain([
|
|
3216
|
+
const l = _optionalChain([_chunkT3QZ6S47cjs.findLayer.call(void 0, this.currentLayers(), id), 'optionalAccess', _86 => _86.layer]);
|
|
3201
3217
|
return isPixelLayer(l) ? l.surface : null;
|
|
3202
3218
|
}
|
|
3203
3219
|
}, _class9);
|
|
@@ -3554,7 +3570,7 @@ function createPaintGuideTools(c) {
|
|
|
3554
3570
|
const pad = c.mixingPad;
|
|
3555
3571
|
return {
|
|
3556
3572
|
content: [
|
|
3557
|
-
{ type: "image", data:
|
|
3573
|
+
{ type: "image", data: _chunkT3QZ6S47cjs.bytesToBase64.call(void 0, _chunkT3QZ6S47cjs.encodePng.call(void 0, pad.width, pad.height, pad.pixels())), mimeType: "image/png" },
|
|
3558
3574
|
{ type: "text", text: `Mixing pad ${pad.width}\xD7${pad.height}` }
|
|
3559
3575
|
]
|
|
3560
3576
|
};
|
|
@@ -3575,7 +3591,7 @@ var TIP = {
|
|
|
3575
3591
|
type: "object",
|
|
3576
3592
|
description: "The tip (the shared brush engine). Missing fields keep their current values.",
|
|
3577
3593
|
properties: {
|
|
3578
|
-
size: { type: "number", minimum: 1, maximum:
|
|
3594
|
+
size: { type: "number", minimum: 1, maximum: _chunkHUFQD4CBcjs.MAX_BRUSH_SIZE, description: "Diameter in document pixels." },
|
|
3579
3595
|
hardness: { type: "number", minimum: 0, maximum: 1, description: "Edge hardness, 0 (soft) .. 1 (hard)." },
|
|
3580
3596
|
spacing: { type: "number", minimum: 0.01, maximum: 10, description: "Dab spacing as a fraction of the diameter (0.05 is smooth, 1 is dotted)." },
|
|
3581
3597
|
angle: { type: "number", minimum: -360, maximum: 360, description: "Tip angle in degrees, counter-clockwise; with rotation stroke or barrel it is added to the stroke direction or pen rotation." },
|
|
@@ -3585,7 +3601,11 @@ var TIP = {
|
|
|
3585
3601
|
smoothing: { type: "number", minimum: 0, maximum: 0.95, description: "Position smoothing of the input, 0..0.95." },
|
|
3586
3602
|
pressureSize: { type: "boolean", description: "Pressure scales the size (down to dynamics.minSize)." },
|
|
3587
3603
|
pressureOpacity: { type: "boolean", description: "Pressure scales the opacity." },
|
|
3588
|
-
blend: {
|
|
3604
|
+
blend: {
|
|
3605
|
+
type: "string",
|
|
3606
|
+
enum: _chunkSZ6KMZNMcjs.BLEND_MODES.map((m) => m.id),
|
|
3607
|
+
description: "How paint combines with the layer. pigment mixes it in like real paint (blue into yellow gives green); multiply darkens like marker ink; watercolor glazes like a transparent wash; tint, highlight and shadow recolour, light and shade (see list_blend_modes)."
|
|
3608
|
+
}
|
|
3589
3609
|
},
|
|
3590
3610
|
additionalProperties: false
|
|
3591
3611
|
};
|
|
@@ -3616,7 +3636,7 @@ var MIXER = {
|
|
|
3616
3636
|
mix: { type: "number", minimum: 0, maximum: 1, description: "How far each dab's paint moves from the reservoir towards the picked-up colour." },
|
|
3617
3637
|
loadEachStroke: { type: "boolean", description: "Refill the reservoir with the colour before each stroke." },
|
|
3618
3638
|
cleanEachStroke: { type: "boolean", description: "Empty the pickup well after each stroke." },
|
|
3619
|
-
mixing: { type: "string", enum: [...
|
|
3639
|
+
mixing: { type: "string", enum: [..._chunkHUFQD4CBcjs.MIXING_MODELS], description: "rgb: RGB averages. pigment: mixes like paint (Kubelka-Munk)." }
|
|
3620
3640
|
},
|
|
3621
3641
|
additionalProperties: false
|
|
3622
3642
|
};
|
|
@@ -3689,7 +3709,7 @@ function createPaintEditorToolProvider(controller, options = {}) {
|
|
|
3689
3709
|
strokes: d.strokes.length,
|
|
3690
3710
|
undo: s.undoLabel,
|
|
3691
3711
|
redo: s.redoLabel,
|
|
3692
|
-
blendModes:
|
|
3712
|
+
blendModes: _chunkSZ6KMZNMcjs.BLEND_MODES.map((m) => m.id)
|
|
3693
3713
|
};
|
|
3694
3714
|
}
|
|
3695
3715
|
});
|
|
@@ -3820,7 +3840,11 @@ function createPaintEditorToolProvider(controller, options = {}) {
|
|
|
3820
3840
|
name: { type: "string", minLength: 1, description: "New name." },
|
|
3821
3841
|
visible: { type: "boolean", description: "Show or hide." },
|
|
3822
3842
|
opacity: { type: "number", minimum: 0, maximum: 1, description: "Layer opacity 0..1." },
|
|
3823
|
-
blend: {
|
|
3843
|
+
blend: {
|
|
3844
|
+
type: "string",
|
|
3845
|
+
enum: [..._chunkSZ6KMZNMcjs.BLEND_MODES.map((m) => m.id), "pass-through"],
|
|
3846
|
+
description: "Blend mode (pass-through for groups only). Painterly modes: watercolor (the layer glazes like a transparent wash), tint (recolours keeping lightness), highlight (adds soft coloured light), shadow (shades with ambient fill); see list_blend_modes."
|
|
3847
|
+
},
|
|
3824
3848
|
clipped: { type: "boolean", description: "Clip to the layer below (paint only shows where it has paint)." },
|
|
3825
3849
|
locks: {
|
|
3826
3850
|
type: "object",
|
|
@@ -3840,6 +3864,22 @@ function createPaintEditorToolProvider(controller, options = {}) {
|
|
|
3840
3864
|
annotations: { title: "Change a layer", ...SET2 },
|
|
3841
3865
|
handler: ({ layerId, ...u }) => c.updateLayer(layerId, u)
|
|
3842
3866
|
});
|
|
3867
|
+
add({
|
|
3868
|
+
name: "list_blend_modes",
|
|
3869
|
+
title: "List blend modes",
|
|
3870
|
+
description: "Lists every layer and brush blend mode: id, label, group (standard Photoshop modes, pigment, or painterly), what the pigment and painterly modes do, and the standard mode PSD export writes in their place. Changes nothing. Read it before choosing a painterly mode for update_layer or a brush tip.",
|
|
3871
|
+
inputSchema: EMPTY2,
|
|
3872
|
+
annotations: { title: "List blend modes", ...READ2 },
|
|
3873
|
+
handler: () => ({
|
|
3874
|
+
modes: _chunkSZ6KMZNMcjs.BLEND_MODES.map((m) => ({
|
|
3875
|
+
id: m.id,
|
|
3876
|
+
label: m.label,
|
|
3877
|
+
group: m.painterly ? "painterly" : m.id === "pigment" ? "pigment" : "standard",
|
|
3878
|
+
...m.description ? { description: m.description } : {},
|
|
3879
|
+
psd: _chunkSZ6KMZNMcjs.standardBlendMode.call(void 0, m.id)
|
|
3880
|
+
}))
|
|
3881
|
+
})
|
|
3882
|
+
});
|
|
3843
3883
|
add({
|
|
3844
3884
|
name: "set_active_layer",
|
|
3845
3885
|
title: "Choose the active layer",
|
|
@@ -3904,7 +3944,7 @@ function createPaintEditorToolProvider(controller, options = {}) {
|
|
|
3904
3944
|
opacity: { type: "number", minimum: 0, maximum: 1, description: "Opacity 0..1 (default 1)." },
|
|
3905
3945
|
grain: { type: "number", minimum: 0, maximum: 1, description: "Paper grain response 0..1 (default 0: flat)." },
|
|
3906
3946
|
pressure: { type: "number", minimum: 0, maximum: 1, description: "With grain: how far into the valleys, 0..1 (default 0.5)." },
|
|
3907
|
-
blend: { type: "string", enum:
|
|
3947
|
+
blend: { type: "string", enum: _chunkSZ6KMZNMcjs.BLEND_MODES.map((m) => m.id), description: "Blend mode (default normal; pigment mixes like paint, watercolor glazes; see list_blend_modes)." }
|
|
3908
3948
|
},
|
|
3909
3949
|
additionalProperties: false
|
|
3910
3950
|
},
|
|
@@ -3927,7 +3967,7 @@ function createPaintEditorToolProvider(controller, options = {}) {
|
|
|
3927
3967
|
annotations: { title: "List brushes", ...READ2 },
|
|
3928
3968
|
handler: () => {
|
|
3929
3969
|
const s = c.getState();
|
|
3930
|
-
return { activeBrushId: s.brush.id, activeEdited: !s.brush.builtin && Boolean(_optionalChain([c, 'access',
|
|
3970
|
+
return { activeBrushId: s.brush.id, activeEdited: !s.brush.builtin && Boolean(_optionalChain([c, 'access', _87 => _87.getBrush, 'call', _88 => _88(s.brush.id), 'optionalAccess', _89 => _89.builtin])), brushes: s.brushes.map(brushSummary) };
|
|
3931
3971
|
}
|
|
3932
3972
|
});
|
|
3933
3973
|
add({
|
|
@@ -4025,7 +4065,7 @@ function createPaintEditorToolProvider(controller, options = {}) {
|
|
|
4025
4065
|
const t = c.brushThumbnail(_nullishCoalesce(id, () => ( c.getState().brush.id)), { width, height, color });
|
|
4026
4066
|
return {
|
|
4027
4067
|
content: [
|
|
4028
|
-
{ type: "image", data:
|
|
4068
|
+
{ type: "image", data: _chunkT3QZ6S47cjs.bytesToBase64.call(void 0, _chunkT3QZ6S47cjs.encodePng.call(void 0, t.width, t.height, t.data)), mimeType: "image/png" },
|
|
4029
4069
|
{ type: "text", text: `Brush ${_nullishCoalesce(id, () => ( c.getState().brush.id))} ${t.width}\xD7${t.height}` }
|
|
4030
4070
|
]
|
|
4031
4071
|
};
|
|
@@ -4146,7 +4186,7 @@ function createPaintEditorToolProvider(controller, options = {}) {
|
|
|
4146
4186
|
color: s.color,
|
|
4147
4187
|
points: ids ? s.points : s.points.length,
|
|
4148
4188
|
seed: s.seed,
|
|
4149
|
-
copies: _nullishCoalesce(_optionalChain([s, 'access',
|
|
4189
|
+
copies: _nullishCoalesce(_optionalChain([s, 'access', _90 => _90.copies, 'optionalAccess', _91 => _91.length]), () => ( 0)),
|
|
4150
4190
|
bounds: { x: Math.floor(Math.min(...xs) - pad), y: Math.floor(Math.min(...ys) - pad), width: Math.ceil(Math.max(...xs) - Math.min(...xs) + 2 * pad), height: Math.ceil(Math.max(...ys) - Math.min(...ys) + 2 * pad) }
|
|
4151
4191
|
};
|
|
4152
4192
|
})
|
|
@@ -4276,18 +4316,18 @@ function createPaintEditorToolProvider(controller, options = {}) {
|
|
|
4276
4316
|
annotations: { title: "Export the painting", ...READ2 },
|
|
4277
4317
|
handler: async ({ format, quality, scale, paper }) => {
|
|
4278
4318
|
const bytes = await c.exportImage({ format, quality, scale, paper });
|
|
4279
|
-
return { mimeType: _nullishCoalesce(format, () => ( "image/png")), bytes: bytes.length, data:
|
|
4319
|
+
return { mimeType: _nullishCoalesce(format, () => ( "image/png")), bytes: bytes.length, data: _chunkT3QZ6S47cjs.bytesToBase64.call(void 0, bytes) };
|
|
4280
4320
|
}
|
|
4281
4321
|
});
|
|
4282
4322
|
add({
|
|
4283
4323
|
name: "export_psd",
|
|
4284
4324
|
title: "Export as PSD",
|
|
4285
|
-
description: 'Writes the painting as an 8-bit RGB PSD (PSB above 30000 px) through the shared PSD writer: every layer and group with its opacity, blend, mask and locks, the paper as a locked "Paper" pixel layer at the bottom, and the composite as the merged image. Changes nothing. Returns the file as base64, its size, whether it is a PSB, and warnings (pigment
|
|
4325
|
+
description: 'Writes the painting as an 8-bit RGB PSD (PSB above 30000 px) through the shared PSD writer: every layer and group with its opacity, blend, mask and locks, the paper as a locked "Paper" pixel layer at the bottom, and the composite as the merged image. Changes nothing. Returns the file as base64, its size, whether it is a PSB, and warnings (pigment and painterly blend modes have no PSD equivalent: they are written as the nearest standard mode, see list_blend_modes).',
|
|
4286
4326
|
inputSchema: EMPTY2,
|
|
4287
4327
|
annotations: { title: "Export as PSD", ...READ2 },
|
|
4288
4328
|
handler: () => {
|
|
4289
4329
|
const r = c.exportPsd();
|
|
4290
|
-
return { data:
|
|
4330
|
+
return { data: _chunkT3QZ6S47cjs.bytesToBase64.call(void 0, r.bytes), bytes: r.bytes.length, psb: r.psb, warnings: r.warnings };
|
|
4291
4331
|
}
|
|
4292
4332
|
});
|
|
4293
4333
|
add({
|
|
@@ -4311,7 +4351,7 @@ function createPaintEditorToolProvider(controller, options = {}) {
|
|
|
4311
4351
|
}
|
|
4312
4352
|
});
|
|
4313
4353
|
tools.push(...createPaintGuideTools(c));
|
|
4314
|
-
tools.push(...
|
|
4354
|
+
tools.push(..._chunkHUFQD4CBcjs.createPigmentTools.call(void 0, ));
|
|
4315
4355
|
return { id: _nullishCoalesce(options.id, () => ( "paint-editor")), namespace: options.namespace, tools };
|
|
4316
4356
|
}
|
|
4317
4357
|
|
|
@@ -4417,12 +4457,12 @@ var PaintGesture = (_class10 = class {
|
|
|
4417
4457
|
if (!m || m.pointerId !== e.pointerId) return;
|
|
4418
4458
|
this.mode = null;
|
|
4419
4459
|
this.predicted = [];
|
|
4420
|
-
if (m.kind === "stroke") _optionalChain([this, 'access',
|
|
4460
|
+
if (m.kind === "stroke") _optionalChain([this, 'access', _92 => _92.controller, 'access', _93 => _93.activeStroke, 'optionalAccess', _94 => _94.end, 'call', _95 => _95()]);
|
|
4421
4461
|
}
|
|
4422
4462
|
cancel() {
|
|
4423
4463
|
this.penDown = false;
|
|
4424
4464
|
this.predicted = [];
|
|
4425
|
-
if (_optionalChain([this, 'access',
|
|
4465
|
+
if (_optionalChain([this, 'access', _96 => _96.mode, 'optionalAccess', _97 => _97.kind]) === "stroke") _optionalChain([this, 'access', _98 => _98.controller, 'access', _99 => _99.activeStroke, 'optionalAccess', _100 => _100.cancel, 'call', _101 => _101()]);
|
|
4426
4466
|
this.mode = null;
|
|
4427
4467
|
}
|
|
4428
4468
|
get active() {
|
|
@@ -4506,11 +4546,11 @@ var PaintCanvasPresenter = (_class11 = class {
|
|
|
4506
4546
|
const key = `${tx},${ty}`;
|
|
4507
4547
|
if (this.uploaded.get(key) === data) return;
|
|
4508
4548
|
this.uploaded.set(key, data);
|
|
4509
|
-
if (!this.scratch) this.scratch = ctx.createImageData(
|
|
4549
|
+
if (!this.scratch) this.scratch = ctx.createImageData(_chunkSZ6KMZNMcjs.TILE, _chunkSZ6KMZNMcjs.TILE);
|
|
4510
4550
|
this.scratch.data.set(data);
|
|
4511
|
-
const ox = tx *
|
|
4512
|
-
const oy = ty *
|
|
4513
|
-
ctx.putImageData(this.scratch, ox, oy, 0, 0, Math.min(
|
|
4551
|
+
const ox = tx * _chunkSZ6KMZNMcjs.TILE;
|
|
4552
|
+
const oy = ty * _chunkSZ6KMZNMcjs.TILE;
|
|
4553
|
+
ctx.putImageData(this.scratch, ox, oy, 0, 0, Math.min(_chunkSZ6KMZNMcjs.TILE, width - ox), Math.min(_chunkSZ6KMZNMcjs.TILE, height - oy));
|
|
4514
4554
|
drawn++;
|
|
4515
4555
|
}, { dirty });
|
|
4516
4556
|
return drawn;
|
|
@@ -4550,7 +4590,7 @@ var PAPER_SLIDERS = [
|
|
|
4550
4590
|
];
|
|
4551
4591
|
function readPath(obj, path) {
|
|
4552
4592
|
let v = obj;
|
|
4553
|
-
for (const k of path.split(".")) v = _optionalChain([v, 'optionalAccess',
|
|
4593
|
+
for (const k of path.split(".")) v = _optionalChain([v, 'optionalAccess', _102 => _102[k]]);
|
|
4554
4594
|
return typeof v === "number" ? v : 0;
|
|
4555
4595
|
}
|
|
4556
4596
|
function patchPath(obj, path, value) {
|
|
@@ -4591,6 +4631,14 @@ function wheelPick(dx, dy, wheel, color) {
|
|
|
4591
4631
|
const [nr, ng, nb] = hsvToRgb(wheelToHue(wheelAngle(dx, dy), wheel), s || 1, v || 1);
|
|
4592
4632
|
return rgbToHexColor(nr, ng, nb);
|
|
4593
4633
|
}
|
|
4634
|
+
var BLEND_MENU_GROUPS = [
|
|
4635
|
+
{ label: "Standard", modes: _chunkSZ6KMZNMcjs.BLEND_MODES.filter((m) => !m.painterly && m.id !== "pigment") },
|
|
4636
|
+
{ label: "Paint", modes: _chunkSZ6KMZNMcjs.BLEND_MODES.filter((m) => m.painterly || m.id === "pigment") }
|
|
4637
|
+
];
|
|
4638
|
+
|
|
4639
|
+
|
|
4640
|
+
|
|
4641
|
+
|
|
4594
4642
|
|
|
4595
4643
|
|
|
4596
4644
|
|
|
@@ -4729,5 +4777,5 @@ function wheelPick(dx, dy, wheel, color) {
|
|
|
4729
4777
|
|
|
4730
4778
|
|
|
4731
4779
|
|
|
4732
|
-
exports.BLEND_MODES =
|
|
4780
|
+
exports.BLEND_MENU_GROUPS = BLEND_MENU_GROUPS; exports.BLEND_MODES = _chunkSZ6KMZNMcjs.BLEND_MODES; exports.BRUSH_ID = BRUSH_ID; exports.BRUSH_ROTATIONS = BRUSH_ROTATIONS; exports.BRUSH_SLIDERS = BRUSH_SLIDERS; exports.BUILTIN_BRUSHES = BUILTIN_BRUSHES; exports.DEFAULT_BRUSH_ID = DEFAULT_BRUSH_ID; exports.DEFAULT_DPI = DEFAULT_DPI; exports.DEFAULT_DYNAMICS = DEFAULT_DYNAMICS; exports.DEFAULT_PAPER = DEFAULT_PAPER; exports.DEFAULT_SWATCHES = DEFAULT_SWATCHES; exports.DEFAULT_VIEW = DEFAULT_VIEW; exports.DryStroke = DryStroke; exports.GRAIN_PATTERNS = GRAIN_PATTERNS; exports.GRAIN_TILE = GRAIN_TILE; exports.HARMONY_KINDS = HARMONY_KINDS; exports.IDENTITY_AFFINE = IDENTITY_AFFINE; exports.IDENTITY_COPY = IDENTITY_COPY; exports.MAX_BRUSH_SIZE = _chunkHUFQD4CBcjs.MAX_BRUSH_SIZE; exports.MAX_CANVAS_SIDE = MAX_CANVAS_SIDE; exports.MAX_COORDINATE = MAX_COORDINATE; exports.MAX_IMAGE_SIDE = MAX_IMAGE_SIDE; exports.MAX_ZOOM = MAX_ZOOM; exports.MIN_CANVAS_SIDE = MIN_CANVAS_SIDE; exports.MIN_ZOOM = MIN_ZOOM; exports.MIXING_PAD_HEIGHT = MIXING_PAD_HEIGHT; exports.MIXING_PAD_WIDTH = MIXING_PAD_WIDTH; exports.MixingPad = MixingPad; exports.PAINTERLY_BLEND_MODES = _chunkSZ6KMZNMcjs.PAINTERLY_BLEND_MODES; exports.PAINT_BRUSH_CATEGORIES = PAINT_BRUSH_CATEGORIES; exports.PAINT_BRUSH_ENGINES = PAINT_BRUSH_ENGINES; exports.PAINT_FORMAT = PAINT_FORMAT; exports.PAINT_SCHEMA_VERSION = PAINT_SCHEMA_VERSION; exports.PAINT_TOOLS = PAINT_TOOLS; exports.PAPER_FAMILIES = PAPER_FAMILIES; exports.PAPER_LIBRARY = PAPER_LIBRARY; exports.PAPER_NODE_ID = PAPER_NODE_ID; exports.PAPER_SLIDERS = PAPER_SLIDERS; exports.PaintCanvasPresenter = PaintCanvasPresenter; exports.PaintDocumentError = PaintDocumentError; exports.PaintEditorController = PaintEditorController; exports.PaintEditorError = PaintEditorError; exports.PaintGesture = PaintGesture; exports.PaintStrokeSession = PaintStrokeSession; exports.PaperGrain = PaperGrain; exports.PenDabWalker = PenDabWalker; exports.PenSmoother = PenSmoother; exports.PerspectiveSnapper = PerspectiveSnapper; exports.SNAP_DECIDE_DISTANCE = SNAP_DECIDE_DISTANCE; exports.SYMMETRY_MODES = SYMMETRY_MODES; exports.TRACING_NODE_ID = TRACING_NODE_ID; exports.TileableNoise = TileableNoise; exports.affineCopy = affineCopy; exports.applyAffine = applyAffine; exports.brushToJSON = brushToJSON; exports.clonePaper = clonePaper; exports.colorHarmony = colorHarmony; exports.composeAffine = composeAffine; exports.createPaintCompositor = createPaintCompositor; exports.createPaintDocument = createPaintDocument; exports.createPaintEditorToolProvider = createPaintEditorToolProvider; exports.createPaintLayer = createPaintLayer; exports.decodeImageBlob = decodeImageBlob; exports.defaultGuides = defaultGuides; exports.defaultImageEncoder = defaultImageEncoder; exports.deserializePaintDocument = deserializePaintDocument; exports.deserializePaintDocumentAsync = deserializePaintDocumentAsync; exports.documentExtensions = documentExtensions; exports.documentToScreen = documentToScreen; exports.downloadBytes = downloadBytes; exports.downsampleRgba = downsampleRgba; exports.fitZoom = fitZoom; exports.grainCatch = grainCatch; exports.grainHeights = grainHeights; exports.guideOverlay = guideOverlay; exports.handlePaintShortcut = handlePaintShortcut; exports.hash2 = hash2; exports.hexToRgb8 = hexToRgb8; exports.hslToRgb = hslToRgb; exports.hsvToRgb = hsvToRgb; exports.hueToWheel = hueToWheel; exports.invertAffine = invertAffine; exports.isBlendMode = _chunkSZ6KMZNMcjs.isBlendMode; exports.isPainterlyBlendMode = _chunkSZ6KMZNMcjs.isPainterlyBlendMode; exports.isPalmTouch = isPalmTouch; exports.mapPenPoint = mapPenPoint; exports.mix32 = mix32; exports.mixerLoadForStroke = mixerLoadForStroke; exports.mixerTip = mixerTip; exports.newPaintLayerId = newPaintLayerId; exports.normalizeBrushStroke = normalizeBrushStroke; exports.normalizeCanvas = normalizeCanvas; exports.normalizeDynamics = normalizeDynamics; exports.normalizePaintBrush = normalizePaintBrush; exports.normalizePaper = normalizePaper; exports.normalizePerspective = normalizePerspective; exports.normalizeRotation = normalizeRotation; exports.normalizeSymmetry = normalizeSymmetry; exports.normalizeView = normalizeView; exports.paperGrain = paperGrain; exports.paperKey = paperKey; exports.paperNode = paperNode; exports.paperPreset = paperPreset; exports.parseBrushLibrary = parseBrushLibrary; exports.parseHexColor = parseHexColor; exports.patchPath = patchPath; exports.penOrientation = penOrientation; exports.perspectiveDirections = perspectiveDirections; exports.perspectiveGuideLines = perspectiveGuideLines; exports.pointerToPenPoint = pointerToPenPoint; exports.rand01 = rand01; exports.randSigned = randSigned; exports.readPath = readPath; exports.renderBrushThumbnail = renderBrushThumbnail; exports.renderColorWheel = renderColorWheel; exports.renderPaper = renderPaper; exports.rgbToHexColor = rgbToHexColor; exports.rgbToHsl = rgbToHsl; exports.rgbToHsv = rgbToHsv; exports.samplePressure = samplePressure; exports.screenToDocument = screenToDocument; exports.seedFromString = seedFromString; exports.serializePaintDocument = serializePaintDocument; exports.serializePaintDocumentExternal = serializePaintDocumentExternal; exports.standardBlendMode = _chunkSZ6KMZNMcjs.standardBlendMode; exports.strokeBounds = strokeBounds; exports.symmetryAxisAngles = symmetryAxisAngles; exports.symmetryAxisSegments = symmetryAxisSegments; exports.symmetryCopies = symmetryCopies; exports.thumbnailStroke = thumbnailStroke; exports.tiltToOrientation = tiltToOrientation; exports.toStrokePoint = toStrokePoint; exports.variationAffine = variationAffine; exports.varyStroke = varyStroke; exports.viewCssTransform = viewCssTransform; exports.viewMatrix = viewMatrix; exports.viewPenToDocument = viewPenToDocument; exports.wheelAngle = wheelAngle; exports.wheelPick = wheelPick; exports.wheelPoint = wheelPoint; exports.wheelToHue = wheelToHue;
|
|
4733
4781
|
//# sourceMappingURL=index.cjs.map
|