@pixerate/editor 0.280.0 → 0.282.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 +59 -59
- package/dist/animation-editor/index.js +3 -3
- package/dist/brushes/index.cjs +76 -71
- package/dist/brushes/index.js +13 -8
- package/dist/brushes/schema.d.cts +1 -0
- package/dist/brushes/schema.d.ts +1 -0
- package/dist/brushes/types.d.cts +29 -3
- package/dist/brushes/types.d.ts +29 -3
- package/dist/{brushstrokeRender-EIK3625T.js → brushstrokeRender-4MA5CBW3.js} +3 -3
- package/dist/{brushstrokeRender-7HOMKZNO.cjs → brushstrokeRender-JVKVKWDA.cjs} +15 -15
- package/dist/canvas/edge-animation-tools.d.cts +115 -0
- package/dist/canvas/edge-animation-tools.d.ts +115 -0
- package/dist/canvas/edgeAnimation.d.cts +164 -0
- package/dist/canvas/edgeAnimation.d.ts +164 -0
- package/dist/canvas/edgePaths.d.cts +63 -0
- package/dist/canvas/edgePaths.d.ts +63 -0
- package/dist/canvas/index.cjs +691 -21
- package/dist/canvas/index.d.cts +3 -0
- package/dist/canvas/index.d.ts +3 -0
- package/dist/canvas/index.js +679 -9
- package/dist/{chunk-NJDEKU5D.js → chunk-2YGYYVSG.js} +1 -1
- package/dist/{chunk-JVFGK3DK.cjs → chunk-3JUKN3RM.cjs} +76 -53
- package/dist/{chunk-HN57I7KT.js → chunk-CG3FBNXE.js} +1 -1
- package/dist/{chunk-WFSYZO5Z.cjs → chunk-DFZ4I7EZ.cjs} +1 -1
- package/dist/{chunk-LZE2QZCT.js → chunk-IHMMHZGP.js} +1 -1
- package/dist/{chunk-K4ANWBF7.cjs → chunk-IJQ2YH2M.cjs} +35 -35
- package/dist/{chunk-HRUK5TFW.cjs → chunk-IUKPQCYQ.cjs} +164 -71
- package/dist/{chunk-WCC4NXWY.cjs → chunk-JD63B33V.cjs} +86 -86
- package/dist/{chunk-NJLPW4MM.js → chunk-KV7QHPKL.js} +27 -4
- package/dist/{chunk-H3EME3S5.cjs → chunk-MRIAR5DY.cjs} +2 -2
- package/dist/{chunk-ROURHJYT.js → chunk-NEDS6DSC.js} +1 -1
- package/dist/{chunk-FKO3CY2C.js → chunk-ULPXJ3NB.js} +1 -1
- package/dist/{chunk-WZYRYYXN.cjs → chunk-UOM5S4W5.cjs} +12 -12
- package/dist/{chunk-YOM76H2V.js → chunk-VEX6YVNG.js} +1 -1
- package/dist/{chunk-MNHP3AQT.cjs → chunk-WEXWDBUF.cjs} +23 -23
- package/dist/{chunk-PPDUCZZV.js → chunk-YRGTQLDN.js} +122 -29
- package/dist/image-editor/index.cjs +788 -788
- package/dist/image-editor/index.js +4 -4
- package/dist/paint-editor/antimatter.d.cts +154 -0
- package/dist/paint-editor/antimatter.d.ts +154 -0
- package/dist/paint-editor/brush-controls.d.cts +1 -0
- package/dist/paint-editor/brush-controls.d.ts +1 -0
- package/dist/paint-editor/brush-model.d.cts +9 -5
- package/dist/paint-editor/brush-model.d.ts +9 -5
- package/dist/paint-editor/controller.d.cts +23 -0
- package/dist/paint-editor/controller.d.ts +23 -0
- package/dist/paint-editor/index.cjs +1931 -891
- package/dist/paint-editor/index.d.cts +1 -0
- package/dist/paint-editor/index.d.ts +1 -0
- package/dist/paint-editor/index.js +1098 -58
- package/dist/paint-editor/mark-settings.d.cts +30 -0
- package/dist/paint-editor/mark-settings.d.ts +30 -0
- package/dist/paint-editor/stroke.d.cts +16 -0
- package/dist/paint-editor/stroke.d.ts +16 -0
- package/dist/paint-editor/strokes.d.cts +2 -0
- package/dist/paint-editor/strokes.d.ts +2 -0
- package/dist/paint-editor/ui.d.cts +4 -2
- package/dist/paint-editor/ui.d.ts +4 -2
- package/dist/vector/index.cjs +999 -999
- package/dist/vector/index.js +4 -4
- package/package.json +1 -1
- package/skills/pixerate-brushes/SKILL.md +1 -1
- package/skills/pixerate-canvas/SKILL.md +25 -2
- package/skills/pixerate-paint-editor/SKILL.md +8 -2
- package/skills/pixerate-paint-editor/references/antimatter.md +49 -0
- package/skills/pixerate-paint-editor/references/brush-facets.md +1 -0
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
resolveEngine,
|
|
29
29
|
summarizeBrushSource,
|
|
30
30
|
withKeptIssues
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-YRGTQLDN.js";
|
|
32
32
|
import {
|
|
33
33
|
base64ToBytes
|
|
34
34
|
} from "./chunk-OTTT5N3K.js";
|
|
@@ -1142,17 +1142,30 @@ var MUTATION_SLIDERS = [
|
|
|
1142
1142
|
{ path: "mutation.patience", label: "Patience", min: 5, max: 300, step: 5 },
|
|
1143
1143
|
{ path: "mutation.fade", label: "Fade", min: 0.5, max: 10, step: 0.5 }
|
|
1144
1144
|
];
|
|
1145
|
+
var ANTIMATTER_SLIDERS = [
|
|
1146
|
+
{ path: "antimatter.blastRadius", label: "Blast size", min: 1, max: 6, step: 0.1 },
|
|
1147
|
+
{ path: "antimatter.blastSpacing", label: "Blast spacing", min: 0.5, max: 8, step: 0.1 },
|
|
1148
|
+
{ path: "antimatter.threshold", label: "Fuel threshold", min: 0, max: 1, step: 0.01 },
|
|
1149
|
+
{ path: "antimatter.invert", label: "Inversion", min: 0, max: 1, step: 0.01 },
|
|
1150
|
+
{ path: "antimatter.scorch", label: "Scorch", min: 0, max: 1, step: 0.01 },
|
|
1151
|
+
{ path: "antimatter.annihilate", label: "Annihilate", min: 0, max: 1, step: 0.01 },
|
|
1152
|
+
{ path: "antimatter.sparks", label: "Sparks", min: 0, max: 1, step: 0.01 },
|
|
1153
|
+
{ path: "antimatter.sparkReach", label: "Spark reach", min: 0.5, max: 8, step: 0.1 },
|
|
1154
|
+
{ path: "antimatter.crater", label: "Crater depth", min: 0, max: 1, step: 0.01 },
|
|
1155
|
+
{ path: "antimatter.duration", label: "Blast duration", min: 0, max: 2, step: 0.05 }
|
|
1156
|
+
];
|
|
1145
1157
|
function brushEngineControls(brush) {
|
|
1146
1158
|
const c = engineControls(brush);
|
|
1147
1159
|
if (!c) return null;
|
|
1148
1160
|
const mut = brush.mutation ? MUTATION_SLIDERS : [];
|
|
1149
1161
|
const wetPaint = brush.engine === "wet" && brush.wet?.tool === "paint" && !brush.ghost && !brush.mutation;
|
|
1150
|
-
if (!(wetPaint || ["dab", "mixer", "particle", "bristle", "impasto"].includes(brush.engine))) {
|
|
1162
|
+
if (!(wetPaint || ["dab", "mixer", "particle", "bristle", "impasto", "antimatter"].includes(brush.engine))) {
|
|
1151
1163
|
return mut.length ? { ...c, sliders: [...c.sliders, ...mut] } : c;
|
|
1152
1164
|
}
|
|
1153
1165
|
const extra = brush.engine === "impasto" ? [{ path: "impasto.rim", label: "Rim", min: 0, max: 1, step: 0.01 }, { path: "impasto.clarity", label: "Clarity", min: 0, max: 1, step: 0.01 }] : [];
|
|
1154
|
-
const
|
|
1155
|
-
|
|
1166
|
+
const canFilm = brush.engine !== "antimatter";
|
|
1167
|
+
const film = canFilm && brush.iridescence ? IRIDESCENCE_SLIDERS : [];
|
|
1168
|
+
return { ...c, sliders: [...c.sliders, ...mut, LIGHT_SLIDER, ...extra, ...film], light: true, iridescence: canFilm };
|
|
1156
1169
|
}
|
|
1157
1170
|
function engineControls(brush) {
|
|
1158
1171
|
switch (brush.engine) {
|
|
@@ -1213,6 +1226,15 @@ function engineControls(brush) {
|
|
|
1213
1226
|
load: false,
|
|
1214
1227
|
stickerStamps: true
|
|
1215
1228
|
};
|
|
1229
|
+
case "antimatter":
|
|
1230
|
+
return {
|
|
1231
|
+
title: "Antimatter",
|
|
1232
|
+
sliders: ANTIMATTER_SLIDERS,
|
|
1233
|
+
mixingPath: null,
|
|
1234
|
+
dirty: false,
|
|
1235
|
+
multicolor: false,
|
|
1236
|
+
load: false
|
|
1237
|
+
};
|
|
1216
1238
|
case "impasto":
|
|
1217
1239
|
return {
|
|
1218
1240
|
title: "Thick paint",
|
|
@@ -1318,6 +1340,7 @@ export {
|
|
|
1318
1340
|
IRIDESCENCE_SLIDERS,
|
|
1319
1341
|
GHOST_SLIDERS,
|
|
1320
1342
|
MUTATION_SLIDERS,
|
|
1343
|
+
ANTIMATTER_SLIDERS,
|
|
1321
1344
|
brushEngineControls,
|
|
1322
1345
|
multiColorSliders,
|
|
1323
1346
|
patchBrushValue
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkIUKPQCYQcjs = require('./chunk-IUKPQCYQ.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var _chunkJBZRVLXVcjs = require('./chunk-JBZRVLXV.cjs');
|
|
@@ -44,7 +44,7 @@ function brushPreviewStrength(brush) {
|
|
|
44
44
|
}
|
|
45
45
|
var over = (fg, bg, alpha) => ({ r: fg.r * alpha + bg.r * (1 - alpha), g: fg.g * alpha + bg.g * (1 - alpha), b: fg.b * alpha + bg.b * (1 - alpha), a: 1 });
|
|
46
46
|
function brushPreviewColours(brush, options = {}) {
|
|
47
|
-
const profile = _nullishCoalesce(options.profile, () => (
|
|
47
|
+
const profile = _nullishCoalesce(options.profile, () => ( _chunkIUKPQCYQcjs.PAINT_PROFILE));
|
|
48
48
|
let background = profile.light === "full" && brushPreviewsOnDark(brush) ? BRUSH_PREVIEW_DARK_PAPER : hexOf(_nullishCoalesce(options.paper, () => ( "#ffffff")));
|
|
49
49
|
if (!options.keepPaper && brush.tip.blend === "multiply" && _chunk5UEFBM2Mcjs.relativeLuminance.call(void 0, _chunk5UEFBM2Mcjs.parseColor.call(void 0, background)) < 0.18) background = "#ffffff";
|
|
50
50
|
const bg = _chunk5UEFBM2Mcjs.parseColor.call(void 0, background);
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkIUKPQCYQcjs = require('./chunk-IUKPQCYQ.cjs');
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
@@ -2796,7 +2796,7 @@ function effectDabField(img, rect, cov, centre, mixed, field, steps = 0, dab = n
|
|
|
2796
2796
|
var samplers = /* @__PURE__ */ new WeakMap();
|
|
2797
2797
|
function stampSampler(ref, art, hardness = 1) {
|
|
2798
2798
|
const sampler = baseSampler(ref, art);
|
|
2799
|
-
if (!sampler || hardness >= 1 || !
|
|
2799
|
+
if (!sampler || hardness >= 1 || !_chunkIUKPQCYQcjs.isBrushSourceRef.call(void 0, ref)) return sampler;
|
|
2800
2800
|
const h = Math.max(0, hardness);
|
|
2801
2801
|
return (u, v2, seed) => {
|
|
2802
2802
|
const r = Math.hypot(u, v2) / Math.SQRT2;
|
|
@@ -2871,7 +2871,7 @@ function rasterizeStampDab(d, sample, seed, rect, out) {
|
|
|
2871
2871
|
}
|
|
2872
2872
|
function brushStickerRefs(brush) {
|
|
2873
2873
|
const refs = brush.engine === "sticker" ? [...brush.sticker.stamps] : brush.engine === "particle" ? [...brush.particle.dotTextures] : brush.engine === "dab" && brush.stamp ? [brush.stamp] : [];
|
|
2874
|
-
return [...new Set(refs.filter((r) => r.includes(":") && !r.startsWith("editor:") && !
|
|
2874
|
+
return [...new Set(refs.filter((r) => r.includes(":") && !r.startsWith("editor:") && !_chunkIUKPQCYQcjs.isBrushSourceRef.call(void 0, r)))];
|
|
2875
2875
|
}
|
|
2876
2876
|
function sprayDroplets(d, spray, seed) {
|
|
2877
2877
|
const count = 1 + Math.round(spray.density * 31);
|
|
@@ -4802,11 +4802,11 @@ function renderBackdropBrushstroke(input, brush, options) {
|
|
|
4802
4802
|
|
|
4803
4803
|
// src/vector/brushstroke.ts
|
|
4804
4804
|
var VECTOR_BRUSHSTROKE_SCALE = 2;
|
|
4805
|
-
var PRESETS =
|
|
4805
|
+
var PRESETS = _chunkIUKPQCYQcjs.listPresets.call(void 0, _chunkIUKPQCYQcjs.VECTOR_PROFILE).map((spec) => _chunkIUKPQCYQcjs.BUILTIN_BRUSHES.find((b) => b.id === spec.id));
|
|
4806
4806
|
function admitted(spec) {
|
|
4807
4807
|
try {
|
|
4808
|
-
const brush =
|
|
4809
|
-
return
|
|
4808
|
+
const brush = _chunkIUKPQCYQcjs.normalizeBrushSpec.call(void 0, spec);
|
|
4809
|
+
return _chunkIUKPQCYQcjs.checkBrush.call(void 0, brush, _chunkIUKPQCYQcjs.VECTOR_PROFILE).ok && isVectorBrushstrokeEngine(_chunkIUKPQCYQcjs.resolveBrush.call(void 0, brush)) ? brush : null;
|
|
4810
4810
|
} catch (e6) {
|
|
4811
4811
|
return null;
|
|
4812
4812
|
}
|
|
@@ -4818,7 +4818,7 @@ function vectorBrushstrokeBrushes(user = []) {
|
|
|
4818
4818
|
const out = [...PRESETS];
|
|
4819
4819
|
for (const raw of user) {
|
|
4820
4820
|
const brush = admitted(raw);
|
|
4821
|
-
if (brush && !out.some((b) => b.id === brush.id)) out.push(
|
|
4821
|
+
if (brush && !out.some((b) => b.id === brush.id)) out.push(_chunkIUKPQCYQcjs.resolveBrush.call(void 0, brush));
|
|
4822
4822
|
}
|
|
4823
4823
|
return out;
|
|
4824
4824
|
}
|
|
@@ -4828,7 +4828,7 @@ function vectorBrushstrokeBrush(id) {
|
|
|
4828
4828
|
function vectorBrushstrokeBrushOf(brush) {
|
|
4829
4829
|
if (brush.spec) {
|
|
4830
4830
|
const saved = admitted(brush.spec);
|
|
4831
|
-
return saved && saved.id === brush.brushId ?
|
|
4831
|
+
return saved && saved.id === brush.brushId ? _chunkIUKPQCYQcjs.resolveBrush.call(void 0, saved) : null;
|
|
4832
4832
|
}
|
|
4833
4833
|
return vectorBrushstrokeBrush(brush.brushId);
|
|
4834
4834
|
}
|
|
@@ -4836,14 +4836,14 @@ function vectorBrushstrokeBrushError(id, user = []) {
|
|
|
4836
4836
|
if (vectorBrushstrokeBrush(id)) return null;
|
|
4837
4837
|
const saved = user.find((b) => b.id === id);
|
|
4838
4838
|
const ids = vectorBrushstrokeBrushes(user).map((b) => b.id);
|
|
4839
|
-
const reasons = (b) =>
|
|
4839
|
+
const reasons = (b) => _chunkIUKPQCYQcjs.checkBrush.call(void 0, b, _chunkIUKPQCYQcjs.VECTOR_PROFILE).issues.filter((i) => i.severity === "error").map((i) => `${i.reason} ${i.fix}`).join(" ") || "its engine does not paint brushstrokes.";
|
|
4840
4840
|
if (saved) return admitted(saved) ? null : `Brush "${id}" (${saved.name}) can't paint a brushstroke: ${reasons(saved)} Use one of: ${ids.join(", ")}.`;
|
|
4841
|
-
const preset2 =
|
|
4841
|
+
const preset2 = _chunkIUKPQCYQcjs.BRUSH_PRESETS.find((b) => b.id === id);
|
|
4842
4842
|
if (preset2) return `Brush "${id}" (${preset2.name}) can't paint a brushstroke: ${reasons(preset2)} Use one of: ${ids.join(", ")}.`;
|
|
4843
|
-
return `Unknown brush "${id}". ${
|
|
4843
|
+
return `Unknown brush "${id}". ${_chunkIUKPQCYQcjs.closest.call(void 0, id, ids)}Use one of: ${ids.join(", ")} (vector.listBrushes lists them).`;
|
|
4844
4844
|
}
|
|
4845
4845
|
function vectorBrushstrokeDefaultColour(id, user = [], scheme = "light") {
|
|
4846
|
-
const brush = _nullishCoalesce(
|
|
4846
|
+
const brush = _nullishCoalesce(_chunkIUKPQCYQcjs.BRUSH_PRESETS.find((b) => b.id === id), () => ( user.find((b) => b.id === id)));
|
|
4847
4847
|
return brush ? _chunkJBZRVLXVcjs.brushColourHex.call(void 0, _optionalChain([brush, 'access', _212 => _212.colour, 'optionalAccess', _213 => _213.default]), scheme) : null;
|
|
4848
4848
|
}
|
|
4849
4849
|
function sanitizeVectorBrushstroke(value, user = []) {
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkUOM5S4W5cjs = require('./chunk-UOM5S4W5.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 = _chunkUOM5S4W5cjs.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) => _chunkUOM5S4W5cjs.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 = _chunkUOM5S4W5cjs.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 = _chunkUOM5S4W5cjs.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(_chunkUOM5S4W5cjs.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(_chunkUOM5S4W5cjs.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(_chunkUOM5S4W5cjs.cloneAnchor);
|
|
1474
1474
|
const n = anchors.length;
|
|
1475
|
-
if (segment < 0 || segment >=
|
|
1475
|
+
if (segment < 0 || segment >= _chunkUOM5S4W5cjs.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] = _chunkUOM5S4W5cjs.moveAnchorHandle.call(void 0, a, "out", c1);
|
|
1487
|
+
anchors[ib] = _chunkUOM5S4W5cjs.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, _chunkUOM5S4W5cjs.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(_chunkUOM5S4W5cjs.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(_chunkUOM5S4W5cjs.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(_chunkUOM5S4W5cjs.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 >= _chunkUOM5S4W5cjs.subpathSegmentCount.call(void 0, sp)) return [{ anchors: sp.anchors.map(_chunkUOM5S4W5cjs.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 } = _chunkUOM5S4W5cjs.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(_chunkUOM5S4W5cjs.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(_chunkUOM5S4W5cjs.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 < _chunkUOM5S4W5cjs.subpathSegmentCount.call(void 0, sp); i++) {
|
|
1675
|
+
const s = _chunkUOM5S4W5cjs.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(_chunkUOM5S4W5cjs.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(_chunkUOM5S4W5cjs.cloneAnchor), closed: sp.closed }));
|
|
1751
1751
|
}
|
|
1752
1752
|
|
|
1753
1753
|
|