@pixerate/editor 0.259.0 → 0.261.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/agent/index.cjs +2 -2
- package/dist/agent/index.js +1 -1
- package/dist/animation-editor/index.cjs +61 -59
- package/dist/animation-editor/index.js +5 -3
- package/dist/brushes/index.cjs +52 -52
- package/dist/brushes/index.js +6 -6
- package/dist/{brushstrokeRender-JI4W6F2G.js → brushstrokeRender-25Q5BEY6.js} +17 -7
- package/dist/{brushstrokeRender-MQ6PSDM5.cjs → brushstrokeRender-N6UPZSQS.cjs} +31 -21
- package/dist/canvas/brushTypes.d.cts +5 -0
- package/dist/canvas/brushTypes.d.ts +5 -0
- package/dist/canvas/drawController.d.cts +15 -1
- package/dist/canvas/drawController.d.ts +15 -1
- package/dist/canvas/index.cjs +136 -102
- package/dist/canvas/index.js +35 -1
- package/dist/{chunk-3PPJRMIG.js → chunk-3O47TPGX.js} +197 -18
- package/dist/{chunk-5Q5MLXAD.cjs → chunk-3TQW5MPW.cjs} +23 -23
- package/dist/{chunk-JBBJE76O.cjs → chunk-3ZRNK3RO.cjs} +1138 -85
- package/dist/{chunk-YSGW7VV4.cjs → chunk-43NT242D.cjs} +1401 -228
- package/dist/{chunk-SMTUQWGY.js → chunk-5IW65VQ6.js} +1 -1
- package/dist/{chunk-YQ4PQTBB.js → chunk-6NZL24W4.js} +9 -1
- package/dist/{chunk-O3ZVZSNJ.cjs → chunk-7AUQ2UJ3.cjs} +137 -129
- package/dist/{chunk-4M4E3N6X.js → chunk-CQVTGBQI.js} +1 -1
- package/dist/{chunk-SSFMWJDK.js → chunk-D4TE5JNW.js} +1192 -19
- package/dist/{chunk-AORZ5M5C.js → chunk-EHALWBBD.js} +1 -1
- package/dist/{chunk-6WCQ35GI.cjs → chunk-NHA26O5X.cjs} +2 -2
- package/dist/{chunk-DPYAO5U6.cjs → chunk-PVJMTLPJ.cjs} +197 -18
- package/dist/{chunk-MQGQTKVW.cjs → chunk-PYTJBVW5.cjs} +29 -29
- package/dist/{chunk-IXQZHCOF.js → chunk-QAR2N7HZ.js} +1 -1
- package/dist/{chunk-5P4JEOIV.js → chunk-TMDDMJCR.js} +2 -2
- package/dist/{chunk-RSIKDWOP.cjs → chunk-TZOX7KWV.cjs} +15 -15
- package/dist/{chunk-IPUTIUGQ.cjs → chunk-UVZ7RQOE.cjs} +1 -1
- package/dist/{chunk-A7GJ6BXI.js → chunk-WJ4WQJCC.js} +1062 -9
- package/dist/{chunk-ICTPLVSR.js → chunk-X2EXYY4J.js} +1 -1
- package/dist/{chunk-WQCNC4DK.js → chunk-XC6DPRYI.js} +695 -4
- package/dist/{chunk-KBYB7OWB.cjs → chunk-YHDHFJUC.cjs} +776 -85
- package/dist/{chunk-P3PZ63M3.cjs → chunk-YLUIFXSL.cjs} +35 -35
- package/dist/commands/index.cjs +2 -2
- package/dist/commands/index.js +1 -1
- package/dist/image-editor/index.cjs +1385 -2484
- package/dist/image-editor/index.js +139 -1238
- package/dist/image-editor/selection-worker.cjs +3 -4
- package/dist/image-editor/selection-worker.js +1 -2
- package/dist/paint/index.cjs +3 -5
- package/dist/paint/index.js +40 -42
- package/dist/paint-editor/contract.d.cts +29 -0
- package/dist/paint-editor/contract.d.ts +29 -0
- package/dist/paint-editor/controller.d.cts +17 -0
- package/dist/paint-editor/controller.d.ts +17 -0
- package/dist/paint-editor/dab-stroke.d.cts +5 -0
- package/dist/paint-editor/dab-stroke.d.ts +5 -0
- package/dist/paint-editor/index.cjs +610 -327
- package/dist/paint-editor/index.d.cts +2 -0
- package/dist/paint-editor/index.d.ts +2 -0
- package/dist/paint-editor/index.js +337 -54
- package/dist/paint-editor/path-samples.d.cts +19 -0
- package/dist/paint-editor/path-samples.d.ts +19 -0
- package/dist/paint-editor/stamp-tip.d.cts +17 -0
- package/dist/paint-editor/stamp-tip.d.ts +17 -0
- package/dist/paint-editor/ui.d.cts +27 -1
- package/dist/paint-editor/ui.d.ts +27 -1
- package/dist/raster/index.cjs +2 -4
- package/dist/raster/index.js +6 -8
- package/dist/vector/brushstroke.d.cts +6 -0
- package/dist/vector/brushstroke.d.ts +6 -0
- package/dist/vector/controller.d.cts +11 -2
- package/dist/vector/controller.d.ts +11 -2
- package/dist/vector/index.cjs +990 -973
- package/dist/vector/index.js +28 -11
- package/package.json +1 -1
- package/skills/pixerate-brushes/SKILL.md +1 -1
- package/skills/pixerate-canvas/SKILL.md +3 -1
- package/skills/pixerate-paint-editor/SKILL.md +2 -0
- package/skills/pixerate-paint-sketch-to-finish/SKILL.md +5 -1
- package/skills/pixerate-vector/SKILL.md +2 -2
- package/dist/chunk-2VJAVXLI.js +0 -192
- package/dist/chunk-62Z5WLRA.js +0 -700
- package/dist/chunk-BOHDJJ2O.cjs +0 -192
- package/dist/chunk-NKGB64CW.cjs +0 -700
- package/dist/chunk-SS53NNZO.cjs +0 -1066
- package/dist/chunk-ZNA3IQZF.js +0 -1066
package/dist/canvas/index.js
CHANGED
|
@@ -46,7 +46,7 @@ import {
|
|
|
46
46
|
resolveCanvasBrushSpec,
|
|
47
47
|
validateCanvasBrush,
|
|
48
48
|
validateCanvasBrushPaint
|
|
49
|
-
} from "../chunk-
|
|
49
|
+
} from "../chunk-EHALWBBD.js";
|
|
50
50
|
import {
|
|
51
51
|
PATHFINDER_OPERATIONS,
|
|
52
52
|
PlanarMap,
|
|
@@ -214,6 +214,10 @@ import {
|
|
|
214
214
|
shapeToPolygon,
|
|
215
215
|
simplifyRing
|
|
216
216
|
} from "../chunk-PWBZH3FK.js";
|
|
217
|
+
import {
|
|
218
|
+
brushColourHex
|
|
219
|
+
} from "../chunk-FJBQTZS4.js";
|
|
220
|
+
import "../chunk-3CI7FRMK.js";
|
|
217
221
|
import {
|
|
218
222
|
StickerError
|
|
219
223
|
} from "../chunk-SZTI6EER.js";
|
|
@@ -8075,6 +8079,7 @@ function createCanvasDrawController(options) {
|
|
|
8075
8079
|
...options.style
|
|
8076
8080
|
};
|
|
8077
8081
|
let activeStroke = null;
|
|
8082
|
+
let colorScheme = options.colorScheme === "dark" ? "dark" : "light";
|
|
8078
8083
|
const erasedInDrag = /* @__PURE__ */ new Map();
|
|
8079
8084
|
let dragStartNodes = null;
|
|
8080
8085
|
function setTool(tool) {
|
|
@@ -8191,6 +8196,11 @@ function createCanvasDrawController(options) {
|
|
|
8191
8196
|
const tool = input.tool ?? "pen";
|
|
8192
8197
|
if (tool !== "pen" && tool !== "highlighter") throw new Error(`Unknown tool '${String(tool)}': use 'pen' or 'highlighter'.`);
|
|
8193
8198
|
const style = { ...createDefaultStrokeStyle(tool), ...input.style };
|
|
8199
|
+
if (input.style?.color === void 0 && typeof style.brush === "string") {
|
|
8200
|
+
const preset = (await listCanvasBrushes(options.brushLibrary)).find((b) => b.id === style.brush);
|
|
8201
|
+
const hex = preset?.defaultColor !== void 0 ? brushColourHex(preset.defaultColor, colorScheme) : null;
|
|
8202
|
+
if (hex) style.color = hex;
|
|
8203
|
+
}
|
|
8194
8204
|
if (!(style.width > 0)) throw new Error("width must be a positive number of canvas units.");
|
|
8195
8205
|
const profiles = { pressure: input.pressure, tiltX: input.tiltX, tiltY: input.tiltY };
|
|
8196
8206
|
for (const [key, values] of Object.entries(profiles)) {
|
|
@@ -8299,6 +8309,30 @@ function createCanvasDrawController(options) {
|
|
|
8299
8309
|
nodeBounds,
|
|
8300
8310
|
/** The presets and saved brushes (of `brushLibrary`) a stroke can be brushed with (loads the paint engine). */
|
|
8301
8311
|
listBrushes: () => listCanvasBrushes(options.brushLibrary),
|
|
8312
|
+
/**
|
|
8313
|
+
* A brush picker's choice: brushes the pen and highlighter with `id` (`null`: a plain vector
|
|
8314
|
+
* stroke) at the brush's own size, embedding a saved brush, and makes its default colour
|
|
8315
|
+
* (resolved for the colour scheme) the stroke colour unless `keepColour`. Throws for a brush
|
|
8316
|
+
* the canvas can't paint. Resolves with the brush chosen.
|
|
8317
|
+
*/
|
|
8318
|
+
async selectBrush(id, choice = {}) {
|
|
8319
|
+
if (id === null) {
|
|
8320
|
+
setStyle({ brush: void 0, brushSize: void 0, brushSpec: void 0, paint: void 0 });
|
|
8321
|
+
return null;
|
|
8322
|
+
}
|
|
8323
|
+
const preset = (await listCanvasBrushes(options.brushLibrary)).find((b) => b.id === id);
|
|
8324
|
+
if (!preset) {
|
|
8325
|
+
await validateCanvasBrush(id);
|
|
8326
|
+
throw new Error(`Brush '${id}' is not one the canvas can paint; listBrushes lists them.`);
|
|
8327
|
+
}
|
|
8328
|
+
const hex = !choice.keepColour && preset.defaultColor !== void 0 ? brushColourHex(preset.defaultColor, colorScheme) : null;
|
|
8329
|
+
setStyle({ brush: id, brushSize: preset.size, brushSpec: preset.spec, ...hex ? { color: hex } : {} });
|
|
8330
|
+
return preset;
|
|
8331
|
+
},
|
|
8332
|
+
/** The host's colour scheme, for brushes' light / dark default colours. */
|
|
8333
|
+
setColorScheme(scheme) {
|
|
8334
|
+
colorScheme = scheme === "dark" ? "dark" : "light";
|
|
8335
|
+
},
|
|
8302
8336
|
/** The saved brush to embed for a brush id (undefined for presets and tip settings); for a brush picker. */
|
|
8303
8337
|
brushSpec: (brush) => resolveCanvasBrushSpec(brush, options.brushLibrary)
|
|
8304
8338
|
};
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
gaussianBlur
|
|
13
13
|
} from "./chunk-ZIF4UJJ6.js";
|
|
14
14
|
import {
|
|
15
|
+
BLEND_MODES,
|
|
15
16
|
blendChannel,
|
|
16
17
|
blendRgb,
|
|
17
18
|
deepTile,
|
|
@@ -762,8 +763,8 @@ function edtNearest(inside, w, h) {
|
|
|
762
763
|
dt1(f, w, o, nr, v, z);
|
|
763
764
|
for (let x = 0; x < w; x++) {
|
|
764
765
|
d[y * w + x] = Math.sqrt(o[x]);
|
|
765
|
-
const
|
|
766
|
-
near[y * w + x] = nc[
|
|
766
|
+
const px2 = nr[x];
|
|
767
|
+
near[y * w + x] = nc[px2 * h + y] * w + px2;
|
|
767
768
|
}
|
|
768
769
|
}
|
|
769
770
|
return { d, near };
|
|
@@ -3446,21 +3447,21 @@ function readWindow(src, srcRect, rect, depth = null) {
|
|
|
3446
3447
|
const win = { x: rect.x, y: rect.y, w: rect.width, h: rect.height, n, data };
|
|
3447
3448
|
const r = intersect(rect, srcRect);
|
|
3448
3449
|
if (!r) return win;
|
|
3449
|
-
const
|
|
3450
|
+
const px2 = depth ? readScaled(src, r, depth) : readRegion(src, r);
|
|
3450
3451
|
for (let y = 0; y < r.height; y++) {
|
|
3451
3452
|
let s = y * r.width * src.channels;
|
|
3452
3453
|
let d = ((r.y - rect.y + y) * rect.width + (r.x - rect.x)) * n;
|
|
3453
3454
|
if (n === 4) {
|
|
3454
3455
|
for (let x = 0; x < r.width; x++, s += 4, d += 4) {
|
|
3455
|
-
const a =
|
|
3456
|
-
data[d] =
|
|
3457
|
-
data[d + 1] =
|
|
3458
|
-
data[d + 2] =
|
|
3456
|
+
const a = px2[s + 3] / 255;
|
|
3457
|
+
data[d] = px2[s] * a;
|
|
3458
|
+
data[d + 1] = px2[s + 1] * a;
|
|
3459
|
+
data[d + 2] = px2[s + 2] * a;
|
|
3459
3460
|
data[d + 3] = a;
|
|
3460
3461
|
}
|
|
3461
3462
|
} else {
|
|
3462
3463
|
for (let x = 0; x < r.width; x++, s++, d += 2) {
|
|
3463
|
-
data[d] =
|
|
3464
|
+
data[d] = px2[s];
|
|
3464
3465
|
data[d + 1] = 1;
|
|
3465
3466
|
}
|
|
3466
3467
|
}
|
|
@@ -3631,7 +3632,7 @@ function boxReduce(src, srcRect, kx, ky, depth = null) {
|
|
|
3631
3632
|
for (let ry = ry0; ry < ry1; ry += rowsPer) {
|
|
3632
3633
|
const rows = Math.min(rowsPer, ry1 - ry);
|
|
3633
3634
|
const strip = { x: rx0 * kx, y: ry * ky, width: rw * kx, height: rows * ky };
|
|
3634
|
-
const
|
|
3635
|
+
const px2 = depth ? readScaled(src, strip, depth) : readRegion(src, strip);
|
|
3635
3636
|
const red = depth ? new Float32Array(rw * rows * ch) : new Uint8ClampedArray(rw * rows * ch);
|
|
3636
3637
|
for (let j = 0; j < rows; j++) {
|
|
3637
3638
|
for (let i = 0; i < rw; i++) {
|
|
@@ -3643,11 +3644,11 @@ function boxReduce(src, srcRect, kx, ky, depth = null) {
|
|
|
3643
3644
|
for (let y = 0; y < ky; y++) {
|
|
3644
3645
|
let s = ((j * ky + y) * strip.width + i * kx) * 4;
|
|
3645
3646
|
for (let x = 0; x < kx; x++, s += 4) {
|
|
3646
|
-
const al =
|
|
3647
|
+
const al = px2[s + 3];
|
|
3647
3648
|
a += al;
|
|
3648
|
-
r +=
|
|
3649
|
-
g +=
|
|
3650
|
-
b +=
|
|
3649
|
+
r += px2[s] * al;
|
|
3650
|
+
g += px2[s + 1] * al;
|
|
3651
|
+
b += px2[s + 2] * al;
|
|
3651
3652
|
}
|
|
3652
3653
|
}
|
|
3653
3654
|
const o = (j * rw + i) * 4;
|
|
@@ -3661,7 +3662,7 @@ function boxReduce(src, srcRect, kx, ky, depth = null) {
|
|
|
3661
3662
|
let v = 0;
|
|
3662
3663
|
for (let y = 0; y < ky; y++) {
|
|
3663
3664
|
const s = (j * ky + y) * strip.width + i * kx;
|
|
3664
|
-
for (let x = 0; x < kx; x++) v +=
|
|
3665
|
+
for (let x = 0; x < kx; x++) v += px2[s + x];
|
|
3665
3666
|
}
|
|
3666
3667
|
red[j * rw + i] = v / area;
|
|
3667
3668
|
}
|
|
@@ -4038,9 +4039,9 @@ function warpSurface(src, f, options = {}) {
|
|
|
4038
4039
|
for (let y = ay0; y < ry1; y += step) {
|
|
4039
4040
|
const py = y + 0.5;
|
|
4040
4041
|
for (let x = ax0; x < rx1; x += step) {
|
|
4041
|
-
const
|
|
4042
|
-
const l1 = ((
|
|
4043
|
-
const l2 = ((p1x - p0x) * (py - p0y) - (
|
|
4042
|
+
const px2 = x + 0.5;
|
|
4043
|
+
const l1 = ((px2 - p0x) * (p2y - p0y) - (p2x - p0x) * (py - p0y)) / det;
|
|
4044
|
+
const l2 = ((p1x - p0x) * (py - p0y) - (px2 - p0x) * (p1y - p0y)) / det;
|
|
4044
4045
|
const l0 = 1 - l1 - l2;
|
|
4045
4046
|
if (l0 < eps || l1 < eps || l2 < eps) continue;
|
|
4046
4047
|
const o = (y - t.y) * tw + (x - t.x);
|
|
@@ -4197,6 +4198,179 @@ function compositeSurfaceOver(base, top) {
|
|
|
4197
4198
|
return new TiledSurface(ch, tiles, base.defaultValue);
|
|
4198
4199
|
}
|
|
4199
4200
|
|
|
4201
|
+
// src/raster/effects/ui.ts
|
|
4202
|
+
function layerEffectsPanel(layer) {
|
|
4203
|
+
const empty = { readOnly: true, enabled: true, scale: 1, rows: [] };
|
|
4204
|
+
if (!layer) return { ...empty, available: false, reason: "Select a layer to add a layer style." };
|
|
4205
|
+
if (layer.type === "adjustment") return { ...empty, available: false, reason: "Adjustment layers cannot have a layer style." };
|
|
4206
|
+
const fx = layer.effects;
|
|
4207
|
+
const readOnly = Boolean(layer.locks?.all);
|
|
4208
|
+
return {
|
|
4209
|
+
available: true,
|
|
4210
|
+
readOnly,
|
|
4211
|
+
reason: readOnly ? "The layer is locked; unlock it to change its layer style." : void 0,
|
|
4212
|
+
enabled: fx?.enabled ?? true,
|
|
4213
|
+
scale: fx?.scale ?? 1,
|
|
4214
|
+
rows: (fx?.items ?? []).map((e) => ({ id: e.id, kind: e.kind, label: layerEffectLabel(e.kind), enabled: e.enabled }))
|
|
4215
|
+
};
|
|
4216
|
+
}
|
|
4217
|
+
function layerEffectsBadge(layer) {
|
|
4218
|
+
if (!layer.effects?.items.length) return null;
|
|
4219
|
+
return hasActiveEffects(layer.effects) ? "on" : "off";
|
|
4220
|
+
}
|
|
4221
|
+
var LAYER_EFFECT_MENU = LAYER_EFFECT_KINDS.map((kind) => ({ kind, label: layerEffectLabel(kind) }));
|
|
4222
|
+
var BLENDS = BLEND_MODES.filter((m) => m.id !== "pigment").map((m) => ({ value: m.id, label: m.label }));
|
|
4223
|
+
var opt = (...pairs) => pairs.map(([value, label]) => ({ value, label }));
|
|
4224
|
+
function patternOptions(patterns) {
|
|
4225
|
+
return [...patterns.map((p) => ({ value: p.id, label: p.name || p.id })), ...builtinPatternIds().map((id) => ({ value: id, label: builtinPattern(id).name }))];
|
|
4226
|
+
}
|
|
4227
|
+
function getPath(o, path) {
|
|
4228
|
+
let v = o;
|
|
4229
|
+
for (const p of path.split(".")) {
|
|
4230
|
+
if (v === null || v === void 0) return void 0;
|
|
4231
|
+
if (Array.isArray(v)) v = p === "last" ? v[v.length - 1] : v[Number(p)];
|
|
4232
|
+
else v = v[p];
|
|
4233
|
+
}
|
|
4234
|
+
return v;
|
|
4235
|
+
}
|
|
4236
|
+
function setPath(o, parts, value) {
|
|
4237
|
+
if (!parts.length) return value;
|
|
4238
|
+
const [p, ...rest] = parts;
|
|
4239
|
+
if (Array.isArray(o)) {
|
|
4240
|
+
const i = p === "last" ? o.length - 1 : Number(p);
|
|
4241
|
+
const out = [...o];
|
|
4242
|
+
out[i] = setPath(o[i], rest, value);
|
|
4243
|
+
return out;
|
|
4244
|
+
}
|
|
4245
|
+
const r = o ?? {};
|
|
4246
|
+
return { ...r, [p]: setPath(r[p], rest, value) };
|
|
4247
|
+
}
|
|
4248
|
+
function fillControls(f, allowPattern, patterns) {
|
|
4249
|
+
const types = allowPattern ? opt(["color", "Color"], ["gradient", "Gradient"], ["pattern", "Pattern"]) : opt(["color", "Color"], ["gradient", "Gradient"]);
|
|
4250
|
+
const out = [{ key: "fill.type", label: "Fill", type: "select", value: f.type, options: types }];
|
|
4251
|
+
if (f.type === "color") out.push({ key: "fill.color", label: "Color", type: "color", value: f.color });
|
|
4252
|
+
else if (f.type === "gradient") out.push(...gradientControls("fill.gradient", f.gradient));
|
|
4253
|
+
else {
|
|
4254
|
+
out.push(
|
|
4255
|
+
{ key: "fill.patternId", label: "Pattern", type: "select", value: f.patternId, options: patternOptions(patterns) },
|
|
4256
|
+
{ key: "fill.scale", label: "Scale", type: "range", min: 0.01, max: 10, step: 0.01, value: f.scale, percent: true, unit: "%" }
|
|
4257
|
+
);
|
|
4258
|
+
}
|
|
4259
|
+
return out;
|
|
4260
|
+
}
|
|
4261
|
+
function gradientControls(prefix, g) {
|
|
4262
|
+
return [
|
|
4263
|
+
{ key: `${prefix}.stops.0.color`, label: "Start colour", type: "color", value: g.stops[0]?.color ?? "#000000" },
|
|
4264
|
+
{ key: `${prefix}.stops.last.color`, label: "End colour", type: "color", value: g.stops[g.stops.length - 1]?.color ?? "#ffffff" },
|
|
4265
|
+
{ key: `${prefix}.style`, label: "Style", type: "select", value: g.style, options: opt(["linear", "Linear"], ["radial", "Radial"], ["angle", "Angle"], ["reflected", "Reflected"], ["diamond", "Diamond"]) },
|
|
4266
|
+
{ key: `${prefix}.angle`, label: "Angle", type: "range", min: -180, max: 180, step: 1, value: g.angle, unit: "\xB0" },
|
|
4267
|
+
{ key: `${prefix}.scale`, label: "Scale", type: "range", min: 0.1, max: 1.5, step: 0.01, value: g.scale, percent: true, unit: "%" },
|
|
4268
|
+
{ key: `${prefix}.reverse`, label: "Reverse", type: "checkbox", value: g.reverse },
|
|
4269
|
+
{ key: `${prefix}.align`, label: "Align with layer", type: "checkbox", value: g.align }
|
|
4270
|
+
];
|
|
4271
|
+
}
|
|
4272
|
+
var px = (key, label, value, max = 250) => ({ key, label, type: "range", min: 0, max, step: 1, value, unit: "px" });
|
|
4273
|
+
var pct = (key, label, value, min = 0, max = 1) => ({ key, label, type: "range", min, max, step: 0.01, value, percent: true, unit: "%" });
|
|
4274
|
+
var deg = (key, label, value, min = -180, max = 180) => ({ key, label, type: "range", min, max, step: 1, value, unit: "\xB0" });
|
|
4275
|
+
function layerEffectControls(e, patterns = []) {
|
|
4276
|
+
const blended = e.kind === "bevel-emboss" ? [] : [
|
|
4277
|
+
{ key: "blend", label: "Blend mode", type: "select", value: e.blend, options: BLENDS },
|
|
4278
|
+
pct("opacity", "Opacity", e.opacity)
|
|
4279
|
+
];
|
|
4280
|
+
switch (e.kind) {
|
|
4281
|
+
case "drop-shadow":
|
|
4282
|
+
case "inner-shadow":
|
|
4283
|
+
return [
|
|
4284
|
+
...blended,
|
|
4285
|
+
{ key: "color", label: "Color", type: "color", value: e.color },
|
|
4286
|
+
{ key: "useGlobalLight", label: "Use global light", type: "checkbox", value: e.useGlobalLight },
|
|
4287
|
+
deg("angle", "Angle", e.angle),
|
|
4288
|
+
px("distance", "Distance", e.distance, 500),
|
|
4289
|
+
e.kind === "drop-shadow" ? pct("spread", "Spread", e.spread) : pct("choke", "Choke", e.choke),
|
|
4290
|
+
px("size", "Size", e.size),
|
|
4291
|
+
pct("noise", "Noise", e.noise),
|
|
4292
|
+
...e.kind === "drop-shadow" ? [{ key: "knocksOut", label: "Layer knocks out shadow", type: "checkbox", value: e.knocksOut }] : []
|
|
4293
|
+
];
|
|
4294
|
+
case "outer-glow":
|
|
4295
|
+
case "inner-glow":
|
|
4296
|
+
return [
|
|
4297
|
+
...blended,
|
|
4298
|
+
...fillControls(e.fill, false, patterns),
|
|
4299
|
+
{ key: "technique", label: "Technique", type: "select", value: e.technique, options: opt(["softer", "Softer"], ["precise", "Precise"]) },
|
|
4300
|
+
...e.kind === "inner-glow" ? [{ key: "source", label: "Source", type: "select", value: e.source, options: opt(["edge", "Edge"], ["center", "Center"]) }] : [],
|
|
4301
|
+
e.kind === "outer-glow" ? pct("spread", "Spread", e.spread) : pct("choke", "Choke", e.choke),
|
|
4302
|
+
px("size", "Size", e.size),
|
|
4303
|
+
pct("range", "Range", e.range, 0.01, 1),
|
|
4304
|
+
pct("noise", "Noise", e.noise)
|
|
4305
|
+
];
|
|
4306
|
+
case "bevel-emboss":
|
|
4307
|
+
return [
|
|
4308
|
+
{ key: "style", label: "Style", type: "select", value: e.style, options: opt(["inner-bevel", "Inner Bevel"], ["outer-bevel", "Outer Bevel"], ["emboss", "Emboss"], ["pillow-emboss", "Pillow Emboss"], ["stroke-emboss", "Stroke Emboss"]) },
|
|
4309
|
+
{ key: "technique", label: "Technique", type: "select", value: e.technique, options: opt(["smooth", "Smooth"], ["chisel-hard", "Chisel Hard"], ["chisel-soft", "Chisel Soft"]) },
|
|
4310
|
+
pct("depth", "Depth", e.depth, 0, 10),
|
|
4311
|
+
{ key: "direction", label: "Direction", type: "select", value: e.direction, options: opt(["up", "Up"], ["down", "Down"]) },
|
|
4312
|
+
px("size", "Size", e.size),
|
|
4313
|
+
px("soften", "Soften", e.soften, 16),
|
|
4314
|
+
{ key: "useGlobalLight", label: "Use global light", type: "checkbox", value: e.useGlobalLight },
|
|
4315
|
+
deg("angle", "Angle", e.angle),
|
|
4316
|
+
deg("altitude", "Altitude", e.altitude, 0, 90),
|
|
4317
|
+
{ key: "highlightColor", label: "Highlight", type: "color", value: e.highlightColor },
|
|
4318
|
+
{ key: "highlightBlend", label: "Highlight mode", type: "select", value: e.highlightBlend, options: BLENDS },
|
|
4319
|
+
pct("highlightOpacity", "Highlight opacity", e.highlightOpacity),
|
|
4320
|
+
{ key: "shadowColor", label: "Shadow", type: "color", value: e.shadowColor },
|
|
4321
|
+
{ key: "shadowBlend", label: "Shadow mode", type: "select", value: e.shadowBlend, options: BLENDS },
|
|
4322
|
+
pct("shadowOpacity", "Shadow opacity", e.shadowOpacity)
|
|
4323
|
+
];
|
|
4324
|
+
case "satin":
|
|
4325
|
+
return [
|
|
4326
|
+
...blended,
|
|
4327
|
+
{ key: "color", label: "Color", type: "color", value: e.color },
|
|
4328
|
+
deg("angle", "Angle", e.angle),
|
|
4329
|
+
px("distance", "Distance", e.distance),
|
|
4330
|
+
px("size", "Size", e.size),
|
|
4331
|
+
{ key: "invert", label: "Invert", type: "checkbox", value: e.invert }
|
|
4332
|
+
];
|
|
4333
|
+
case "color-overlay":
|
|
4334
|
+
return [...blended, { key: "color", label: "Color", type: "color", value: e.color }];
|
|
4335
|
+
case "gradient-overlay":
|
|
4336
|
+
return [...blended, ...gradientControls("gradient", e.gradient)];
|
|
4337
|
+
case "pattern-overlay":
|
|
4338
|
+
return [
|
|
4339
|
+
...blended,
|
|
4340
|
+
{ key: "patternId", label: "Pattern", type: "select", value: e.patternId, options: patternOptions(patterns) },
|
|
4341
|
+
pct("scale", "Scale", e.scale, 0.01, 10),
|
|
4342
|
+
deg("angle", "Angle", e.angle ?? 0),
|
|
4343
|
+
{ key: "link", label: "Link with layer", type: "checkbox", value: e.link ?? true }
|
|
4344
|
+
];
|
|
4345
|
+
case "stroke":
|
|
4346
|
+
return [
|
|
4347
|
+
...blended,
|
|
4348
|
+
px("size", "Size", e.size),
|
|
4349
|
+
{ key: "position", label: "Position", type: "select", value: e.position, options: opt(["outside", "Outside"], ["inside", "Inside"], ["center", "Center"]) },
|
|
4350
|
+
...fillControls(e.fill, true, patterns)
|
|
4351
|
+
];
|
|
4352
|
+
}
|
|
4353
|
+
}
|
|
4354
|
+
function fillOfType(current, type, patterns) {
|
|
4355
|
+
if (type === "gradient") return { type: "gradient", gradient: defaultEffectGradient() };
|
|
4356
|
+
if (type === "pattern") return { type: "pattern", patternId: patterns[0]?.id ?? "checker", scale: 1 };
|
|
4357
|
+
return { type: "color", color: current.type === "color" ? current.color : "#000000" };
|
|
4358
|
+
}
|
|
4359
|
+
function effectControlChange(effect, key, value, patterns = []) {
|
|
4360
|
+
const [top, ...rest] = key.split(".");
|
|
4361
|
+
if (top === "fill" && rest[0] === "type") return { fill: fillOfType(effect.fill, String(value), patterns) };
|
|
4362
|
+
if (top === "patternId" && !rest.length) {
|
|
4363
|
+
const name = patternOptions(patterns).find((o) => o.value === value)?.label;
|
|
4364
|
+
return name ? { patternId: value, name } : { patternId: value };
|
|
4365
|
+
}
|
|
4366
|
+
if (!rest.length) return { [top]: value };
|
|
4367
|
+
if (top === "fill" && rest[0] === "patternId") {
|
|
4368
|
+
const name = patternOptions(patterns).find((o) => o.value === value)?.label;
|
|
4369
|
+
return { fill: { ...effect.fill, patternId: value, ...name ? { name } : {} } };
|
|
4370
|
+
}
|
|
4371
|
+
return { [top]: setPath(getPath(effect, top), rest, value) };
|
|
4372
|
+
}
|
|
4373
|
+
|
|
4200
4374
|
export {
|
|
4201
4375
|
DEFAULT_GLOBAL_LIGHT,
|
|
4202
4376
|
LAYER_EFFECT_KINDS,
|
|
@@ -4258,5 +4432,10 @@ export {
|
|
|
4258
4432
|
transformedBounds,
|
|
4259
4433
|
transformSurface,
|
|
4260
4434
|
warpSurface,
|
|
4261
|
-
compositeSurfaceOver
|
|
4435
|
+
compositeSurfaceOver,
|
|
4436
|
+
layerEffectsPanel,
|
|
4437
|
+
layerEffectsBadge,
|
|
4438
|
+
LAYER_EFFECT_MENU,
|
|
4439
|
+
layerEffectControls,
|
|
4440
|
+
effectControlChange
|
|
4262
4441
|
};
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunk7AUQ2UJ3cjs = require('./chunk-7AUQ2UJ3.cjs');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
var _chunkGF2RBSDMcjs = require('./chunk-GF2RBSDM.cjs');
|
|
@@ -1361,12 +1361,12 @@ var unit = (x, y) => {
|
|
|
1361
1361
|
return l > 1e-12 && Number.isFinite(l) ? [x / l, y / l] : null;
|
|
1362
1362
|
};
|
|
1363
1363
|
function cubicOf(sp, i) {
|
|
1364
|
-
const s =
|
|
1364
|
+
const s = _chunk7AUQ2UJ3cjs.subpathSegment.call(void 0, sp, i);
|
|
1365
1365
|
if (s.length === 4) return s;
|
|
1366
1366
|
const [a, b] = s;
|
|
1367
1367
|
return [a, [a[0] + (b[0] - a[0]) / 3, a[1] + (b[1] - a[1]) / 3], [a[0] + 2 * (b[0] - a[0]) / 3, a[1] + 2 * (b[1] - a[1]) / 3], b];
|
|
1368
1368
|
}
|
|
1369
|
-
var isLine = (sp, i) =>
|
|
1369
|
+
var isLine = (sp, i) => _chunk7AUQ2UJ3cjs.subpathSegment.call(void 0, sp, i).length === 2;
|
|
1370
1370
|
function startTangent(c) {
|
|
1371
1371
|
for (let k = 1; k < 4; k++) {
|
|
1372
1372
|
const u = unit(c[k][0] - c[0][0], c[k][1] - c[0][1]);
|
|
@@ -1386,10 +1386,10 @@ function sample(c, n, out, withStart) {
|
|
|
1386
1386
|
}
|
|
1387
1387
|
var onAnchor = (a, h) => !h || Math.abs(h.x - a.x) < EPS && Math.abs(h.y - a.y) < EPS;
|
|
1388
1388
|
function tidy(a, keepType = true) {
|
|
1389
|
-
const next =
|
|
1389
|
+
const next = _chunk7AUQ2UJ3cjs.cloneAnchor.call(void 0, a);
|
|
1390
1390
|
if (onAnchor(next, next.in)) delete next.in;
|
|
1391
1391
|
if (onAnchor(next, next.out)) delete next.out;
|
|
1392
|
-
const shown =
|
|
1392
|
+
const shown = _chunk7AUQ2UJ3cjs.inferAnchorType.call(void 0, next);
|
|
1393
1393
|
const type = keepType && a.type ? a.type === "symmetric" && shown !== "symmetric" ? shown === "corner" ? "corner" : "smooth" : a.type === "smooth" && shown === "corner" ? "corner" : a.type : shown;
|
|
1394
1394
|
if (type === "corner") delete next.type;
|
|
1395
1395
|
else next.type = type;
|
|
@@ -1433,7 +1433,7 @@ function fitAcross(pts, N, t0, t1) {
|
|
|
1433
1433
|
return goldenMin(fit, 0, 1);
|
|
1434
1434
|
}
|
|
1435
1435
|
function removeAnchorKeepingShape(sp, index) {
|
|
1436
|
-
const anchors = sp.anchors.map(
|
|
1436
|
+
const anchors = sp.anchors.map(_chunk7AUQ2UJ3cjs.cloneAnchor);
|
|
1437
1437
|
const n = anchors.length;
|
|
1438
1438
|
if (index < 0 || index >= n) return { anchors, closed: sp.closed };
|
|
1439
1439
|
if ((sp.closed || index > 0 && index < n - 1) && n >= 3) {
|
|
@@ -1467,12 +1467,12 @@ function removeAnchorKeepingShape(sp, index) {
|
|
|
1467
1467
|
}
|
|
1468
1468
|
function removeAnchorsKeepingShape(sp, indices) {
|
|
1469
1469
|
const order = [...new Set(indices)].filter((i) => i >= 0 && i < sp.anchors.length).sort((a, b) => b - a);
|
|
1470
|
-
return order.reduce((acc, i) => removeAnchorKeepingShape(acc, i), { anchors: sp.anchors.map(
|
|
1470
|
+
return order.reduce((acc, i) => removeAnchorKeepingShape(acc, i), { anchors: sp.anchors.map(_chunk7AUQ2UJ3cjs.cloneAnchor), closed: sp.closed });
|
|
1471
1471
|
}
|
|
1472
1472
|
function bendSegment(sp, segment, t, p) {
|
|
1473
|
-
const anchors = sp.anchors.map(
|
|
1473
|
+
const anchors = sp.anchors.map(_chunk7AUQ2UJ3cjs.cloneAnchor);
|
|
1474
1474
|
const n = anchors.length;
|
|
1475
|
-
if (segment < 0 || segment >=
|
|
1475
|
+
if (segment < 0 || segment >= _chunk7AUQ2UJ3cjs.subpathSegmentCount.call(void 0, sp) || !Number.isFinite(t) || !Number.isFinite(p.x) || !Number.isFinite(p.y)) return { anchors, closed: sp.closed };
|
|
1476
1476
|
const tc = Math.min(0.95, Math.max(0.05, t));
|
|
1477
1477
|
const ia = segment;
|
|
1478
1478
|
const ib = (segment + 1) % n;
|
|
@@ -1483,16 +1483,16 @@ function bendSegment(sp, segment, t, p) {
|
|
|
1483
1483
|
const oy = (p.y - (a.y + (b.y - a.y) * tc)) / k;
|
|
1484
1484
|
const c1 = { x: a.x + (b.x - a.x) / 3 + ox, y: a.y + (b.y - a.y) / 3 + oy };
|
|
1485
1485
|
const c2 = { x: b.x + (a.x - b.x) / 3 + ox, y: b.y + (a.y - b.y) / 3 + oy };
|
|
1486
|
-
anchors[ia] =
|
|
1487
|
-
anchors[ib] =
|
|
1486
|
+
anchors[ia] = _chunk7AUQ2UJ3cjs.moveAnchorHandle.call(void 0, a, "out", c1);
|
|
1487
|
+
anchors[ib] = _chunk7AUQ2UJ3cjs.moveAnchorHandle.call(void 0, b, "in", c2);
|
|
1488
1488
|
return { anchors, closed: sp.closed };
|
|
1489
1489
|
}
|
|
1490
1490
|
function subpathPointAt(sp, segment, t) {
|
|
1491
|
-
const [x, y] = _chunkGF2RBSDMcjs.segmentPoint.call(void 0,
|
|
1491
|
+
const [x, y] = _chunkGF2RBSDMcjs.segmentPoint.call(void 0, _chunk7AUQ2UJ3cjs.subpathSegment.call(void 0, sp, segment), t);
|
|
1492
1492
|
return { x, y };
|
|
1493
1493
|
}
|
|
1494
1494
|
function curvatureMoveAnchor(sp, index, q) {
|
|
1495
|
-
const anchors = sp.anchors.map(
|
|
1495
|
+
const anchors = sp.anchors.map(_chunk7AUQ2UJ3cjs.cloneAnchor);
|
|
1496
1496
|
const a = sp.anchors[index];
|
|
1497
1497
|
if (!a) return { anchors, closed: sp.closed };
|
|
1498
1498
|
const own = [
|
|
@@ -1538,7 +1538,7 @@ function curvatureMoveAnchor(sp, index, q) {
|
|
|
1538
1538
|
function cutSubpathAt(sp, at) {
|
|
1539
1539
|
const n = sp.anchors.length;
|
|
1540
1540
|
const cuts = [...new Set(at)].filter((i) => Number.isInteger(i) && i >= 0 && i < n && (sp.closed || i > 0 && i < n - 1)).sort((a, b) => a - b);
|
|
1541
|
-
if (!cuts.length || n < 2) return [{ anchors: sp.anchors.map(
|
|
1541
|
+
if (!cuts.length || n < 2) return [{ anchors: sp.anchors.map(_chunk7AUQ2UJ3cjs.cloneAnchor), closed: sp.closed }];
|
|
1542
1542
|
const first = cuts[0];
|
|
1543
1543
|
const run = sp.closed ? Array.from({ length: n + 1 }, (_, i) => sp.anchors[(first + i) % n]) : sp.anchors;
|
|
1544
1544
|
const cutSet = new Set(sp.closed ? [...cuts.map((c) => (c - first + n) % n), n] : cuts);
|
|
@@ -1546,7 +1546,7 @@ function cutSubpathAt(sp, at) {
|
|
|
1546
1546
|
let cur = [];
|
|
1547
1547
|
run.forEach((a, i) => {
|
|
1548
1548
|
if (!cutSet.has(i)) {
|
|
1549
|
-
cur.push(
|
|
1549
|
+
cur.push(_chunk7AUQ2UJ3cjs.cloneAnchor.call(void 0, a));
|
|
1550
1550
|
return;
|
|
1551
1551
|
}
|
|
1552
1552
|
if (cur.length) {
|
|
@@ -1561,10 +1561,10 @@ function cutSubpathAt(sp, at) {
|
|
|
1561
1561
|
}
|
|
1562
1562
|
function splitSubpathAt(sp, segment, t, endTolerance = 1e-6) {
|
|
1563
1563
|
const n = sp.anchors.length;
|
|
1564
|
-
if (segment < 0 || segment >=
|
|
1564
|
+
if (segment < 0 || segment >= _chunk7AUQ2UJ3cjs.subpathSegmentCount.call(void 0, sp)) return [{ anchors: sp.anchors.map(_chunk7AUQ2UJ3cjs.cloneAnchor), closed: sp.closed }];
|
|
1565
1565
|
if (t <= endTolerance) return cutSubpathAt(sp, [segment]);
|
|
1566
1566
|
if (t >= 1 - endTolerance) return cutSubpathAt(sp, [(segment + 1) % n]);
|
|
1567
|
-
const { subpath, index } =
|
|
1567
|
+
const { subpath, index } = _chunk7AUQ2UJ3cjs.insertAnchor.call(void 0, sp, segment, t);
|
|
1568
1568
|
return cutSubpathAt(subpath, [index]);
|
|
1569
1569
|
}
|
|
1570
1570
|
var endOf = (sp, last) => sp.anchors[last ? sp.anchors.length - 1 : 0];
|
|
@@ -1587,7 +1587,7 @@ function joinSubpaths(subpaths, tolerance) {
|
|
|
1587
1587
|
const closed = [];
|
|
1588
1588
|
let open = [];
|
|
1589
1589
|
for (const sp of subpaths) {
|
|
1590
|
-
const copy = { anchors: sp.anchors.map(
|
|
1590
|
+
const copy = { anchors: sp.anchors.map(_chunk7AUQ2UJ3cjs.cloneAnchor), closed: sp.closed };
|
|
1591
1591
|
if (sp.closed || sp.anchors.length < 2) {
|
|
1592
1592
|
if (sp.anchors.length) closed.push(copy);
|
|
1593
1593
|
} else open.push(copy);
|
|
@@ -1642,7 +1642,7 @@ function smoothSubpath(sp, amount = 1, only) {
|
|
|
1642
1642
|
const t = Math.min(1, Math.max(0, amount));
|
|
1643
1643
|
const orig = sp.anchors;
|
|
1644
1644
|
const n = orig.length;
|
|
1645
|
-
const anchors = orig.map(
|
|
1645
|
+
const anchors = orig.map(_chunk7AUQ2UJ3cjs.cloneAnchor);
|
|
1646
1646
|
if (n < 3 || t === 0) return { anchors, closed: sp.closed };
|
|
1647
1647
|
for (let i = 0; i < n; i++) {
|
|
1648
1648
|
if (!sp.closed && (i === 0 || i === n - 1)) continue;
|
|
@@ -1671,8 +1671,8 @@ function smoothSubpath(sp, amount = 1, only) {
|
|
|
1671
1671
|
}
|
|
1672
1672
|
function segsOf(sp) {
|
|
1673
1673
|
const out = [];
|
|
1674
|
-
for (let i = 0; i <
|
|
1675
|
-
const s =
|
|
1674
|
+
for (let i = 0; i < _chunk7AUQ2UJ3cjs.subpathSegmentCount.call(void 0, sp); i++) {
|
|
1675
|
+
const s = _chunk7AUQ2UJ3cjs.subpathSegment.call(void 0, sp, i);
|
|
1676
1676
|
out.push(s.length === 2 ? { c: s, line: true } : { c: s, line: false });
|
|
1677
1677
|
}
|
|
1678
1678
|
return out;
|
|
@@ -1729,7 +1729,7 @@ function removeRedundantPoints(sp, tolerance) {
|
|
|
1729
1729
|
const tol = Math.max(tolerance, 1e-9);
|
|
1730
1730
|
const types = new Map(sp.anchors.filter((a) => a.type).map((a) => [`${a.x},${a.y}`, a.type]));
|
|
1731
1731
|
const segs = segsOf(sp).filter((s) => !isZeroSeg(s));
|
|
1732
|
-
if (!segs.length) return { anchors: sp.anchors.map(
|
|
1732
|
+
if (!segs.length) return { anchors: sp.anchors.map(_chunk7AUQ2UJ3cjs.cloneAnchor), closed: sp.closed };
|
|
1733
1733
|
const minSegs = sp.closed ? 2 : 1;
|
|
1734
1734
|
let changed = true;
|
|
1735
1735
|
while (changed && segs.length > minSegs) {
|
|
@@ -1747,7 +1747,7 @@ function removeRedundantPoints(sp, tolerance) {
|
|
|
1747
1747
|
break;
|
|
1748
1748
|
}
|
|
1749
1749
|
}
|
|
1750
|
-
return _nullishCoalesce(segsToSubpath(segs, sp.closed, types), () => ( { anchors: sp.anchors.map(
|
|
1750
|
+
return _nullishCoalesce(segsToSubpath(segs, sp.closed, types), () => ( { anchors: sp.anchors.map(_chunk7AUQ2UJ3cjs.cloneAnchor), closed: sp.closed }));
|
|
1751
1751
|
}
|
|
1752
1752
|
|
|
1753
1753
|
|