@pixerate/editor 0.275.1 → 0.276.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/animation-editor/index.cjs +62 -62
- package/dist/animation-editor/index.js +6 -6
- package/dist/brushes/index.cjs +81 -70
- package/dist/brushes/index.js +17 -6
- package/dist/brushes/patch.d.cts +1 -1
- package/dist/brushes/patch.d.ts +1 -1
- package/dist/brushes/profiles.d.cts +2 -0
- package/dist/brushes/profiles.d.ts +2 -0
- package/dist/brushes/schema.d.cts +1 -0
- package/dist/brushes/schema.d.ts +1 -0
- package/dist/brushes/types.d.cts +22 -1
- package/dist/brushes/types.d.ts +22 -1
- package/dist/{brushstrokeRender-WGY4DZHF.js → brushstrokeRender-FK3ASUUJ.js} +5 -5
- package/dist/{brushstrokeRender-2RQL46WB.cjs → brushstrokeRender-I6MYFCOU.cjs} +21 -21
- package/dist/canvas/index.cjs +13 -13
- package/dist/canvas/index.js +1 -1
- package/dist/{chunk-Y2ISSVPH.js → chunk-4EM5NGCL.js} +167 -9
- package/dist/{chunk-Y354ETAE.cjs → chunk-5HR5CSLC.cjs} +49 -49
- package/dist/{chunk-LMG57L5A.js → chunk-CTHWXW5M.js} +121 -8
- package/dist/{chunk-43XJC3PP.js → chunk-CVBTJVRN.js} +1 -1
- package/dist/{chunk-RJGW3RQS.js → chunk-GHYJAMMS.js} +1 -1
- package/dist/{chunk-NIBFKXMD.cjs → chunk-IFWLZZCW.cjs} +619 -2
- package/dist/{chunk-G5TCMKX5.js → chunk-IJ6NSWKM.js} +2 -2
- package/dist/{chunk-C6VB7CPY.cjs → chunk-ISCAJBPQ.cjs} +1 -1
- package/dist/{chunk-W6JDUXP3.js → chunk-J23JOHPR.js} +1 -1
- package/dist/{chunk-IEEY5RJV.js → chunk-JNMNM3SL.js} +1 -1
- package/dist/{chunk-HVO6XCI4.js → chunk-JPB65KQ6.js} +1 -1
- package/dist/{chunk-ACTHSQOI.js → chunk-LDZOXESA.js} +618 -1
- package/dist/{chunk-DHC4E2DU.cjs → chunk-MITQGHN3.cjs} +121 -8
- package/dist/{chunk-STLTOISW.cjs → chunk-NPPMKMCU.cjs} +17 -17
- package/dist/{chunk-75SYKUOT.js → chunk-OS6OG7DN.js} +1 -1
- package/dist/{chunk-OLZXXAER.cjs → chunk-OY24XRYF.cjs} +408 -250
- package/dist/{chunk-6QNDGMK7.cjs → chunk-Q33V5PEF.cjs} +123 -42
- package/dist/{chunk-JDXWLCXF.cjs → chunk-QNNZA3V5.cjs} +2 -2
- package/dist/{chunk-T6KNJVBP.cjs → chunk-U26LUXCJ.cjs} +35 -35
- package/dist/{chunk-62MFUHSI.cjs → chunk-UQXULAMQ.cjs} +16 -16
- package/dist/{chunk-RAPNRK4R.cjs → chunk-X7XBEX3O.cjs} +88 -88
- package/dist/{chunk-MSWLJI4G.js → chunk-XMSH66VU.js} +2 -2
- package/dist/{chunk-ZM7IKQ4X.js → chunk-XVPQNX7O.js} +89 -8
- package/dist/{chunk-YYZC2EQO.cjs → chunk-ZIE6EJGR.cjs} +23 -23
- package/dist/image-editor/index.cjs +880 -852
- package/dist/image-editor/index.js +36 -8
- package/dist/paint/index.cjs +33 -5
- package/dist/paint/index.d.cts +1 -0
- package/dist/paint/index.d.ts +1 -0
- package/dist/paint/index.js +32 -4
- package/dist/paint/live-patterns.d.cts +149 -0
- package/dist/paint/live-patterns.d.ts +149 -0
- package/dist/paint/wet/world.d.cts +13 -0
- package/dist/paint/wet/world.d.ts +13 -0
- package/dist/paint-editor/brush-model.d.cts +7 -1
- package/dist/paint-editor/brush-model.d.ts +7 -1
- package/dist/paint-editor/controller.d.cts +52 -0
- package/dist/paint-editor/controller.d.ts +52 -0
- package/dist/paint-editor/index.cjs +850 -510
- package/dist/paint-editor/index.js +355 -15
- package/dist/paint-editor/ui.d.cts +5 -1
- package/dist/paint-editor/ui.d.ts +5 -1
- package/dist/paint-editor/wet-tools.d.cts +42 -0
- package/dist/paint-editor/wet-tools.d.ts +42 -0
- package/dist/paint-editor/wet.d.cts +22 -1
- package/dist/paint-editor/wet.d.ts +22 -1
- package/dist/vector/index.cjs +1002 -1002
- package/dist/vector/index.js +7 -7
- package/package.json +1 -1
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
listPresets,
|
|
9
9
|
normalizeBrushSpec,
|
|
10
10
|
resolveBrush
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-XVPQNX7O.js";
|
|
12
12
|
import {
|
|
13
13
|
editorStampOf,
|
|
14
14
|
stampCoverage
|
|
@@ -74,17 +74,18 @@ import {
|
|
|
74
74
|
normalizeTilt,
|
|
75
75
|
normalizeWetParams,
|
|
76
76
|
pigmentOf
|
|
77
|
-
} from "./chunk-
|
|
77
|
+
} from "./chunk-CTHWXW5M.js";
|
|
78
78
|
import {
|
|
79
79
|
BrushstrokeCache,
|
|
80
80
|
brushstrokeDataUrl,
|
|
81
81
|
brushstrokeSamples,
|
|
82
82
|
isBrushstrokeBrush
|
|
83
|
-
} from "./chunk-
|
|
83
|
+
} from "./chunk-J23JOHPR.js";
|
|
84
84
|
import {
|
|
85
85
|
CoverageMap,
|
|
86
86
|
EMPTY_MIXER_LOAD,
|
|
87
87
|
GRAIN_PATTERNS,
|
|
88
|
+
LivePatternField,
|
|
88
89
|
PaintExchange,
|
|
89
90
|
PaintGradientSampler,
|
|
90
91
|
PaperGrain,
|
|
@@ -97,12 +98,14 @@ import {
|
|
|
97
98
|
grainCatch,
|
|
98
99
|
loadMixer,
|
|
99
100
|
mixerRates,
|
|
101
|
+
moveLivePatternSnapshot,
|
|
102
|
+
normalizeLivePatterns,
|
|
100
103
|
parsePaintSource,
|
|
101
104
|
rasterizeDab,
|
|
102
105
|
readPaintSource,
|
|
103
106
|
resolvePaintGradient,
|
|
104
107
|
scalePaintGradient
|
|
105
|
-
} from "./chunk-
|
|
108
|
+
} from "./chunk-LDZOXESA.js";
|
|
106
109
|
import {
|
|
107
110
|
rand01,
|
|
108
111
|
randSigned
|
|
@@ -3914,6 +3917,17 @@ var WetStrokeDriver = class {
|
|
|
3914
3917
|
} else world.paint(laneId, rect, cov, this.medium.options.water * k, null);
|
|
3915
3918
|
ex.drain();
|
|
3916
3919
|
if (wet.rewet > 0) world.rewet(laneId, rect, cov, wet.rewet * k * 0.15, this.init.paperColor);
|
|
3920
|
+
if (brush.livePatterns) {
|
|
3921
|
+
world.seedLivePatterns(
|
|
3922
|
+
laneId,
|
|
3923
|
+
d.x,
|
|
3924
|
+
d.y,
|
|
3925
|
+
Math.max(2, d.radius),
|
|
3926
|
+
this.init.seed + this.dabCount * 131 + copy * 997 | 0,
|
|
3927
|
+
Math.max(0.65, d.pressure),
|
|
3928
|
+
brush.livePatterns
|
|
3929
|
+
);
|
|
3930
|
+
}
|
|
3917
3931
|
break;
|
|
3918
3932
|
}
|
|
3919
3933
|
case "water": {
|
|
@@ -3966,6 +3980,7 @@ var PaintWetLayers = class {
|
|
|
3966
3980
|
world = null;
|
|
3967
3981
|
tilt = { ...FLAT };
|
|
3968
3982
|
settings = /* @__PURE__ */ new Map();
|
|
3983
|
+
patterns = /* @__PURE__ */ new Map();
|
|
3969
3984
|
paused = false;
|
|
3970
3985
|
/** Wet strokes dry as soon as they end (one undo step with the stroke). */
|
|
3971
3986
|
instantDry = false;
|
|
@@ -4072,6 +4087,14 @@ var PaintWetLayers = class {
|
|
|
4072
4087
|
extend(width, height, left2, top, paper) {
|
|
4073
4088
|
if (!this.canExtend(left2, top)) throw new Error("Wet paint only moves by whole 256 px tiles, between strokes.");
|
|
4074
4089
|
for (const [id, s] of this.settings) if (s.flow.center) this.settings.set(id, { ...s, flow: { ...s.flow, center: { x: s.flow.center.x + left2, y: s.flow.center.y + top } } });
|
|
4090
|
+
const tx0 = left2 / WET_TILE;
|
|
4091
|
+
const ty0 = top / WET_TILE;
|
|
4092
|
+
for (const [id, f] of this.patterns) {
|
|
4093
|
+
const moved2 = moveLivePatternSnapshot(f.snapshot(), { width, height }, tx0, ty0);
|
|
4094
|
+
const next = new LivePatternField(width, height);
|
|
4095
|
+
next.restore(moved2);
|
|
4096
|
+
this.patterns.set(id, next);
|
|
4097
|
+
}
|
|
4075
4098
|
const old = this.world;
|
|
4076
4099
|
const snap = old?.laneIds().length ? old.snapshot() : null;
|
|
4077
4100
|
this.dropWorld();
|
|
@@ -4088,6 +4111,7 @@ var PaintWetLayers = class {
|
|
|
4088
4111
|
});
|
|
4089
4112
|
this.world = this.makeWorld(width, height, paper);
|
|
4090
4113
|
this.world.restore(moved);
|
|
4114
|
+
for (const id of this.world.laneIds()) this.patterns.set(id, this.world.livePatternField(id));
|
|
4091
4115
|
}
|
|
4092
4116
|
/** Whether any layer (or `layerId`) has wet paint. */
|
|
4093
4117
|
isWet(layerId) {
|
|
@@ -4111,18 +4135,32 @@ var PaintWetLayers = class {
|
|
|
4111
4135
|
settingsOf(layerId, medium = "watercolor") {
|
|
4112
4136
|
let s = this.settings.get(layerId);
|
|
4113
4137
|
if (!s) {
|
|
4114
|
-
s = { params: normalizeWetParams(WET_MEDIUM_PARAMS[medium], DEFAULT_WET_PARAMS), flow: { ...DEFAULT_FLOW } };
|
|
4138
|
+
s = { params: normalizeWetParams(WET_MEDIUM_PARAMS[medium], DEFAULT_WET_PARAMS), flow: { ...DEFAULT_FLOW }, livePatterns: null };
|
|
4115
4139
|
this.settings.set(layerId, s);
|
|
4116
4140
|
}
|
|
4117
4141
|
return s;
|
|
4118
4142
|
}
|
|
4143
|
+
patternFieldOf(layerId) {
|
|
4144
|
+
const { width, height } = this.host.canvas();
|
|
4145
|
+
let f = this.patterns.get(layerId);
|
|
4146
|
+
if (!f) {
|
|
4147
|
+
f = new LivePatternField(width, height);
|
|
4148
|
+
const s = this.settings.get(layerId)?.livePatterns;
|
|
4149
|
+
if (s) f.configure(s);
|
|
4150
|
+
this.patterns.set(layerId, f);
|
|
4151
|
+
} else if (f.width !== width || f.height !== height) {
|
|
4152
|
+
f.resize(width, height);
|
|
4153
|
+
}
|
|
4154
|
+
return f;
|
|
4155
|
+
}
|
|
4119
4156
|
/** Puts a layer in the world (its current pixels become the base under the wet paint). */
|
|
4120
4157
|
ensureLane(layerId, medium) {
|
|
4121
4158
|
const w = this.ensureWorld();
|
|
4159
|
+
const lp = this.patternFieldOf(layerId);
|
|
4122
4160
|
if (!w.hasLane(layerId)) {
|
|
4123
4161
|
const base = this.host.layerSurface(layerId) ?? new TiledSurface(4, /* @__PURE__ */ new Map(), 0);
|
|
4124
4162
|
const s = this.settingsOf(layerId, medium);
|
|
4125
|
-
w.ensureLane(layerId, { params: s.params, base, light: this.host.layerLight(layerId), ghost: s.ghost });
|
|
4163
|
+
w.ensureLane(layerId, { params: s.params, base, light: this.host.layerLight(layerId), ghost: s.ghost, livePatterns: lp });
|
|
4126
4164
|
const { width, height } = this.host.canvas();
|
|
4127
4165
|
if (s.flow.kind !== "none") w.setFlow(layerId, flowField(s.flow, width, height), s.flow.strength);
|
|
4128
4166
|
}
|
|
@@ -4143,6 +4181,65 @@ var PaintWetLayers = class {
|
|
|
4143
4181
|
}
|
|
4144
4182
|
return { ...s.flow };
|
|
4145
4183
|
}
|
|
4184
|
+
setLivePatterns(layerId, update) {
|
|
4185
|
+
const s = this.settingsOf(layerId);
|
|
4186
|
+
const f = this.patternFieldOf(layerId);
|
|
4187
|
+
if (update === null) {
|
|
4188
|
+
f.clear();
|
|
4189
|
+
s.livePatterns = null;
|
|
4190
|
+
if (this.world?.hasLane(layerId)) this.syncDisplays();
|
|
4191
|
+
return null;
|
|
4192
|
+
}
|
|
4193
|
+
const next = this.world?.hasLane(layerId) ? this.world.setLivePatterns(layerId, update) : f.configure(update);
|
|
4194
|
+
s.livePatterns = { ...next };
|
|
4195
|
+
this.syncDisplays();
|
|
4196
|
+
return { ...next };
|
|
4197
|
+
}
|
|
4198
|
+
seedLivePatterns(layerId, points, radius, seed = 1, settings) {
|
|
4199
|
+
const s = this.settingsOf(layerId);
|
|
4200
|
+
const f = this.patternFieldOf(layerId);
|
|
4201
|
+
if (settings) {
|
|
4202
|
+
const next = this.world?.hasLane(layerId) ? this.world.setLivePatterns(layerId, settings) : f.configure(settings);
|
|
4203
|
+
s.livePatterns = { ...next };
|
|
4204
|
+
} else if (!f.enabled) {
|
|
4205
|
+
const next = this.world?.hasLane(layerId) ? this.world.setLivePatterns(layerId, s.livePatterns ?? {}) : f.configure(s.livePatterns ?? {});
|
|
4206
|
+
s.livePatterns = { ...next };
|
|
4207
|
+
}
|
|
4208
|
+
let seededCells = 0;
|
|
4209
|
+
const hasLane = Boolean(this.world?.hasLane(layerId));
|
|
4210
|
+
for (let i = 0; i < points.length; i++) {
|
|
4211
|
+
const p = points[i];
|
|
4212
|
+
const str = p.strength ?? 1;
|
|
4213
|
+
const ptSeed = seed + i * 7919 | 0;
|
|
4214
|
+
if (hasLane) {
|
|
4215
|
+
seededCells += this.world.seedLivePatterns(layerId, p.x, p.y, radius, ptSeed, str);
|
|
4216
|
+
} else {
|
|
4217
|
+
seededCells += f.seedDisc(p.x, p.y, radius, ptSeed, str);
|
|
4218
|
+
}
|
|
4219
|
+
}
|
|
4220
|
+
this.syncDisplays();
|
|
4221
|
+
return { seededCells, stats: this.livePatternStats(layerId) };
|
|
4222
|
+
}
|
|
4223
|
+
livePatternStats(layerId) {
|
|
4224
|
+
const f = this.patterns.get(layerId);
|
|
4225
|
+
if (f?.enabled) {
|
|
4226
|
+
const s = this.settingsOf(layerId);
|
|
4227
|
+
if (!s.livePatterns) s.livePatterns = { ...f.settings };
|
|
4228
|
+
}
|
|
4229
|
+
if (this.world?.hasLane(layerId)) return this.world.livePatternStats(layerId);
|
|
4230
|
+
if (f) return f.stats(() => false);
|
|
4231
|
+
const cfg = this.settings.get(layerId)?.livePatterns ?? null;
|
|
4232
|
+
return {
|
|
4233
|
+
enabled: Boolean(cfg),
|
|
4234
|
+
settings: normalizeLivePatterns(cfg ?? {}),
|
|
4235
|
+
activeTiles: 0,
|
|
4236
|
+
patternCells: 0,
|
|
4237
|
+
wetPatternCells: 0,
|
|
4238
|
+
meanV: 0,
|
|
4239
|
+
maxV: 0,
|
|
4240
|
+
bounds: null
|
|
4241
|
+
};
|
|
4242
|
+
}
|
|
4146
4243
|
setTilt(update) {
|
|
4147
4244
|
this.tilt = normalizeTilt(update, this.tilt);
|
|
4148
4245
|
this.world?.setTilt(this.tilt);
|
|
@@ -4155,6 +4252,8 @@ var PaintWetLayers = class {
|
|
|
4155
4252
|
/** A layer as tools describe it. */
|
|
4156
4253
|
info(layerId) {
|
|
4157
4254
|
const s = this.settingsOf(layerId);
|
|
4255
|
+
const f = this.patterns.get(layerId);
|
|
4256
|
+
if (f?.enabled && !s.livePatterns) s.livePatterns = { ...f.settings };
|
|
4158
4257
|
const st = this.world?.hasLane(layerId) ? this.world.stats(layerId) : null;
|
|
4159
4258
|
const g = this.world?.hasLane(layerId) ? this.world.getGhost(layerId) : s.ghost ?? null;
|
|
4160
4259
|
return {
|
|
@@ -4165,6 +4264,7 @@ var PaintWetLayers = class {
|
|
|
4165
4264
|
activeTiles: st?.activeTiles ?? 0,
|
|
4166
4265
|
params: { ...s.params },
|
|
4167
4266
|
flow: { ...s.flow },
|
|
4267
|
+
livePatterns: s.livePatterns ? { ...s.livePatterns } : null,
|
|
4168
4268
|
...g ? { ghost: { remaining: Math.round(g.remaining * FREE_INTERVAL / this.speed * 100) / 100 } } : {}
|
|
4169
4269
|
};
|
|
4170
4270
|
}
|
|
@@ -4174,10 +4274,13 @@ var PaintWetLayers = class {
|
|
|
4174
4274
|
/** Shows the current wet pixels (at most `maxTiles` reshaded per layer). */
|
|
4175
4275
|
syncDisplays(maxTiles = Infinity) {
|
|
4176
4276
|
const w = this.world;
|
|
4277
|
+
this.syncHeights();
|
|
4177
4278
|
if (!w) return [];
|
|
4178
4279
|
const surfaces = /* @__PURE__ */ new Map();
|
|
4179
4280
|
const rects = [];
|
|
4180
4281
|
for (const id of w.laneIds()) {
|
|
4282
|
+
const f = this.patterns.get(id);
|
|
4283
|
+
if (f?.enabled) this.settingsOf(id).livePatterns = { ...f.settings };
|
|
4181
4284
|
const d = w.display(id, maxTiles);
|
|
4182
4285
|
if (this.host.layerSurface(id) !== d.surface) surfaces.set(id, d.surface);
|
|
4183
4286
|
rects.push(...d.changed);
|
|
@@ -4189,10 +4292,13 @@ var PaintWetLayers = class {
|
|
|
4189
4292
|
/** Like `syncDisplays`, shading on the GPU when Engine B is active (all stale tiles at once). */
|
|
4190
4293
|
async syncDisplaysGpu(maxCpuTiles, lead = false) {
|
|
4191
4294
|
const w = this.world;
|
|
4295
|
+
this.syncHeights();
|
|
4192
4296
|
if (!w) return [];
|
|
4193
4297
|
const surfaces = /* @__PURE__ */ new Map();
|
|
4194
4298
|
const rects = [];
|
|
4195
4299
|
for (const id of w.laneIds()) {
|
|
4300
|
+
const f = this.patterns.get(id);
|
|
4301
|
+
if (f?.enabled) this.settingsOf(id).livePatterns = { ...f.settings };
|
|
4196
4302
|
const d = await w.displayGpu(id, maxCpuTiles, lead);
|
|
4197
4303
|
if (!w.hasLane(id)) continue;
|
|
4198
4304
|
if (this.host.layerSurface(id) !== d.surface) surfaces.set(id, d.surface);
|
|
@@ -4202,6 +4308,18 @@ var PaintWetLayers = class {
|
|
|
4202
4308
|
if (surfaces.size) this.host.updateSurfaces(surfaces, rects);
|
|
4203
4309
|
return rects;
|
|
4204
4310
|
}
|
|
4311
|
+
/** Updates thick height maps for any layers with live pattern relief (`relief > 0`). */
|
|
4312
|
+
syncHeights() {
|
|
4313
|
+
if (!this.host.layerHeight || !this.host.updateHeights) return;
|
|
4314
|
+
const heights = /* @__PURE__ */ new Map();
|
|
4315
|
+
for (const [id, f] of this.patterns) {
|
|
4316
|
+
if (!f.enabled || !(f.settings.relief > 0) || f.tiles.size === 0) continue;
|
|
4317
|
+
const cur = this.host.layerHeight(id) ?? new TiledSurface(1, /* @__PURE__ */ new Map(), 0);
|
|
4318
|
+
const next = f.applyReliefHeight(cur);
|
|
4319
|
+
if (next !== cur) heights.set(id, next);
|
|
4320
|
+
}
|
|
4321
|
+
if (heights.size) this.host.updateHeights(heights);
|
|
4322
|
+
}
|
|
4205
4323
|
/** Shows each wet layer's live light paint (the light under it with the wet light shaded in). */
|
|
4206
4324
|
syncLights() {
|
|
4207
4325
|
const w = this.world;
|
|
@@ -4376,18 +4494,57 @@ var PaintWetLayers = class {
|
|
|
4376
4494
|
/** A snapshot of the world for undo (`null` when there is none). */
|
|
4377
4495
|
snapshot() {
|
|
4378
4496
|
const w = this.world;
|
|
4379
|
-
|
|
4380
|
-
|
|
4497
|
+
const patterns = /* @__PURE__ */ new Map();
|
|
4498
|
+
let patternBytes = 0;
|
|
4499
|
+
for (const [id, f] of this.patterns) {
|
|
4500
|
+
if (!f.enabled && f.tiles.size === 0) continue;
|
|
4501
|
+
const ps = f.snapshot();
|
|
4502
|
+
patterns.set(id, ps);
|
|
4503
|
+
patternBytes += ps.bytes;
|
|
4504
|
+
}
|
|
4505
|
+
if (!w || !w.laneIds().length) {
|
|
4506
|
+
if (!patterns.size) return null;
|
|
4507
|
+
return {
|
|
4508
|
+
clock: w?.clock ?? 0,
|
|
4509
|
+
tilt: { ...this.tilt },
|
|
4510
|
+
lanes: [],
|
|
4511
|
+
slots: /* @__PURE__ */ new Map(),
|
|
4512
|
+
patterns,
|
|
4513
|
+
bytes: patternBytes
|
|
4514
|
+
};
|
|
4515
|
+
}
|
|
4516
|
+
const snap = w.snapshot();
|
|
4517
|
+
return patterns.size ? { ...snap, patterns } : snap;
|
|
4381
4518
|
}
|
|
4382
4519
|
/** Puts a snapshot back (`null`: no wet layers). Returns the layer surfaces it implies. */
|
|
4383
4520
|
restore(snap) {
|
|
4521
|
+
this.patterns.clear();
|
|
4522
|
+
for (const [, s] of this.settings) s.livePatterns = null;
|
|
4384
4523
|
if (!snap) {
|
|
4385
4524
|
if (this.world) for (const id of this.world.laneIds()) this.world.removeLane(id);
|
|
4386
4525
|
return;
|
|
4387
4526
|
}
|
|
4388
4527
|
const { width, height } = this.host.canvas();
|
|
4389
4528
|
if (this.world && (this.world.width !== width || this.world.height !== height)) this.dropWorld();
|
|
4390
|
-
|
|
4529
|
+
if (snap.patterns) {
|
|
4530
|
+
for (const [id, ps] of snap.patterns) {
|
|
4531
|
+
const f = new LivePatternField(width, height);
|
|
4532
|
+
f.restore(ps);
|
|
4533
|
+
this.patterns.set(id, f);
|
|
4534
|
+
this.settingsOf(id).livePatterns = f.enabled ? { ...f.settings } : null;
|
|
4535
|
+
}
|
|
4536
|
+
}
|
|
4537
|
+
if (snap.lanes.length) {
|
|
4538
|
+
const w = this.ensureWorld();
|
|
4539
|
+
w.restore(snap);
|
|
4540
|
+
for (const id of w.laneIds()) {
|
|
4541
|
+
const f = w.livePatternField(id);
|
|
4542
|
+
this.patterns.set(id, f);
|
|
4543
|
+
this.settingsOf(id).livePatterns = f.enabled ? { ...f.settings } : null;
|
|
4544
|
+
}
|
|
4545
|
+
} else if (this.world) {
|
|
4546
|
+
for (const id of this.world.laneIds()) this.world.removeLane(id);
|
|
4547
|
+
}
|
|
4391
4548
|
this.syncDisplays();
|
|
4392
4549
|
}
|
|
4393
4550
|
dropWorld() {
|
|
@@ -4401,6 +4558,7 @@ var PaintWetLayers = class {
|
|
|
4401
4558
|
this.world = null;
|
|
4402
4559
|
this.driver = null;
|
|
4403
4560
|
this.settings.clear();
|
|
4561
|
+
this.patterns.clear();
|
|
4404
4562
|
this.lastTick = null;
|
|
4405
4563
|
this.stepsOwed = 0;
|
|
4406
4564
|
}
|
|
@@ -27,7 +27,7 @@ var _chunkPFHJS4HEcjs = require('./chunk-PFHJS4HE.cjs');
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
var
|
|
30
|
+
var _chunkQ33V5PEFcjs = require('./chunk-Q33V5PEF.cjs');
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
var _chunkW5M3J7PVcjs = require('./chunk-W5M3J7PV.cjs');
|
|
@@ -38,13 +38,13 @@ var _chunkXFM3OCHUcjs = require('./chunk-XFM3OCHU.cjs');
|
|
|
38
38
|
// src/brushes/patch.ts
|
|
39
39
|
var isObject = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
40
40
|
var copy = (v) => JSON.parse(JSON.stringify(v));
|
|
41
|
-
var FACETS =
|
|
41
|
+
var FACETS = _chunkQ33V5PEFcjs.BRUSH_JSON_SCHEMA.properties;
|
|
42
42
|
var BRUSH_PATCH_PROPERTIES = (() => {
|
|
43
43
|
const { id: _id, name: _name, ...rest } = FACETS;
|
|
44
44
|
const { required: _r, ...tip } = rest.tip;
|
|
45
45
|
return { ...rest, tip: { ...tip, description: `${tip.description} In a patch, shape may be left out to keep it.` } };
|
|
46
46
|
})();
|
|
47
|
-
var UNSETTABLE_BRUSH_FACETS = ["description", "tags", "medium", "variety", "marks", "dynamics", "behaviour", "light", "fluorescence", "thermochromic", "iridescence", "ghost", "mutation", "motion", "colour"];
|
|
47
|
+
var UNSETTABLE_BRUSH_FACETS = ["description", "tags", "medium", "variety", "marks", "dynamics", "behaviour", "light", "fluorescence", "thermochromic", "iridescence", "ghost", "mutation", "motion", "livePatterns", "colour"];
|
|
48
48
|
var BRUSH_UNSET_PROPERTY = {
|
|
49
49
|
type: "array",
|
|
50
50
|
minItems: 1,
|
|
@@ -557,7 +557,7 @@ function idMaker(prefix) {
|
|
|
557
557
|
return (name) => {
|
|
558
558
|
const base = `${prefix}-${slug(name, 20) || "brush"}`.slice(0, 58).replace(/-+$/, "");
|
|
559
559
|
let id = base;
|
|
560
|
-
for (let n = 2; used.has(id) || !
|
|
560
|
+
for (let n = 2; used.has(id) || !_chunkQ33V5PEFcjs.BRUSH_ID.test(id); n++) id = `${base}-${n}`;
|
|
561
561
|
used.add(id);
|
|
562
562
|
return id;
|
|
563
563
|
};
|
|
@@ -582,9 +582,9 @@ function readAbrPack(bytes, name, prefix, licence, pack) {
|
|
|
582
582
|
return;
|
|
583
583
|
}
|
|
584
584
|
try {
|
|
585
|
-
const source =
|
|
585
|
+
const source = _chunkQ33V5PEFcjs.brushSourceFromMask.call(void 0, { id: `${brushId}-shape`, name: label, licence, origin: `${name}.abr` }, tip.width, tip.height, tip.mask);
|
|
586
586
|
pack.sources.push(source);
|
|
587
|
-
pack.brushes.push({ ...base, tip: { shape: "stamp", size: clamp2(Math.max(tip.width, tip.height), 1, 2500), spacing: _nullishCoalesce(tip.spacing, () => ( 0.25)), stamps: [
|
|
587
|
+
pack.brushes.push({ ...base, tip: { shape: "stamp", size: clamp2(Math.max(tip.width, tip.height), 1, 2500), spacing: _nullishCoalesce(tip.spacing, () => ( 0.25)), stamps: [_chunkQ33V5PEFcjs.brushSourceRef.call(void 0, source.id)] } });
|
|
588
588
|
} catch (e) {
|
|
589
589
|
pack.unsupported.push(`"${label}": ${e.message}`);
|
|
590
590
|
}
|
|
@@ -626,7 +626,7 @@ function readProcreatePack(bytes, name, prefix, licence, pack) {
|
|
|
626
626
|
const e = byName.get(`${dir}${file}`);
|
|
627
627
|
if (!e) return null;
|
|
628
628
|
try {
|
|
629
|
-
const s =
|
|
629
|
+
const s = _chunkQ33V5PEFcjs.makeBrushSource.call(void 0, { id: `${brushId}-${kind}`, name: `${label} ${kind}`, image: e.read(), channel: "lightness", licence: [licence, terms].filter(Boolean).join("\n\n") || void 0, origin: `${where}/${file}` });
|
|
630
630
|
pack.sources.push(s);
|
|
631
631
|
return s;
|
|
632
632
|
} catch (err) {
|
|
@@ -647,8 +647,8 @@ function readProcreatePack(bytes, name, prefix, licence, pack) {
|
|
|
647
647
|
shape: shape ? "stamp" : "round",
|
|
648
648
|
size: 40,
|
|
649
649
|
...plot !== void 0 ? { spacing: plot } : {},
|
|
650
|
-
...shape ? { stamps: [
|
|
651
|
-
...grain ? { grain: { source:
|
|
650
|
+
...shape ? { stamps: [_chunkQ33V5PEFcjs.brushSourceRef.call(void 0, shape.id)] } : {},
|
|
651
|
+
...grain ? { grain: { source: _chunkQ33V5PEFcjs.brushSourceRef.call(void 0, grain.id), mode: "moving" } } : {}
|
|
652
652
|
}
|
|
653
653
|
});
|
|
654
654
|
if (!settings) pack.unsupported.push(`"${label}": its Brush.archive could not be read; the brush takes its name from the file and default settings.`);
|
|
@@ -702,17 +702,17 @@ async function importBrushFile(library, file, options = {}) {
|
|
|
702
702
|
// src/brushes/tools.ts
|
|
703
703
|
var READ = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false };
|
|
704
704
|
var WRITE = { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false };
|
|
705
|
-
var FACETS2 =
|
|
705
|
+
var FACETS2 = _chunkQ33V5PEFcjs.BRUSH_JSON_SCHEMA.properties;
|
|
706
706
|
var ID = { type: "string", pattern: String(FACETS2.id.pattern), description: "Brush id from list_brush_presets (lowercase letters, digits and dashes)." };
|
|
707
707
|
var FACET_PROPS = BRUSH_PATCH_PROPERTIES;
|
|
708
|
-
var HOSTS = Object.keys(
|
|
708
|
+
var HOSTS = Object.keys(_chunkQ33V5PEFcjs.BRUSH_HOST_PROFILES);
|
|
709
709
|
var copy2 = (v) => JSON.parse(JSON.stringify(v));
|
|
710
710
|
var merge = mergeBrushPatch;
|
|
711
711
|
var changedPaths = changedBrushPaths;
|
|
712
712
|
function summary(entry, profile, withCheck) {
|
|
713
713
|
const b = entry.brush;
|
|
714
|
-
const engine =
|
|
715
|
-
const check = withCheck ?
|
|
714
|
+
const engine = _chunkQ33V5PEFcjs.resolveEngine.call(void 0, b);
|
|
715
|
+
const check = withCheck ? _chunkQ33V5PEFcjs.checkBrush.call(void 0, b, profile) : null;
|
|
716
716
|
return {
|
|
717
717
|
id: b.id,
|
|
718
718
|
name: b.name,
|
|
@@ -721,7 +721,7 @@ function summary(entry, profile, withCheck) {
|
|
|
721
721
|
...b.medium ? { medium: b.medium } : {},
|
|
722
722
|
...b.variety ? { variety: b.variety } : {},
|
|
723
723
|
...b.tool ? { tool: b.tool } : {},
|
|
724
|
-
category:
|
|
724
|
+
category: _chunkQ33V5PEFcjs.resolveCategory.call(void 0, b, engine),
|
|
725
725
|
engine,
|
|
726
726
|
tip: b.tip.shape,
|
|
727
727
|
...b.tip.size !== void 0 ? { size: b.tip.size } : {},
|
|
@@ -735,33 +735,33 @@ function summary(entry, profile, withCheck) {
|
|
|
735
735
|
var refusal = (check, host) => `${host.name} can't use this brush: ${check.issues.filter((i) => i.severity === "error").map((i) => `${i.facet}: ${i.reason} ${i.fix}`).join(" ")} (check_brush lists every issue; nothing was saved.)`;
|
|
736
736
|
var warnings = (check) => check.issues.filter((i) => i.severity === "warning");
|
|
737
737
|
function createBrushLibraryTools(library, options = {}) {
|
|
738
|
-
const profile = _nullishCoalesce(options.profile, () => (
|
|
738
|
+
const profile = _nullishCoalesce(options.profile, () => ( _chunkQ33V5PEFcjs.PAINT_PROFILE));
|
|
739
739
|
const hostOf = (id) => {
|
|
740
740
|
if (id === void 0) return profile;
|
|
741
|
-
const p =
|
|
742
|
-
if (!p) throw new (0,
|
|
741
|
+
const p = _chunkQ33V5PEFcjs.BRUSH_HOST_PROFILES[id];
|
|
742
|
+
if (!p) throw new (0, _chunkQ33V5PEFcjs.BrushLibraryError)("invalid", `No host "${id}"; use one of: ${HOSTS.join(", ")}.`);
|
|
743
743
|
return p;
|
|
744
744
|
};
|
|
745
745
|
const entry = async (id) => {
|
|
746
746
|
const found = await library.get(id);
|
|
747
747
|
if (found) return found;
|
|
748
748
|
const ids = (await library.list()).map((e) => e.brush.id);
|
|
749
|
-
throw new (0,
|
|
749
|
+
throw new (0, _chunkQ33V5PEFcjs.BrushLibraryError)("unknown_brush", `No brush "${id}". ${_chunkQ33V5PEFcjs.closest.call(void 0, id, ids)}list_brush_presets lists them.`);
|
|
750
750
|
};
|
|
751
751
|
const checkFor = async (brush, p) => {
|
|
752
|
-
const check2 =
|
|
752
|
+
const check2 = _chunkQ33V5PEFcjs.checkBrush.call(void 0, brush, p);
|
|
753
753
|
const issues = [...check2.issues];
|
|
754
754
|
const refs = [...(_nullishCoalesce(brush.tip.stamps, () => ( []))).map((r) => ["tip.stamps", r]), ...brush.tip.grain ? [["tip.grain.source", brush.tip.grain.source]] : []];
|
|
755
755
|
for (const [facet, ref] of refs) {
|
|
756
|
-
const id =
|
|
756
|
+
const id = _chunkQ33V5PEFcjs.brushSourceIdOf.call(void 0, ref);
|
|
757
757
|
if (id === null || await library.getSource(id)) continue;
|
|
758
758
|
const ids = (await library.listSources()).map((x) => x.id);
|
|
759
|
-
issues.push({ facet, severity: "error", reason: `There is no image source "${id}" in the brush library. ${
|
|
759
|
+
issues.push({ facet, severity: "error", reason: `There is no image source "${id}" in the brush library. ${_chunkQ33V5PEFcjs.closest.call(void 0, id, ids)}`.trim(), fix: "Add it with add_brush_source, or use a ref list_brush_sources lists." });
|
|
760
760
|
}
|
|
761
761
|
const provider = _optionalChain([options, 'access', _24 => _24.stickers, 'optionalCall', _25 => _25()]);
|
|
762
762
|
if (!provider || brush.tip.shape !== "stamp") return { ok: !issues.some((i) => i.severity === "error"), issues };
|
|
763
763
|
for (const ref of _nullishCoalesce(brush.tip.stamps, () => ( []))) {
|
|
764
|
-
if (ref.startsWith("editor:") ||
|
|
764
|
+
if (ref.startsWith("editor:") || _chunkQ33V5PEFcjs.isBrushSourceRef.call(void 0, ref)) continue;
|
|
765
765
|
try {
|
|
766
766
|
await _chunkPFHJS4HEcjs.describeStickerRef.call(void 0, provider, ref);
|
|
767
767
|
} catch (e) {
|
|
@@ -774,12 +774,12 @@ function createBrushLibraryTools(library, options = {}) {
|
|
|
774
774
|
const problems = [];
|
|
775
775
|
let brush;
|
|
776
776
|
try {
|
|
777
|
-
brush =
|
|
777
|
+
brush = _chunkQ33V5PEFcjs.normalizeBrushSpec.call(void 0, raw, problems);
|
|
778
778
|
} catch (e) {
|
|
779
|
-
throw new (0,
|
|
779
|
+
throw new (0, _chunkQ33V5PEFcjs.BrushLibraryError)("invalid", e.message);
|
|
780
780
|
}
|
|
781
|
-
const check2 =
|
|
782
|
-
if (!check2.ok) throw new (0,
|
|
781
|
+
const check2 = _chunkQ33V5PEFcjs.withKeptIssues.call(void 0, await checkFor(brush, profile), original ? await checkFor(original, profile) : null);
|
|
782
|
+
if (!check2.ok) throw new (0, _chunkQ33V5PEFcjs.BrushLibraryError)("invalid", refusal(check2, profile));
|
|
783
783
|
const saved = await library.save(brush, { overwrite });
|
|
784
784
|
return { ...saved, problems, check: check2 };
|
|
785
785
|
};
|
|
@@ -790,10 +790,10 @@ function createBrushLibraryTools(library, options = {}) {
|
|
|
790
790
|
inputSchema: {
|
|
791
791
|
type: "object",
|
|
792
792
|
properties: {
|
|
793
|
-
kind: { type: "string", enum: [...
|
|
794
|
-
medium: { type: "string", enum: [...
|
|
793
|
+
kind: { type: "string", enum: [..._chunkQ33V5PEFcjs.BRUSH_KINDS], description: "mark (lays a material) or tool (works on paint already down)." },
|
|
794
|
+
medium: { type: "string", enum: [..._chunkQ33V5PEFcjs.BRUSH_MEDIA], description: "Marks laying this medium." },
|
|
795
795
|
variety: { type: "string", maxLength: 40, description: "This variety (oil, watercolor, pencil, highlighter\u2026)." },
|
|
796
|
-
tool: { type: "string", enum: [...
|
|
796
|
+
tool: { type: "string", enum: [..._chunkQ33V5PEFcjs.BRUSH_TOOLS], description: "Tools that do this." },
|
|
797
797
|
tag: { type: "string", maxLength: 40, description: "Brushes with this tag." },
|
|
798
798
|
text: { type: "string", maxLength: 200, description: "Words in the id, name, description, variety or tags (each word must match the start of one)." },
|
|
799
799
|
source: { type: "string", enum: ["all", "builtin", "user"], description: "all (default), builtin presets only, or user (saved) brushes only." },
|
|
@@ -820,8 +820,8 @@ function createBrushLibraryTools(library, options = {}) {
|
|
|
820
820
|
annotations: { title: "Describe a brush", ...READ },
|
|
821
821
|
handler: async ({ id }) => {
|
|
822
822
|
const e = await entry(id);
|
|
823
|
-
const engine =
|
|
824
|
-
return { brush: e.brush, builtin: e.builtin, engine, category:
|
|
823
|
+
const engine = _chunkQ33V5PEFcjs.resolveEngine.call(void 0, e.brush);
|
|
824
|
+
return { brush: e.brush, builtin: e.builtin, engine, category: _chunkQ33V5PEFcjs.resolveCategory.call(void 0, e.brush, engine), check: await checkFor(e.brush, profile) };
|
|
825
825
|
}
|
|
826
826
|
};
|
|
827
827
|
const check = {
|
|
@@ -839,20 +839,20 @@ function createBrushLibraryTools(library, options = {}) {
|
|
|
839
839
|
},
|
|
840
840
|
annotations: { title: "Check a brush for a host", ...READ },
|
|
841
841
|
handler: async ({ id, brush, host }) => {
|
|
842
|
-
if (id === void 0 === (brush === void 0)) throw new (0,
|
|
842
|
+
if (id === void 0 === (brush === void 0)) throw new (0, _chunkQ33V5PEFcjs.BrushLibraryError)("invalid", "Give either id (a library brush) or brush (a spec), not both or neither.");
|
|
843
843
|
const p = hostOf(host);
|
|
844
844
|
let b;
|
|
845
845
|
const problems = [];
|
|
846
846
|
if (id !== void 0) b = (await entry(id)).brush;
|
|
847
847
|
else {
|
|
848
848
|
try {
|
|
849
|
-
b =
|
|
849
|
+
b = _chunkQ33V5PEFcjs.normalizeBrushSpec.call(void 0, brush, problems);
|
|
850
850
|
} catch (e) {
|
|
851
|
-
throw new (0,
|
|
851
|
+
throw new (0, _chunkQ33V5PEFcjs.BrushLibraryError)("invalid", e.message);
|
|
852
852
|
}
|
|
853
853
|
}
|
|
854
854
|
const result = await checkFor(b, p);
|
|
855
|
-
return { host: p.id, ...result, ...problems.length ? { problems } : {}, ...!result.ok ? { degraded:
|
|
855
|
+
return { host: p.id, ...result, ...problems.length ? { problems } : {}, ...!result.ok ? { degraded: _chunkQ33V5PEFcjs.degrade.call(void 0, b, p) } : {} };
|
|
856
856
|
}
|
|
857
857
|
};
|
|
858
858
|
const exportTool = {
|
|
@@ -887,7 +887,7 @@ function createBrushLibraryTools(library, options = {}) {
|
|
|
887
887
|
});
|
|
888
888
|
const start = _nullishCoalesce(offset, () => ( 0));
|
|
889
889
|
const page = found.slice(start, start + (_nullishCoalesce(limit, () => ( 100))));
|
|
890
|
-
return { total: found.length, sources: page.map((x) => ({ ...
|
|
890
|
+
return { total: found.length, sources: page.map((x) => ({ ..._chunkQ33V5PEFcjs.summarizeBrushSource.call(void 0, x), usedBy: brushes.filter((b) => _chunkQ33V5PEFcjs.brushSourceIds.call(void 0, b).includes(x.id)).map((b) => b.id) })) };
|
|
891
891
|
}
|
|
892
892
|
};
|
|
893
893
|
const tools = [list, describe, check, exportTool, listSources];
|
|
@@ -938,12 +938,12 @@ function createBrushLibraryTools(library, options = {}) {
|
|
|
938
938
|
},
|
|
939
939
|
annotations: { title: "Save a new brush", ...WRITE },
|
|
940
940
|
handler: async ({ basedOn, ...spec }) => {
|
|
941
|
-
if (library.isBuiltin(spec.id)) throw new (0,
|
|
942
|
-
if (await library.get(spec.id)) throw new (0,
|
|
941
|
+
if (library.isBuiltin(spec.id)) throw new (0, _chunkQ33V5PEFcjs.BrushLibraryError)("builtin", `"${spec.id}" is a built-in brush id; pick another id (or basedOn "${spec.id}" with a new id).`);
|
|
942
|
+
if (await library.get(spec.id)) throw new (0, _chunkQ33V5PEFcjs.BrushLibraryError)("exists", `A brush "${spec.id}" exists already; pick another id, or change it with update_brush.`);
|
|
943
943
|
const base = basedOn !== void 0 ? (await entry(basedOn)).brush : void 0;
|
|
944
944
|
const raw = base ? merge(base, spec) : spec;
|
|
945
945
|
const saved = await store(raw, false);
|
|
946
|
-
return { id: saved.brush.id, brush: saved.brush, engine:
|
|
946
|
+
return { id: saved.brush.id, brush: saved.brush, engine: _chunkQ33V5PEFcjs.resolveEngine.call(void 0, saved.brush), problems: saved.problems, warnings: warnings(saved.check) };
|
|
947
947
|
}
|
|
948
948
|
},
|
|
949
949
|
{
|
|
@@ -964,7 +964,7 @@ function createBrushLibraryTools(library, options = {}) {
|
|
|
964
964
|
annotations: { title: "Update a brush", ...WRITE, idempotentHint: true },
|
|
965
965
|
handler: async ({ id, unset, ...patch }) => {
|
|
966
966
|
const e = await entry(id);
|
|
967
|
-
if (e.builtin) throw new (0,
|
|
967
|
+
if (e.builtin) throw new (0, _chunkQ33V5PEFcjs.BrushLibraryError)("builtin", `"${id}" is a built-in brush and can't be changed; duplicate_brush makes a copy you can change.`);
|
|
968
968
|
const base = copy2(e.brush);
|
|
969
969
|
for (const k of _nullishCoalesce(unset, () => ( []))) delete base[k];
|
|
970
970
|
const saved = await store(merge(base, { ...patch, id }), true, e.brush);
|
|
@@ -974,14 +974,14 @@ function createBrushLibraryTools(library, options = {}) {
|
|
|
974
974
|
{
|
|
975
975
|
name: "add_brush_source",
|
|
976
976
|
title: "Add a brush image source",
|
|
977
|
-
description: `Adds an image to the brush library as a source for image tips and image grain (as Procreate's shape and grain sources). The image is a PNG data: URL; the marks are read from its transparency, its dark parts (a scan of marks on paper) or its light parts (white on black), as channel says, and kept as a grey mask at most ${
|
|
977
|
+
description: `Adds an image to the brush library as a source for image tips and image grain (as Procreate's shape and grain sources). The image is a PNG data: URL; the marks are read from its transparency, its dark parts (a scan of marks on paper) or its light parts (white on black), as channel says, and kept as a grey mask at most ${_chunkQ33V5PEFcjs.MAX_BRUSH_SOURCE_SIZE} px on a side. Returns id, ref (source:<id>), the stored source's width and height, problems (the channel auto picked, scaling) and replaced. Then make the brush: create_brush or update_brush with tip { shape: "stamp", stamps: [ref] } for an image tip, or tip.grain { source: ref } for grain. A taken id is refused unless overwrite.`,
|
|
978
978
|
inputSchema: {
|
|
979
979
|
type: "object",
|
|
980
980
|
properties: {
|
|
981
981
|
name: { type: "string", minLength: 1, maxLength: 80, description: 'Display name, e.g. "Charcoal scan".' },
|
|
982
|
-
image: { type: "string", pattern: "^data:image/png;base64,", maxLength: 4e7, description: `The image: a PNG data: URL, at most ${
|
|
982
|
+
image: { type: "string", pattern: "^data:image/png;base64,", maxLength: 4e7, description: `The image: a PNG data: URL, at most ${_chunkQ33V5PEFcjs.MAX_BRUSH_SOURCE_INPUT_PIXELS} pixels; larger than ${_chunkQ33V5PEFcjs.MAX_BRUSH_SOURCE_SIZE} px it is scaled down.` },
|
|
983
983
|
id: { type: "string", pattern: String(FACETS2.id.pattern), description: "The source id (default: from the name, made unique): lowercase letters, digits and dashes." },
|
|
984
|
-
channel: { type: "string", enum: [...
|
|
984
|
+
channel: { type: "string", enum: [..._chunkQ33V5PEFcjs.BRUSH_SOURCE_CHANNELS], description: "Where the marks are: auto (default: the transparency when the image has any, else the dark parts), alpha, darkness (dark marks on light paper) or lightness (light marks on black)." },
|
|
985
985
|
invert: { type: "boolean", description: "Swap painted and empty parts (default false)." },
|
|
986
986
|
licence: { type: "string", maxLength: 2e3, description: "The licence or terms the image came with, kept with the source." },
|
|
987
987
|
origin: { type: "string", maxLength: 200, description: "Where it came from: a file name, a pack or a URL." },
|
|
@@ -993,7 +993,7 @@ function createBrushLibraryTools(library, options = {}) {
|
|
|
993
993
|
annotations: { title: "Add a brush image source", ...WRITE },
|
|
994
994
|
handler: async ({ overwrite, ...input }) => {
|
|
995
995
|
const r = await library.addSource(input, { overwrite: !!overwrite });
|
|
996
|
-
return { id: r.source.id, ref:
|
|
996
|
+
return { id: r.source.id, ref: _chunkQ33V5PEFcjs.brushSourceRef.call(void 0, r.source.id), width: r.source.width, height: r.source.height, problems: r.problems, replaced: r.replaced };
|
|
997
997
|
}
|
|
998
998
|
},
|
|
999
999
|
{
|
|
@@ -1067,24 +1067,24 @@ function createBrushLibraryTools(library, options = {}) {
|
|
|
1067
1067
|
try {
|
|
1068
1068
|
bytes = _chunkW5M3J7PVcjs.base64ToBytes.call(void 0, file.replace(/^data:[^,]*,/, ""));
|
|
1069
1069
|
} catch (e6) {
|
|
1070
|
-
throw new (0,
|
|
1070
|
+
throw new (0, _chunkQ33V5PEFcjs.BrushLibraryError)("invalid", "file is not base64: pass the pack's bytes as base64 (a data: URL works too).");
|
|
1071
1071
|
}
|
|
1072
1072
|
let r;
|
|
1073
1073
|
try {
|
|
1074
1074
|
r = await importBrushPack(library, bytes, { fileName, ...format ? { format } : {}, ...prefix ? { prefix } : {}, ...licence ? { licence } : {}, overwrite: !!overwrite });
|
|
1075
1075
|
} catch (e) {
|
|
1076
|
-
if (e instanceof
|
|
1077
|
-
throw new (0,
|
|
1076
|
+
if (e instanceof _chunkQ33V5PEFcjs.BrushLibraryError) throw e;
|
|
1077
|
+
throw new (0, _chunkQ33V5PEFcjs.BrushLibraryError)("invalid", `${e.message} Nothing was imported.`);
|
|
1078
1078
|
}
|
|
1079
1079
|
const entries = await Promise.all(r.brushes.map((b) => library.get(b.id)));
|
|
1080
|
-
return { ...r, brushes: r.brushes.map((b, i) => ({ ...b, renderable: entries[i] ?
|
|
1080
|
+
return { ...r, brushes: r.brushes.map((b, i) => ({ ...b, renderable: entries[i] ? _chunkQ33V5PEFcjs.checkBrush.call(void 0, entries[i].brush, profile).ok : false })) };
|
|
1081
1081
|
}
|
|
1082
1082
|
}
|
|
1083
1083
|
);
|
|
1084
1084
|
return tools;
|
|
1085
1085
|
}
|
|
1086
1086
|
function createBrushLibraryToolProvider(library, options = {}) {
|
|
1087
|
-
const profile = _nullishCoalesce(options.profile, () => (
|
|
1087
|
+
const profile = _nullishCoalesce(options.profile, () => ( _chunkQ33V5PEFcjs.PAINT_PROFILE));
|
|
1088
1088
|
const tools = createBrushLibraryTools(library, options);
|
|
1089
1089
|
return {
|
|
1090
1090
|
id: _nullishCoalesce(options.id, () => ( "brushes")),
|