@pixerate/editor 0.53.0 → 0.55.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 +20 -12
- package/dist/agent/index.cjs.map +1 -1
- package/dist/agent/index.d.cts +4 -3
- package/dist/agent/index.d.ts +4 -3
- package/dist/agent/index.js +18 -10
- package/dist/agent/index.js.map +1 -1
- package/dist/animation/index.cjs +16 -2
- package/dist/animation/index.cjs.map +1 -1
- package/dist/animation/index.d.cts +4 -226
- package/dist/animation/index.d.ts +4 -226
- package/dist/animation/index.js +15 -1
- package/dist/animation-editor/index.cjs +2221 -0
- package/dist/animation-editor/index.cjs.map +1 -0
- package/dist/animation-editor/index.d.cts +1117 -0
- package/dist/animation-editor/index.d.ts +1117 -0
- package/dist/animation-editor/index.js +2221 -0
- package/dist/animation-editor/index.js.map +1 -0
- package/dist/bezier-BfwIbVTl.d.cts +548 -0
- package/dist/bezier-DYBvLgUH.d.ts +548 -0
- package/dist/bridge/cli.cjs +36 -0
- package/dist/bridge/cli.cjs.map +1 -0
- package/dist/bridge/cli.d.cts +1 -0
- package/dist/bridge/cli.d.ts +1 -0
- package/dist/bridge/cli.js +36 -0
- package/dist/bridge/cli.js.map +1 -0
- package/dist/bridge/index.cjs +16 -0
- package/dist/bridge/index.cjs.map +1 -0
- package/dist/bridge/index.d.cts +65 -0
- package/dist/bridge/index.d.ts +65 -0
- package/dist/bridge/index.js +16 -0
- package/dist/bridge/index.js.map +1 -0
- package/dist/bridge-client-C5OziCRK.d.cts +148 -0
- package/dist/bridge-client-C5dRjrz5.d.ts +148 -0
- package/dist/canvas/index.cjs +1564 -557
- package/dist/canvas/index.cjs.map +1 -1
- package/dist/canvas/index.d.cts +411 -7
- package/dist/canvas/index.d.ts +411 -7
- package/dist/canvas/index.js +1559 -552
- package/dist/canvas/index.js.map +1 -1
- package/dist/chart/index.cjs +34 -76
- package/dist/chart/index.cjs.map +1 -1
- package/dist/chart/index.d.cts +9 -38
- package/dist/chart/index.d.ts +9 -38
- package/dist/chart/index.js +23 -65
- package/dist/chart/index.js.map +1 -1
- package/dist/chunk-AWKPSOSX.js +401 -0
- package/dist/chunk-AWKPSOSX.js.map +1 -0
- package/dist/chunk-B6DSIEXA.js +96 -0
- package/dist/chunk-B6DSIEXA.js.map +1 -0
- package/dist/chunk-EGFUVXKK.cjs +96 -0
- package/dist/chunk-EGFUVXKK.cjs.map +1 -0
- package/dist/{chunk-AMWXSYCI.js → chunk-GPWNYQ7R.js} +2 -370
- package/dist/chunk-GPWNYQ7R.js.map +1 -0
- package/dist/{chunk-TO22LX34.js → chunk-GTMJ4Y3S.js} +2208 -2920
- package/dist/chunk-GTMJ4Y3S.js.map +1 -0
- package/dist/chunk-H5K77C7Y.cjs +3848 -0
- package/dist/chunk-H5K77C7Y.cjs.map +1 -0
- package/dist/chunk-K73CKYUM.cjs +458 -0
- package/dist/chunk-K73CKYUM.cjs.map +1 -0
- package/dist/chunk-MLREO6J3.cjs +737 -0
- package/dist/chunk-MLREO6J3.cjs.map +1 -0
- package/dist/chunk-NONDTTH7.js +5979 -0
- package/dist/chunk-NONDTTH7.js.map +1 -0
- package/dist/chunk-NV22EMOZ.cjs +401 -0
- package/dist/chunk-NV22EMOZ.cjs.map +1 -0
- package/dist/{chunk-YNSK4MGT.cjs → chunk-O2UH7LZE.cjs} +1549 -2261
- package/dist/chunk-O2UH7LZE.cjs.map +1 -0
- package/dist/chunk-PTMIGXZ2.js +467 -0
- package/dist/chunk-PTMIGXZ2.js.map +1 -0
- package/dist/chunk-QIWFEEWG.cjs +467 -0
- package/dist/chunk-QIWFEEWG.cjs.map +1 -0
- package/dist/chunk-VWZB6BCY.js +737 -0
- package/dist/chunk-VWZB6BCY.js.map +1 -0
- package/dist/chunk-WWJNC7SX.js +3848 -0
- package/dist/chunk-WWJNC7SX.js.map +1 -0
- package/dist/chunk-XCXQDPID.cjs +5979 -0
- package/dist/chunk-XCXQDPID.cjs.map +1 -0
- package/dist/color-E9pwm--w.d.cts +33 -0
- package/dist/color-E9pwm--w.d.ts +33 -0
- package/dist/commands/index.cjs +2 -2
- package/dist/commands/index.cjs.map +1 -1
- package/dist/commands/index.d.cts +1 -1
- package/dist/commands/index.d.ts +1 -1
- package/dist/commands/index.js +3 -3
- package/dist/diagram/index.cjs +1167 -0
- package/dist/diagram/index.cjs.map +1 -0
- package/dist/diagram/index.d.cts +810 -0
- package/dist/diagram/index.d.ts +810 -0
- package/dist/diagram/index.js +1167 -0
- package/dist/diagram/index.js.map +1 -0
- package/dist/{easing-DTmX99QG.d.cts → easing-CNGk-W6d.d.cts} +1 -1
- package/dist/{easing-DTmX99QG.d.ts → easing-CNGk-W6d.d.ts} +1 -1
- package/dist/generation/index.d.cts +2 -2
- package/dist/generation/index.d.ts +2 -2
- package/dist/image-editor/index.d.cts +1 -1
- package/dist/image-editor/index.d.ts +1 -1
- package/dist/parameters/index.d.cts +1 -1
- package/dist/parameters/index.d.ts +1 -1
- package/dist/pathfinder-BZL8aSu0.d.cts +469 -0
- package/dist/pathfinder-CNtsbCRK.d.ts +469 -0
- package/dist/player-Dg0FT0UI.d.cts +193 -0
- package/dist/player-W-5DX3Go.d.ts +193 -0
- package/dist/presence-Cb6WhcrQ.d.cts +77 -0
- package/dist/presence-Cb6WhcrQ.d.ts +77 -0
- package/dist/{registry-CSlH4iUn.d.ts → registry-7AZFuand.d.ts} +1 -1
- package/dist/{registry-B4l-lYts.d.cts → registry-DIpIaCkH.d.cts} +1 -1
- package/dist/svg-CLg2zqZA.d.cts +847 -0
- package/dist/svg-CPK82TtU.d.ts +847 -0
- package/dist/tools/index.cjs +10 -2
- package/dist/tools/index.cjs.map +1 -1
- package/dist/tools/index.d.cts +3 -74
- package/dist/tools/index.d.ts +3 -74
- package/dist/tools/index.js +12 -4
- package/dist/types-BULrFyuQ.d.cts +316 -0
- package/dist/types-BULrFyuQ.d.ts +316 -0
- package/dist/vector/index.cjs +1328 -6752
- package/dist/vector/index.cjs.map +1 -1
- package/dist/vector/index.d.cts +7 -847
- package/dist/vector/index.d.ts +7 -847
- package/dist/vector/index.js +645 -6069
- package/dist/vector/index.js.map +1 -1
- package/package.json +19 -1
- package/dist/chunk-AMWXSYCI.js.map +0 -1
- package/dist/chunk-TO22LX34.js.map +0 -1
- package/dist/chunk-XFYUFVAX.cjs +0 -826
- package/dist/chunk-XFYUFVAX.cjs.map +0 -1
- package/dist/chunk-YNSK4MGT.cjs.map +0 -1
- package/dist/pathfinder-B9xh_pCZ.d.ts +0 -1013
- package/dist/pathfinder-QdG70sr9.d.cts +0 -1013
|
@@ -0,0 +1,469 @@
|
|
|
1
|
+
import { P as Point } from './types-BFkYA4eF.cjs';
|
|
2
|
+
import { B as BezierPath, P as PolygonBooleanOperation, a as BezierPathInput, b as PolygonFillRule, c as BezierSegment, d as BezierContour } from './bezier-BfwIbVTl.cjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Curve-preserving boolean operations (union, intersection, difference, xor and divide) on
|
|
6
|
+
* Bézier paths.
|
|
7
|
+
*
|
|
8
|
+
* Algorithm (planar arrangement of curve pieces + winding classification):
|
|
9
|
+
* 1. Every segment of every operand (open subpaths closed for filling) is a *source*; it is
|
|
10
|
+
* cut into pieces monotone in x and y. Each piece remembers its source and its parameter
|
|
11
|
+
* range there, so results can be rebuilt from exact sub-curves of the inputs.
|
|
12
|
+
* 2. Pieces are intersected pairwise (pruned by a sweep on x): lines analytically, curves by
|
|
13
|
+
* recursive subdivision down to flat sub-curves, chord intersection and Newton polishing.
|
|
14
|
+
* Endpoints lying on another piece (T-junctions, tangent touches), collinear / coincident
|
|
15
|
+
* overlaps and clusters of hits along a tangency are resolved first. Points closer than
|
|
16
|
+
* `epsilon` share one vertex. Splitting repeats until no piece crosses another.
|
|
17
|
+
* 3. Coincident pieces (shared edges, identical curves) merge into one edge carrying every
|
|
18
|
+
* operand's signed multiplicity.
|
|
19
|
+
* 4. Each edge is classified by casting a horizontal or vertical ray from its midpoint (the
|
|
20
|
+
* pieces are monotone, so a ray crosses each at most once); the operands' fill rules turn
|
|
21
|
+
* the winding numbers on both sides into inside flags and the operation picks the edges
|
|
22
|
+
* with the result on exactly one side.
|
|
23
|
+
* 5. The kept edges are traced into rings, taking the sharpest left turn at each vertex
|
|
24
|
+
* (ties between tangent curves broken by a short chord along each curve), and consecutive
|
|
25
|
+
* pieces of one source are merged back into one exact sub-curve, so circles stay four
|
|
26
|
+
* cubics and rectangles four lines.
|
|
27
|
+
*
|
|
28
|
+
* When the curve engine fails (non-converging intersections on near-coincident curves,
|
|
29
|
+
* an inconsistent arrangement) the operation falls back to the polygon engine
|
|
30
|
+
* (`polygonBoolean`) on flattened input and reports it (`engine: 'polygon'`).
|
|
31
|
+
*
|
|
32
|
+
* Portions ported from vectorcraft-main/crates/pathops/src/boolean.rs (MIT OR Apache-2.0,
|
|
33
|
+
* © ArtCraft Team and contributors). See THIRD_PARTY_NOTICES.md.
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
/** Boolean operations (same names as `polygonBoolean`). `xor` is Exclude. */
|
|
37
|
+
type PathBooleanOperation = PolygonBooleanOperation;
|
|
38
|
+
/** A path with the fill rule it is read with (default `nonzero`). */
|
|
39
|
+
interface PathOperand {
|
|
40
|
+
path: BezierPathInput;
|
|
41
|
+
fillRule?: PolygonFillRule;
|
|
42
|
+
}
|
|
43
|
+
type PathOperandInput = BezierPathInput | PathOperand;
|
|
44
|
+
interface PathOpsOptions {
|
|
45
|
+
/**
|
|
46
|
+
* Distance below which points are treated as equal. Defaults to `1e-9` times the
|
|
47
|
+
* largest coordinate magnitude (at least `1e-9`).
|
|
48
|
+
*/
|
|
49
|
+
epsilon?: number;
|
|
50
|
+
/** Fall back to the polygon engine when the curve engine fails (default `true`). */
|
|
51
|
+
fallback?: boolean;
|
|
52
|
+
/** Flattening tolerance used by the polygon fallback (default 0.05). */
|
|
53
|
+
fallbackTolerance?: number;
|
|
54
|
+
/** Called with the reason whenever the polygon fallback is used. */
|
|
55
|
+
onFallback?: (reason: string) => void;
|
|
56
|
+
/**
|
|
57
|
+
* Work budget of the curve–curve intersection search (flat sub-curve pairs per pair of
|
|
58
|
+
* pieces, default 20,000). Exceeding it (nearly coincident curves) falls back.
|
|
59
|
+
*/
|
|
60
|
+
subdivisionBudget?: number;
|
|
61
|
+
}
|
|
62
|
+
/** Which engine produced a result, and why the curve engine was not used. */
|
|
63
|
+
interface PathOpsReport {
|
|
64
|
+
engine: 'curve' | 'polygon';
|
|
65
|
+
fallbackReason?: string;
|
|
66
|
+
/** Set when the input cannot be processed at all (non-finite coordinates); the result is empty. */
|
|
67
|
+
error?: string;
|
|
68
|
+
}
|
|
69
|
+
interface PathBooleanResult extends PathOpsReport {
|
|
70
|
+
path: BezierPath;
|
|
71
|
+
}
|
|
72
|
+
/** One region of `dividePaths`, with the indices of the operands that cover it. */
|
|
73
|
+
interface PathPiece {
|
|
74
|
+
path: BezierPath;
|
|
75
|
+
operands: number[];
|
|
76
|
+
}
|
|
77
|
+
interface DividePathsResult extends PathOpsReport {
|
|
78
|
+
pieces: PathPiece[];
|
|
79
|
+
}
|
|
80
|
+
/** Raised by the curve engine when it cannot produce a reliable arrangement. */
|
|
81
|
+
declare class PathOpsError extends Error {
|
|
82
|
+
constructor(message: string);
|
|
83
|
+
}
|
|
84
|
+
/** A crossing or touch of two segments: the parameter on each and the point. */
|
|
85
|
+
interface SegmentIntersection {
|
|
86
|
+
ta: number;
|
|
87
|
+
tb: number;
|
|
88
|
+
point: Point;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Every point where two segments (lines, quadratics or cubics, as control points) cross or
|
|
92
|
+
* touch, by the same subdivision search the boolean operations use: flat sub-curves, chord
|
|
93
|
+
* intersection, Newton polishing. Hits closer than `epsilon` (default: 1e-9 of the segments'
|
|
94
|
+
* size) are one. Coincident stretches report the hits the search finds along them.
|
|
95
|
+
*/
|
|
96
|
+
declare function segmentIntersections(a: BezierSegment, b: BezierSegment, options?: {
|
|
97
|
+
epsilon?: number;
|
|
98
|
+
budget?: number;
|
|
99
|
+
}): SegmentIntersection[];
|
|
100
|
+
/**
|
|
101
|
+
* Applies a boolean operation to any number of path operands, keeping curves:
|
|
102
|
+
* - `union`: covered by any operand.
|
|
103
|
+
* - `intersection`: covered by every operand.
|
|
104
|
+
* - `difference`: the first operand minus all others.
|
|
105
|
+
* - `xor`: covered by an odd number of operands (Exclude).
|
|
106
|
+
*
|
|
107
|
+
* Open subpaths are closed for filling. Non-finite input gives an empty path (`error`); with
|
|
108
|
+
* `fallback: false` a failure of the curve engine throws a `PathOpsError`. The result is a set of simple closed subpaths that
|
|
109
|
+
* never cross (they may touch at points): outer subpaths run counter-clockwise in a y-up
|
|
110
|
+
* frame (clockwise on screen), holes the other way, so it fills the same with `nonzero`
|
|
111
|
+
* and `evenodd`. Segments of the inputs are kept as exact sub-curves.
|
|
112
|
+
*/
|
|
113
|
+
declare function pathBoolean(operation: PathBooleanOperation, operands: PathOperandInput[], options?: PathOpsOptions): PathBooleanResult;
|
|
114
|
+
declare const unitePaths: (a: PathOperandInput, b: PathOperandInput, options?: PathOpsOptions) => BezierPath;
|
|
115
|
+
declare const intersectPaths: (a: PathOperandInput, b: PathOperandInput, options?: PathOpsOptions) => BezierPath;
|
|
116
|
+
declare const subtractPaths: (a: PathOperandInput, b: PathOperandInput, options?: PathOpsOptions) => BezierPath;
|
|
117
|
+
declare const excludePaths: (a: PathOperandInput, b: PathOperandInput, options?: PathOpsOptions) => BezierPath;
|
|
118
|
+
/**
|
|
119
|
+
* Splits the arrangement of the operands into its regions (Divide): every connected area
|
|
120
|
+
* covered by the same set of operands becomes one piece (an outer subpath with its holes).
|
|
121
|
+
* Pieces are ordered by operand set, then by area (largest first).
|
|
122
|
+
*/
|
|
123
|
+
declare function dividePaths(operands: PathOperandInput[], options?: PathOpsOptions): DividePathsResult;
|
|
124
|
+
/**
|
|
125
|
+
* Resolves self-intersections and overlaps of one filled path into simple, consistently
|
|
126
|
+
* oriented subpaths (outer subpaths and holes) under its fill rule.
|
|
127
|
+
*/
|
|
128
|
+
declare function normalizeBezierPath(path: BezierPathInput, fillRule?: PolygonFillRule, options?: PathOpsOptions): BezierPath;
|
|
129
|
+
/** Filled area of a path under its fill rule (overlaps counted once; exact for curves). */
|
|
130
|
+
declare function bezierPathArea(path: BezierPathInput, fillRule?: PolygonFillRule, options?: PathOpsOptions): number;
|
|
131
|
+
/** One edge of `planarSplit`: a piece of an input segment between two vertices. */
|
|
132
|
+
interface PlanarSplitEdge {
|
|
133
|
+
/** Vertex indices at the start and end of `pts`. */
|
|
134
|
+
a: number;
|
|
135
|
+
b: number;
|
|
136
|
+
/** Control points from vertex `a` to vertex `b`. */
|
|
137
|
+
pts: Point[];
|
|
138
|
+
/** Inputs whose chains run along this edge, ascending (several where outlines coincide). */
|
|
139
|
+
operands: number[];
|
|
140
|
+
/** The source segment it is a piece of (index into `sources`) and its parameters there at `a` and `b`. */
|
|
141
|
+
src: number;
|
|
142
|
+
sa: number;
|
|
143
|
+
sb: number;
|
|
144
|
+
}
|
|
145
|
+
interface PlanarSplitResult {
|
|
146
|
+
vertices: Point[];
|
|
147
|
+
edges: PlanarSplitEdge[];
|
|
148
|
+
/** The input segments, as `src` refers to them. */
|
|
149
|
+
sources: BezierSegment[];
|
|
150
|
+
eps: number;
|
|
151
|
+
scale: number;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* The chains of every input (open or closed, as given: nothing is closed for filling) split
|
|
155
|
+
* wherever they cross or touch each other or themselves, with the same intersection search as
|
|
156
|
+
* the boolean operations. Coincident pieces become one edge that lists every input along it.
|
|
157
|
+
* Throws a `PathOpsError` when the search does not settle or the input is not finite.
|
|
158
|
+
*/
|
|
159
|
+
declare function planarSplit(inputs: readonly (readonly (readonly BezierSegment[])[])[], options?: PathOpsOptions): PlanarSplitResult;
|
|
160
|
+
/** Result of `pathBooleanSelect`: per selector, its connected parts (each an outer subpath with its holes). */
|
|
161
|
+
interface PathSelectResult extends PathOpsReport {
|
|
162
|
+
parts: BezierPath[][];
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Several boolean selections over one arrangement of the operands (the Pathfinder panel's
|
|
166
|
+
* Trim, Merge, Crop and Minus Back are each a selection per output). A selector gets the
|
|
167
|
+
* ascending indices of the operands covering an area and keeps the area when it returns true.
|
|
168
|
+
* Each selection comes back as its connected parts, largest first, built as `pathBoolean`
|
|
169
|
+
* builds its result; areas that only touch at an edge are one part. Falls back to the
|
|
170
|
+
* polygon engine like `pathBoolean`.
|
|
171
|
+
*/
|
|
172
|
+
declare function pathBooleanSelect(operands: PathOperandInput[], selectors: readonly ((covering: readonly number[]) => boolean)[], options?: PathOpsOptions): PathSelectResult;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Offset Path and Outline Stroke on Bézier paths.
|
|
176
|
+
*
|
|
177
|
+
* The stroker offsets every segment by ± half the width (lines exactly, curves by cubic
|
|
178
|
+
* approximations refined until they stay within `tolerance` of the true offset), joins the
|
|
179
|
+
* pieces (miter with a miter limit, round or bevel on the outer side of a turn; through the
|
|
180
|
+
* vertex on the inner side) and adds caps (butt, round, square) to open subpaths. Dashes
|
|
181
|
+
* follow arc length, restart on every subpath and join across the start of a closed
|
|
182
|
+
* subpath. The raw outline overlaps itself, so it is filled with the non-zero rule and
|
|
183
|
+
* normalised with the curve boolean engine.
|
|
184
|
+
*
|
|
185
|
+
* When the stroke is wider than a curve's radius of curvature the inner offset turns inside
|
|
186
|
+
* out and its loops cancel winding, leaving holes that are really covered. Every face of
|
|
187
|
+
* the true result is bounded by the arrangement, so a face is spurious exactly when a point
|
|
188
|
+
* deep inside it is closer to the path than the offset distance (holes when growing,
|
|
189
|
+
* islands when insetting); such faces are dropped.
|
|
190
|
+
*
|
|
191
|
+
* Portions ported from vectorcraft-main/crates/pathops/src/offset.rs,
|
|
192
|
+
* vectorcraft-main/crates/pathops/src/boolean.rs (`try_merge`) and
|
|
193
|
+
* vectorcraft-main/crates/effects/src/stroke/dash.rs (MIT OR Apache-2.0, © ArtCraft Team
|
|
194
|
+
* and contributors). See THIRD_PARTY_NOTICES.md.
|
|
195
|
+
*/
|
|
196
|
+
|
|
197
|
+
/** Line join (as SVG `stroke-linejoin`). */
|
|
198
|
+
type StrokeJoin = 'miter' | 'round' | 'bevel';
|
|
199
|
+
/** Line cap (as SVG `stroke-linecap`). */
|
|
200
|
+
type StrokeCap = 'butt' | 'round' | 'square';
|
|
201
|
+
interface OutlineStrokeOptions extends PathOpsOptions {
|
|
202
|
+
/** Stroke width. Non-positive or non-finite widths give an empty result. */
|
|
203
|
+
width: number;
|
|
204
|
+
/** Default `miter` (as SVG). */
|
|
205
|
+
join?: StrokeJoin;
|
|
206
|
+
/** Default `butt` (as SVG). */
|
|
207
|
+
cap?: StrokeCap;
|
|
208
|
+
/** Miter length / stroke width above which a miter join is bevelled (default 4, as SVG). */
|
|
209
|
+
miterLimit?: number;
|
|
210
|
+
/** Dash pattern (as SVG `stroke-dasharray`); odd patterns repeat twice. */
|
|
211
|
+
dash?: readonly number[];
|
|
212
|
+
/** Distance into the dash pattern at the start of each subpath (as `stroke-dashoffset`). */
|
|
213
|
+
dashOffset?: number;
|
|
214
|
+
/** Maximum distance between the approximated and the true offset curve (default 0.01). */
|
|
215
|
+
tolerance?: number;
|
|
216
|
+
}
|
|
217
|
+
interface OffsetPathOptions extends PathOpsOptions {
|
|
218
|
+
/** Corner style of the grown / shrunk outline (default `miter`). */
|
|
219
|
+
join?: StrokeJoin;
|
|
220
|
+
/** Miter limit (default 4). */
|
|
221
|
+
miterLimit?: number;
|
|
222
|
+
/** Fill rule of the input (default `nonzero`). */
|
|
223
|
+
fillRule?: PolygonFillRule;
|
|
224
|
+
/** Maximum distance between the approximated and the true offset curve (default 0.01). */
|
|
225
|
+
tolerance?: number;
|
|
226
|
+
}
|
|
227
|
+
interface DashedPath {
|
|
228
|
+
/** The dashes, as open subpaths. */
|
|
229
|
+
contours: BezierContour[];
|
|
230
|
+
/** Zero-length dashes: where they sit and the path direction there. */
|
|
231
|
+
dots: {
|
|
232
|
+
point: Point;
|
|
233
|
+
tangent: Point;
|
|
234
|
+
}[];
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Applies a dash pattern (SVG `stroke-dasharray` / `stroke-dashoffset` semantics) to the
|
|
238
|
+
* subpaths. Returns `null` when the pattern is invalid (negative or non-finite entries),
|
|
239
|
+
* has no positive entry, or would make more than 200,000 dashes: the line is solid.
|
|
240
|
+
*/
|
|
241
|
+
declare function dashContours(contours: readonly BezierContour[], pattern: readonly number[], offset?: number): DashedPath | null;
|
|
242
|
+
/**
|
|
243
|
+
* The raw (overlapping) outline of a stroke as closed subpaths to fill with `nonzero`.
|
|
244
|
+
* `outlineStroke` normalises it; this is useful for previews.
|
|
245
|
+
*/
|
|
246
|
+
declare function strokeOutlineRings(input: BezierPathInput, options: OutlineStrokeOptions): BezierPath;
|
|
247
|
+
/**
|
|
248
|
+
* Outline Stroke: the filled area painted by stroking `path`, as one clean path (overlaps
|
|
249
|
+
* removed, consistently oriented). Joins, caps, miter limit and dashes follow SVG.
|
|
250
|
+
*/
|
|
251
|
+
declare function outlineStroke(input: BezierPathInput, options: OutlineStrokeOptions): BezierPath;
|
|
252
|
+
/**
|
|
253
|
+
* Offset Path: grows (`distance > 0`) or shrinks (`distance < 0`) the filled area by
|
|
254
|
+
* `distance`. Closed subpaths are a filled region (read with `fillRule`); open subpaths are
|
|
255
|
+
* outlined with a stroke of width `2·|distance|` and butt caps (when growing). Loops of the
|
|
256
|
+
* offset curves are removed.
|
|
257
|
+
*/
|
|
258
|
+
declare function offsetPath(input: BezierPathInput, distance: number, options?: OffsetPathOptions): BezierPath;
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Planar maps: the faces and edges a set of paths divides the plane into (Shape Builder, fill
|
|
262
|
+
* regions, Pathfinder Outline).
|
|
263
|
+
*
|
|
264
|
+
* Unlike `dividePaths`, which splits the *filled areas* of closed shapes, every path here is an
|
|
265
|
+
* edge, open ones included: three crossing lines enclose a triangle, a line across a rectangle
|
|
266
|
+
* splits it in two, and an area enclosed by paths is a face whether or not anything fills it.
|
|
267
|
+
*
|
|
268
|
+
* 1. `planarSplit` (the boolean engine's intersection search) cuts every input segment wherever
|
|
269
|
+
* it meets another one; coincident pieces become one edge.
|
|
270
|
+
* 2. Each edge gives two half-edges. Around every vertex the half-edges leaving it are sorted by
|
|
271
|
+
* the direction in which they cross a small circle around it (half the shortest edge there),
|
|
272
|
+
* which orders tangent curves correctly.
|
|
273
|
+
* 3. A face walk takes, at each vertex, the half-edge just clockwise of the way back — the
|
|
274
|
+
* sharpest left turn. Bounded faces come out counter-clockwise (positive area in a y-up
|
|
275
|
+
* frame), the outer boundary of every connected piece clockwise; spurs (loose line ends) are
|
|
276
|
+
* dropped. Each outer boundary becomes a hole of the smallest face of another piece around
|
|
277
|
+
* it, so nesting is decided face by face, never by an even-odd rule over the whole network.
|
|
278
|
+
* 4. Faces learn which inputs fill them from a point well inside each face.
|
|
279
|
+
*
|
|
280
|
+
* Adjacency is kept in per-vertex lists and half-edge slots (no scans over all edges per step).
|
|
281
|
+
*
|
|
282
|
+
* Ported from vectorcraft-main/crates/pathops/src/planar.rs (`map`, `Map::merge`, `build`,
|
|
283
|
+
* `interior_point`, `without_spurs`, `leaving_angle`, `cut_out`), figcraft-main/crates/doc/src/vector_faces.rs
|
|
284
|
+
* (`faces`: half-edge walk with an angle-sorted next edge, the winding deciding inside or
|
|
285
|
+
* outside) and cadcraft-main/crates/geom/src/region.rs (`enclosing_loop`, `boundary_at_gap`:
|
|
286
|
+
* a ray from the point, the sharpest left turn, islands as holes, gaps between open ends
|
|
287
|
+
* closed). MIT OR Apache-2.0, © ArtCraft Team and contributors. See THIRD_PARTY_NOTICES.md.
|
|
288
|
+
*/
|
|
289
|
+
|
|
290
|
+
/** One input of a planar map. */
|
|
291
|
+
interface PlanarInput {
|
|
292
|
+
/** Its subpaths: closed ones bound faces and the area the input fills, open ones are edges only. */
|
|
293
|
+
path: BezierPathInput;
|
|
294
|
+
/** How its closed subpaths fill (default `nonzero`). */
|
|
295
|
+
fillRule?: PolygonFillRule;
|
|
296
|
+
/** Whether its closed subpaths count as filling the faces inside them (default true). */
|
|
297
|
+
fills?: boolean;
|
|
298
|
+
}
|
|
299
|
+
interface PlanarMapOptions extends PathOpsOptions {
|
|
300
|
+
/**
|
|
301
|
+
* Close gaps up to this distance between loose ends (vertices with one edge): each one joins
|
|
302
|
+
* the nearest other loose end within reach by a straight edge (default 0, off).
|
|
303
|
+
*/
|
|
304
|
+
gap?: number;
|
|
305
|
+
/** Most input segments mapped (default 4096); a bigger input gives no map. */
|
|
306
|
+
maxSegments?: number;
|
|
307
|
+
}
|
|
308
|
+
/** A bounded face: an outer outline with the holes other pieces of the map make in it. */
|
|
309
|
+
interface PlanarFace {
|
|
310
|
+
/** Outer subpath (counter-clockwise in a y-up frame) followed by its holes (clockwise). */
|
|
311
|
+
path: BezierPath;
|
|
312
|
+
/** Area (holes taken out). */
|
|
313
|
+
area: number;
|
|
314
|
+
bounds: {
|
|
315
|
+
minX: number;
|
|
316
|
+
minY: number;
|
|
317
|
+
maxX: number;
|
|
318
|
+
maxY: number;
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
/** A run of edges between junctions (vertices where paths meet or a path ends). */
|
|
322
|
+
interface PlanarChain {
|
|
323
|
+
segments: BezierSegment[];
|
|
324
|
+
/** A loop with no junction on it. */
|
|
325
|
+
closed: boolean;
|
|
326
|
+
/** The input it lies on: the front-most (highest index) where several coincide. */
|
|
327
|
+
source: number;
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* A point strictly inside a filled path (nonzero), well away from its edges where it can be:
|
|
331
|
+
* the middle of the widest span of a few horizontal lines through it. Null for an empty path.
|
|
332
|
+
* Ported from vectorcraft's `interior_point` (cadcraft's `interior_point` for polygons).
|
|
333
|
+
*/
|
|
334
|
+
declare function interiorPoint(path: BezierPathInput | readonly (readonly BezierSegment[])[]): Point | null;
|
|
335
|
+
/**
|
|
336
|
+
* The planar map of a set of paths. Build it with `PlanarMap.build`; faces, chains and fills
|
|
337
|
+
* are computed on first use.
|
|
338
|
+
*/
|
|
339
|
+
declare class PlanarMap {
|
|
340
|
+
readonly vertices: Point[];
|
|
341
|
+
private readonly edges;
|
|
342
|
+
private readonly sources;
|
|
343
|
+
readonly eps: number;
|
|
344
|
+
readonly inputCount: number;
|
|
345
|
+
private readonly around;
|
|
346
|
+
private readonly slot;
|
|
347
|
+
private readonly component;
|
|
348
|
+
private cyclesCache;
|
|
349
|
+
private sourcesCache;
|
|
350
|
+
private readonly fills;
|
|
351
|
+
private constructor();
|
|
352
|
+
/**
|
|
353
|
+
* Maps `inputs` (their subpaths as given: open ones stay open). Null when they cannot be mapped
|
|
354
|
+
* (non-finite points, more than `maxSegments` segments or an intersection search that does
|
|
355
|
+
* not settle) or have no edges.
|
|
356
|
+
*/
|
|
357
|
+
static build(inputs: readonly PlanarInput[], options?: PlanarMapOptions): PlanarMap | null;
|
|
358
|
+
private origin;
|
|
359
|
+
private halfPts;
|
|
360
|
+
/** The half-edge after `h` on the face to its left: the sharpest left turn at its end. */
|
|
361
|
+
private next;
|
|
362
|
+
/** Direction (angle) in which half-edge `h`, leaving `at`, first gets `r` away from it. */
|
|
363
|
+
private leavingAngle;
|
|
364
|
+
/** Segments of a run of half-edges (a loop unless `closed` is false), pieces of one input segment joined again. */
|
|
365
|
+
private cycleSegments;
|
|
366
|
+
private cycles;
|
|
367
|
+
private faceChains;
|
|
368
|
+
/** The bounded faces of the map. */
|
|
369
|
+
get faces(): PlanarFace[];
|
|
370
|
+
/** The inputs whose fill covers face `i`, ascending (empty for an area only outlines enclose). */
|
|
371
|
+
faceSources(i: number): number[];
|
|
372
|
+
/** A point well inside face `i`. */
|
|
373
|
+
faceInterior(i: number): Point | null;
|
|
374
|
+
/** The face under `p` (the smallest one around it), or -1. */
|
|
375
|
+
faceAt(p: Point): number;
|
|
376
|
+
/**
|
|
377
|
+
* The union of faces, traced along the map's own edges: those between two merged faces drop
|
|
378
|
+
* out exactly, so no seam or sliver is left where a boolean union of their outlines could
|
|
379
|
+
* round shared corners apart. Outer subpaths come out counter-clockwise (y-up), holes clockwise.
|
|
380
|
+
*/
|
|
381
|
+
merge(faceIndices: readonly number[]): BezierPath;
|
|
382
|
+
/**
|
|
383
|
+
* The edges joined into runs between junctions: vertices where other than two edges meet, or
|
|
384
|
+
* where the two edges lie on different inputs. Each run is keyed by its input.
|
|
385
|
+
*/
|
|
386
|
+
chains(): PlanarChain[];
|
|
387
|
+
/**
|
|
388
|
+
* The region enclosing `p`, traced as cadcraft does it: a ray from `p` towards +x meets the
|
|
389
|
+
* edges in order; for each, the half-edge with `p` on its left is followed by always taking the
|
|
390
|
+
* sharpest left turn, until a loop that runs counter-clockwise round `p` comes back. The pieces
|
|
391
|
+
* of the map nested inside that loop (islands) become its holes. Null when nothing encloses `p`.
|
|
392
|
+
*/
|
|
393
|
+
regionAt(p: Point): BezierPath | null;
|
|
394
|
+
}
|
|
395
|
+
/** Whether a contour, closed, encloses an area (rather than retracing itself). */
|
|
396
|
+
declare function contourEnclosesArea(contour: BezierContour): boolean;
|
|
397
|
+
/**
|
|
398
|
+
* `path` without `piece`, a run along one of its subpaths between two points (a Shape Builder
|
|
399
|
+
* edge from `PlanarMap.chains`): a closed subpath opens there, an open one splits in two (or
|
|
400
|
+
* loses an end), and a piece that runs all the way round (`closed`, or ending where it starts)
|
|
401
|
+
* takes its subpath with it. With `fillCloses`, open subpaths that enclose an area run on round
|
|
402
|
+
* an invisible closing edge, as the Shape Builder sees a filled path: a piece may run over it,
|
|
403
|
+
* and it never comes back as a visible segment. Null when the piece does not lie on `path`
|
|
404
|
+
* within `tol`.
|
|
405
|
+
*
|
|
406
|
+
* Ported from vectorcraft-main/crates/pathops/src/planar.rs (`cut_out`, `nearest_u`, `span`,
|
|
407
|
+
* `snap_ends`). MIT OR Apache-2.0, © ArtCraft Team and contributors. See THIRD_PARTY_NOTICES.md.
|
|
408
|
+
*/
|
|
409
|
+
declare function cutOutPiece(path: BezierPathInput, piece: {
|
|
410
|
+
segments: readonly BezierSegment[];
|
|
411
|
+
closed?: boolean;
|
|
412
|
+
}, fillCloses: boolean, tol: number): BezierPath | null;
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* The Pathfinder panel's dividing operations over a stack of shapes (index 0 at the back):
|
|
416
|
+
* Divide, Trim, Merge, Crop, Outline and Minus Back. (Unite, Minus Front, Intersect and Exclude
|
|
417
|
+
* are `pathBoolean`.) Every result carries the index of the shape whose paint it keeps.
|
|
418
|
+
*
|
|
419
|
+
* The filled areas come from one arrangement of all shapes (`dividePaths`, `pathBooleanSelect`):
|
|
420
|
+
* each area knows the shapes covering it, so an operation is a choice of areas per result.
|
|
421
|
+
* Outline and Divide with cutting lines use the planar map (`PlanarMap`).
|
|
422
|
+
*
|
|
423
|
+
* Ported from vectorcraft-main/crates/pathops/src/pathfinder.rs (`pathfinder`, `PathfinderOp`,
|
|
424
|
+
* `outline_edges`), MIT OR Apache-2.0, © ArtCraft Team and contributors. See
|
|
425
|
+
* THIRD_PARTY_NOTICES.md.
|
|
426
|
+
*/
|
|
427
|
+
|
|
428
|
+
type PathfinderOperation = 'divide' | 'trim' | 'merge' | 'crop' | 'outline' | 'minusBack';
|
|
429
|
+
declare const PATHFINDER_OPERATIONS: readonly PathfinderOperation[];
|
|
430
|
+
/** A shape of the stack. */
|
|
431
|
+
interface PathfinderShape {
|
|
432
|
+
/** Its outline; open subpaths are closed for filling (unless `line`). */
|
|
433
|
+
path: BezierPathInput;
|
|
434
|
+
fillRule?: PolygonFillRule;
|
|
435
|
+
/** Identifies its paint: Merge joins touching areas whose shapes share a key (default: the index). */
|
|
436
|
+
key?: string | number;
|
|
437
|
+
/**
|
|
438
|
+
* An unfilled open path: a cutting edge for Divide, splitting the faces it crosses without
|
|
439
|
+
* becoming one (ignored by the other operations).
|
|
440
|
+
*/
|
|
441
|
+
line?: boolean;
|
|
442
|
+
}
|
|
443
|
+
/** One result: a filled area (or an open stroke for Outline). */
|
|
444
|
+
interface PathfinderPiece {
|
|
445
|
+
path: BezierPath;
|
|
446
|
+
/** Index of the shape whose paint it keeps. */
|
|
447
|
+
source: number;
|
|
448
|
+
/** Outline edges are open paths (a loop with no junction on it stays closed). */
|
|
449
|
+
open?: boolean;
|
|
450
|
+
}
|
|
451
|
+
interface PathfinderResult extends PathOpsReport {
|
|
452
|
+
pieces: PathfinderPiece[];
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Runs a Pathfinder operation:
|
|
456
|
+
* - `divide`: every face of the arrangement becomes its own piece, painted like the top-most
|
|
457
|
+
* shape covering it. `line` shapes cut the faces they cross.
|
|
458
|
+
* - `trim`: hidden parts are removed; one piece per shape that stays visible, nothing merged.
|
|
459
|
+
* - `merge`: like Trim, then touching or overlapping visible parts of shapes with the same key
|
|
460
|
+
* become one piece (one per connected area).
|
|
461
|
+
* - `crop`: the top shape crops the others; it is removed, the visible parts of the shapes below
|
|
462
|
+
* inside it stay.
|
|
463
|
+
* - `outline`: every outline is cut where it meets another; the pieces are open paths painted
|
|
464
|
+
* like the shape they bound (the top-most where outlines coincide).
|
|
465
|
+
* - `minusBack`: the top shape minus everything behind it.
|
|
466
|
+
*/
|
|
467
|
+
declare function pathfinder(op: PathfinderOperation, shapes: readonly PathfinderShape[], options?: PathOpsOptions): PathfinderResult;
|
|
468
|
+
|
|
469
|
+
export { cutOutPiece as A, dashContours as B, dividePaths as C, type DashedPath as D, excludePaths as E, interiorPoint as F, intersectPaths as G, normalizeBezierPath as H, offsetPath as I, outlineStroke as J, pathBoolean as K, pathBooleanSelect as L, pathfinder as M, planarSplit as N, type OffsetPathOptions as O, PlanarMap as P, segmentIntersections as Q, strokeOutlineRings as R, type StrokeJoin as S, subtractPaths as T, unitePaths as U, type StrokeCap as a, type PathfinderOperation as b, type PathfinderShape as c, type DividePathsResult as d, type OutlineStrokeOptions as e, PATHFINDER_OPERATIONS as f, type PathBooleanOperation as g, type PathBooleanResult as h, type PathOperand as i, type PathOperandInput as j, PathOpsError as k, type PathOpsOptions as l, type PathOpsReport as m, type PathPiece as n, type PathSelectResult as o, type PathfinderPiece as p, type PathfinderResult as q, type PlanarChain as r, type PlanarFace as s, type PlanarInput as t, type PlanarMapOptions as u, type PlanarSplitEdge as v, type PlanarSplitResult as w, type SegmentIntersection as x, bezierPathArea as y, contourEnclosesArea as z };
|