@pixerate/editor 0.36.0 → 0.38.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixerate/editor",
3
- "version": "0.36.0",
3
+ "version": "0.38.0",
4
4
  "description": "UI-agnostic rich text and media editing core library",
5
5
  "author": "Pixerate",
6
6
  "license": "MIT",
@@ -1,547 +0,0 @@
1
- import { P as Point } from './types-BFkYA4eF.js';
2
-
3
- /**
4
- * Polygon boolean operations (union, intersection, difference, xor and divide) on
5
- * multi-polygons with holes.
6
- *
7
- * Algorithm (overlay + winding classification):
8
- * 1. Every input edge is collected into one segment set. Vertices are merged through a
9
- * tolerance-aware point pool, so points closer than `epsilon` become one vertex.
10
- * 2. Segments are split at every crossing, T-junction and collinear overlap until no two
11
- * segments cross (a planar arrangement). Splitting is repeated because snapping a new
12
- * vertex can move a segment by up to `epsilon`.
13
- * 3. Coincident segments (shared edges) are merged, keeping for every operand the signed
14
- * number of its edges that run along the segment.
15
- * 4. For every segment the winding number of each operand on its right side is computed
16
- * with a ray cast from the segment midpoint (the segment itself excluded), and the left
17
- * side follows from the signed multiplicities. The fill rule turns windings into
18
- * inside / outside flags and the operation decides whether each side is in the result.
19
- * 5. Segments with the result on exactly one side are kept, oriented with the result on
20
- * their left, and traced into rings (taking the sharpest left turn at shared vertices,
21
- * so rings that touch at a vertex stay separate simple rings). Rings with a positive
22
- * signed area are outer rings; negative ones are holes, assigned to the smallest outer
23
- * ring that contains them.
24
- *
25
- * Handles shared edges, touching vertices, collinear overlaps, holes, nested and disjoint
26
- * inputs and self-intersecting input rings (resolved by the operand's fill rule).
27
- *
28
- * Limits: the overlay is O(n²) in the number of edges (pruned by a sweep on x), which is
29
- * comfortable for canvas shapes (thousands of edges) but not for GIS-scale data. Features
30
- * narrower than `epsilon` collapse. Coordinates must be finite.
31
- */
32
-
33
- /** A closed ring of points. The closing point may be repeated or omitted. */
34
- type PolygonRing = Point[];
35
- /** A polygon: the outer ring followed by its holes. */
36
- type PolygonWithHoles = PolygonRing[];
37
- /** A set of polygons. */
38
- type MultiPolygon = PolygonWithHoles[];
39
- /** SVG fill rule used to decide which areas of a ring set are inside. */
40
- type PolygonFillRule = 'nonzero' | 'evenodd';
41
- /** Boolean operations. `xor` is Freeform's Exclude. */
42
- type PolygonBooleanOperation = 'union' | 'intersection' | 'difference' | 'xor';
43
- /**
44
- * A raw ring set with a fill rule (e.g. flattened SVG path data). Ring orientation is
45
- * significant for `nonzero`.
46
- */
47
- interface PolygonOperand {
48
- rings: PolygonRing[];
49
- fillRule?: PolygonFillRule;
50
- }
51
- type PolygonInput = MultiPolygon | PolygonOperand;
52
- interface PolygonBooleanOptions {
53
- /**
54
- * Distance below which points are treated as equal. Defaults to `1e-9` times the
55
- * largest coordinate magnitude of the inputs (at least `1e-9`).
56
- */
57
- epsilon?: number;
58
- }
59
- /** One region of `dividePolygons`, with the indices of the operands that cover it. */
60
- interface PolygonPiece {
61
- polygon: PolygonWithHoles;
62
- operands: number[];
63
- }
64
- /** Signed shoelace area of a ring (positive when counter-clockwise in a y-up frame). */
65
- declare function ringSignedArea(ring: readonly Point[]): number;
66
- /** Area of a polygon (outer ring minus holes). */
67
- declare function polygonArea(polygon: PolygonWithHoles): number;
68
- /** Total area of a multi-polygon (holes subtracted). */
69
- declare function multiPolygonArea(multi: MultiPolygon): number;
70
- /** Axis-aligned bounds of a multi-polygon (or ring list), or `null` when empty. */
71
- declare function multiPolygonBounds(input: MultiPolygon | PolygonRing[]): {
72
- minX: number;
73
- minY: number;
74
- maxX: number;
75
- maxY: number;
76
- } | null;
77
- /**
78
- * Whether a point is inside a ring set under a fill rule. Points exactly on an edge may
79
- * report either side.
80
- */
81
- declare function pointInRings(point: Point, rings: readonly (readonly Point[])[], fillRule?: PolygonFillRule): boolean;
82
- /** Whether a point is inside a multi-polygon (holes excluded). */
83
- declare function pointInMultiPolygon(point: Point, multi: MultiPolygon): boolean;
84
- /**
85
- * Applies a boolean operation to any number of operands.
86
- * - `union`: covered by any operand.
87
- * - `intersection`: covered by every operand.
88
- * - `difference`: the first operand minus all others.
89
- * - `xor`: covered by an odd number of operands (Exclude).
90
- *
91
- * Returns simple rings: outer rings have a positive signed area, holes a negative one.
92
- * Rings may touch at vertices but never cross.
93
- */
94
- declare function polygonBoolean(operation: PolygonBooleanOperation, operands: PolygonInput[], options?: PolygonBooleanOptions): MultiPolygon;
95
- declare const unionPolygons: (a: PolygonInput, b: PolygonInput, options?: PolygonBooleanOptions) => MultiPolygon;
96
- declare const intersectPolygons: (a: PolygonInput, b: PolygonInput, options?: PolygonBooleanOptions) => MultiPolygon;
97
- declare const subtractPolygons: (a: PolygonInput, b: PolygonInput, options?: PolygonBooleanOptions) => MultiPolygon;
98
- declare const xorPolygons: (a: PolygonInput, b: PolygonInput, options?: PolygonBooleanOptions) => MultiPolygon;
99
- /**
100
- * Splits the overlay of the operands into its distinct regions (Freeform's Divide): every
101
- * connected area covered by the same set of operands becomes one piece. Pieces are ordered
102
- * by their operand set, then by size (largest first).
103
- */
104
- declare function dividePolygons(operands: PolygonInput[], options?: PolygonBooleanOptions): PolygonPiece[];
105
-
106
- /**
107
- * Canvas gradient models, parsing, presets, and SVG defs generation.
108
- * Supports linear and radial gradients for shape fills, strokes, and freehand drawing.
109
- */
110
- interface GradientStop {
111
- offset: number;
112
- color: string;
113
- opacity?: number;
114
- }
115
- interface CanvasLinearGradient {
116
- type: 'linear';
117
- angle?: number;
118
- stops: GradientStop[];
119
- }
120
- interface CanvasRadialGradient {
121
- type: 'radial';
122
- cx?: number;
123
- cy?: number;
124
- r?: number;
125
- stops: GradientStop[];
126
- }
127
- type CanvasGradientDef = CanvasLinearGradient | CanvasRadialGradient;
128
- interface SvgGradientStop {
129
- offset: string;
130
- stopColor: string;
131
- stopOpacity?: number;
132
- }
133
- interface SvgGradientDef {
134
- id: string;
135
- type: 'linear' | 'radial';
136
- attrs: Record<string, string | number>;
137
- stops: SvgGradientStop[];
138
- }
139
- declare const CANVAS_GRADIENT_PRESETS: Record<string, CanvasLinearGradient>;
140
- /** Whether an arbitrary value matches a CanvasGradientDef object. */
141
- declare function isCanvasGradient(value: unknown): value is CanvasGradientDef;
142
- /**
143
- * Parses CSS linear-gradient or radial-gradient strings into CanvasGradientDef.
144
- * Supports forms like:
145
- * - linear-gradient(90deg, #ff0000 0%, #0000ff 100%)
146
- * - linear-gradient(to right, red, blue)
147
- * - radial-gradient(circle, red 0%, blue 100%)
148
- */
149
- declare function parseCssGradient(css: string): CanvasGradientDef | null;
150
- /**
151
- * Resolves a paint value (which could be a CSS color, preset name, CSS gradient string, or CanvasGradientDef)
152
- * into either a CanvasGradientDef (if gradient) or null (if solid color or invalid).
153
- */
154
- declare function resolveCanvasGradient(value: unknown): CanvasGradientDef | null;
155
- /**
156
- * Converts degrees clockwise (CSS angle: 0 = top, 90 = right, 180 = bottom, 270 = left)
157
- * to SVG linearGradient vector coordinates (x1, y1, x2, y2) normalized [0, 1].
158
- */
159
- declare function angleToSvgLinearCoords(angleDeg?: number): {
160
- x1: number;
161
- y1: number;
162
- x2: number;
163
- y2: number;
164
- };
165
- /**
166
- * Converts a CanvasGradientDef to an SvgGradientDef descriptor ready for rendering `<linearGradient>` / `<radialGradient>`.
167
- */
168
- declare function gradientToSvgDef(gradient: CanvasGradientDef, id: string): SvgGradientDef;
169
-
170
- /**
171
- * Shape geometry: shape descriptions (rect, rounded rect, ellipse, regular polygon, star and
172
- * SVG path data) to polygons, SVG path parsing / flattening, and polygons back to path data.
173
- */
174
-
175
- /** Paint shared by every shape kind. Colours are any CSS colour, preset name, or gradient definition. */
176
- interface ShapePaint {
177
- fill?: string | CanvasGradientDef;
178
- stroke?: string | CanvasGradientDef;
179
- strokeWidth?: number;
180
- opacity?: number;
181
- strokeLinecap?: 'round' | 'butt' | 'square';
182
- strokeLinejoin?: 'round' | 'bevel' | 'miter';
183
- fillGradient?: CanvasGradientDef;
184
- strokeGradient?: CanvasGradientDef;
185
- }
186
- interface ShapeBase extends ShapePaint {
187
- /** Clockwise rotation in degrees (on a y-down canvas) about the centre of the node box. */
188
- rotation?: number;
189
- }
190
- /** Rectangle filling the node box, optionally with rounded corners. */
191
- interface RectShape extends ShapeBase {
192
- kind: 'rect';
193
- /** One radius, or `[topLeft, topRight, bottomRight, bottomLeft]`. Clamped to fit. */
194
- cornerRadius?: number | readonly [number, number, number, number];
195
- }
196
- /** Ellipse (circle when the node is square) inscribed in the node box. */
197
- interface EllipseShape extends ShapeBase {
198
- kind: 'ellipse';
199
- }
200
- /** Regular polygon, stretched so its bounding box fills the node box. */
201
- interface RegularPolygonShape extends ShapeBase {
202
- kind: 'polygon';
203
- /** Number of sides (at least 3, default 6). The first vertex points up. */
204
- sides?: number;
205
- }
206
- /** Star, stretched so its bounding box fills the node box. */
207
- interface StarShape extends ShapeBase {
208
- kind: 'star';
209
- /** Number of points (at least 3, default 5). The first point points up. */
210
- points?: number;
211
- /** Inner radius as a fraction of the outer radius (default 0.5). */
212
- innerRadius?: number;
213
- }
214
- /** Arbitrary SVG path data. */
215
- interface PathShape extends ShapeBase {
216
- kind: 'path';
217
- d: string;
218
- /**
219
- * `[minX, minY, width, height]` of the path's coordinate space, scaled to the node box.
220
- * Without it the path coordinates are node-local pixels.
221
- */
222
- viewBox?: readonly [number, number, number, number];
223
- /** Fill rule (default `nonzero`, as in SVG). */
224
- fillRule?: PolygonFillRule;
225
- }
226
- /**
227
- * Shape description stored on a node as `data.shape`. Geometry is relative to the node
228
- * box (`0,0` to `width,height`), so resizing the node resizes the shape.
229
- */
230
- type ShapeDescription = RectShape | EllipseShape | RegularPolygonShape | StarShape | PathShape;
231
- type ShapeKind = ShapeDescription['kind'];
232
- declare const SHAPE_KINDS: readonly ShapeKind[];
233
- /** Whether a value is a supported shape description. */
234
- declare function isShapeDescription(value: unknown): value is ShapeDescription;
235
- interface ShapeSize {
236
- width: number;
237
- height: number;
238
- }
239
- interface FlattenOptions {
240
- /** Maximum distance between a curve and its polyline, in output units (default 0.25). */
241
- tolerance?: number;
242
- /** Upper bound on the segments one curve is split into (default 512). */
243
- maxSegments?: number;
244
- }
245
- /** Normalised absolute path command produced by `parseSvgPath`. */
246
- type PathCommand = {
247
- type: 'M';
248
- x: number;
249
- y: number;
250
- } | {
251
- type: 'L';
252
- x: number;
253
- y: number;
254
- } | {
255
- type: 'C';
256
- x1: number;
257
- y1: number;
258
- x2: number;
259
- y2: number;
260
- x: number;
261
- y: number;
262
- } | {
263
- type: 'Q';
264
- x1: number;
265
- y1: number;
266
- x: number;
267
- y: number;
268
- } | {
269
- type: 'A';
270
- rx: number;
271
- ry: number;
272
- rotation: number;
273
- largeArc: boolean;
274
- sweep: boolean;
275
- x: number;
276
- y: number;
277
- } | {
278
- type: 'Z';
279
- };
280
- /**
281
- * Parses SVG path data into absolute `M`, `L`, `C`, `Q`, `A` and `Z` commands. Relative
282
- * commands, `H` / `V`, smooth curves (`S` / `T`) and implicit repeated commands are
283
- * normalised. Parsing stops at the first malformed command (as browsers do).
284
- */
285
- declare function parseSvgPath(d: string): PathCommand[];
286
- /**
287
- * Flattens SVG path data into closed rings (one per subpath; open subpaths are closed the
288
- * way SVG fills them). Curves are approximated within `tolerance`.
289
- */
290
- declare function flattenSvgPath(d: string | PathCommand[], options?: FlattenOptions): PolygonRing[];
291
- /**
292
- * SVG path data for a shape in node-local pixels (exact curves: arcs for rounded corners
293
- * and ellipses), plus the fill rule and a `transform` for rotation / path view boxes.
294
- * Use it to render a shape; use `shapeToPolygon` for geometry.
295
- */
296
- declare function getShapeSvg(shape: ShapeDescription, size: ShapeSize): {
297
- d: string;
298
- transform?: string;
299
- fillRule: PolygonFillRule;
300
- };
301
- /** Everything a renderer needs to draw a shape as one SVG `<path>`. */
302
- interface ShapeRenderData {
303
- /** SVG `viewBox` (`0 0 width height`): node-local pixels. */
304
- viewBox: string;
305
- width: number;
306
- height: number;
307
- d: string;
308
- transform?: string;
309
- fillRule: PolygonFillRule;
310
- fill: string;
311
- stroke: string;
312
- strokeWidth: number;
313
- opacity?: number;
314
- strokeLinecap?: 'round' | 'butt' | 'square';
315
- strokeLinejoin?: 'round' | 'bevel' | 'miter';
316
- /** Gradient def for the fill, when fill uses a gradient. */
317
- fillGradient?: SvgGradientDef;
318
- /** Gradient def for the stroke, when stroke uses a gradient. */
319
- strokeGradient?: SvgGradientDef;
320
- }
321
- interface GetShapeRenderDataOptions {
322
- /** Unique ID suffix or base ID used when generating SVG gradient IDs (default: auto random). */
323
- id?: string;
324
- }
325
- /**
326
- * Resolves the SVG drawing of a shape for a node size. Without a size, a path's view box
327
- * size (or 100x100) is used. Paint defaults: `fill: currentColor`, `stroke: none`,
328
- * `strokeWidth: 1`. Supports solid colors, CSS gradients, presets, and CanvasGradientDef.
329
- */
330
- declare function getShapeRenderData(shape: ShapeDescription, size?: Partial<ShapeSize>, options?: GetShapeRenderDataOptions): ShapeRenderData;
331
- /**
332
- * Converts a shape to rings in node-local pixels (rotation applied), flattening curves at
333
- * `tolerance`. Returns the rings with the fill rule they must be read with.
334
- */
335
- declare function shapeToPolygon(shape: ShapeDescription, size: ShapeSize, options?: FlattenOptions): {
336
- rings: PolygonRing[];
337
- fillRule: PolygonFillRule;
338
- };
339
- /** Formats a number with at most `precision` decimals, without trailing zeros. */
340
- declare function formatNumber(value: number, precision?: number): string;
341
- /**
342
- * Simplifies a closed ring with Ramer–Douglas–Peucker at `tolerance`. Returns an empty
343
- * ring when fewer than three points survive.
344
- */
345
- declare function simplifyRing(ring: readonly Point[], tolerance: number): Point[];
346
- interface PolygonToPathOptions {
347
- /** Decimal places in the output (default 3). */
348
- precision?: number;
349
- /** Ramer–Douglas–Peucker tolerance; `0` (default) keeps every vertex. */
350
- simplify?: number;
351
- /** Added to every point before formatting (e.g. to make coordinates node-local). */
352
- offset?: {
353
- x: number;
354
- y: number;
355
- };
356
- /**
357
- * `'lines'` (default) writes every ring as `M`/`L`/`Z`. `'fit'` fits cubic Béziers to each
358
- * ring (`fitPathData`), so flattened curves come back as smooth `C` curves while sharp
359
- * corners (turning more than `cornerAngleDeg`) and straight edges stay as they are.
360
- */
361
- curves?: 'lines' | 'fit';
362
- /** Curve-fitting tolerance in path units for `curves: 'fit'` (default 0.25). */
363
- curveTolerance?: number;
364
- /** Corner threshold in degrees for `curves: 'fit'` (default 30). */
365
- cornerAngleDeg?: number;
366
- }
367
- /**
368
- * Converts a multi-polygon (or a list of rings) to SVG path data using `M`/`L`/`Z`. Holes
369
- * keep their opposite orientation, so the path fills correctly with either fill rule.
370
- */
371
- declare function polygonToSvgPath(input: MultiPolygon | PolygonRing[], options?: PolygonToPathOptions): string;
372
-
373
- /**
374
- * Bézier path model shared by the curve-preserving path operations: absolute `M` / `L` /
375
- * `Q` / `C` / `Z` commands, conversion from SVG path data (arcs become cubics), segment
376
- * math (evaluation, splitting, extrema, nearest point), exact areas, winding numbers and
377
- * arc-length utilities.
378
- */
379
-
380
- /** One absolute path command. Every subpath starts with `M`; `Z` closes it. */
381
- type BezierCommand = {
382
- type: 'M';
383
- x: number;
384
- y: number;
385
- } | {
386
- type: 'L';
387
- x: number;
388
- y: number;
389
- } | {
390
- type: 'Q';
391
- x1: number;
392
- y1: number;
393
- x: number;
394
- y: number;
395
- } | {
396
- type: 'C';
397
- x1: number;
398
- y1: number;
399
- x2: number;
400
- y2: number;
401
- x: number;
402
- y: number;
403
- } | {
404
- type: 'Z';
405
- };
406
- /** A path as a list of absolute move / line / quadratic / cubic / close commands. */
407
- type BezierPath = BezierCommand[];
408
- /** Anything the path operations accept as a path: SVG path data, parsed commands or a `BezierPath`. */
409
- type BezierPathInput = string | readonly BezierCommand[] | readonly PathCommand[];
410
- /**
411
- * One segment as its control points: 2 points for a line, 3 for a quadratic and 4 for a
412
- * cubic Bézier.
413
- */
414
- type BezierSegment = readonly Point[];
415
- /** A subpath as a chain of segments (each starts where the previous one ends). */
416
- interface BezierContour {
417
- segments: BezierSegment[];
418
- closed: boolean;
419
- }
420
- /** Point at parameter `t` (de Casteljau, works for any degree). */
421
- declare function segmentPoint(seg: BezierSegment, t: number): Point;
422
- /** First derivative at `t`. */
423
- declare function segmentDerivative(seg: BezierSegment, t: number): Point;
424
- /**
425
- * Unit tangent at `t`. Where the derivative vanishes (a handle on its anchor) the direction
426
- * a hair further along is used, and the chord as the last resort.
427
- */
428
- declare function segmentTangent(seg: BezierSegment, t: number): Point;
429
- /** Signed curvature at `t` (positive when turning counter-clockwise in a y-up frame). */
430
- declare function segmentCurvature(seg: BezierSegment, t: number): number;
431
- /** Splits a segment at `t` (de Casteljau). */
432
- declare function splitSegment(seg: BezierSegment, t: number): [Point[], Point[]];
433
- /** The part of a segment between parameters `t0` and `t1` (reversed when `t1 < t0`). */
434
- declare function subSegment(seg: BezierSegment, t0: number, t1: number): Point[];
435
- /** Parameters in (0, 1) where the segment's `axis` coordinate has a local extremum. */
436
- declare function segmentExtrema(seg: BezierSegment, axis: 0 | 1): number[];
437
- /** Exact axis-aligned bounds of a segment. */
438
- declare function segmentBounds(seg: BezierSegment): {
439
- minX: number;
440
- minY: number;
441
- maxX: number;
442
- maxY: number;
443
- };
444
- /** Arc length of the segment between `t0` and `t1` (default the whole segment). */
445
- declare function segmentLength(seg: BezierSegment, t0?: number, t1?: number, tolerance?: number): number;
446
- /** Parameter at arc length `length` from the segment start (clamped to [0, 1]). */
447
- declare function segmentParamAtLength(seg: BezierSegment, length: number, total?: number): number;
448
- /**
449
- * Nearest point of the segment to `p`: the parameter and the distance. Coarse sampling
450
- * followed by Newton refinement around the best samples.
451
- */
452
- declare function segmentNearest(seg: BezierSegment, p: Point): {
453
- t: number;
454
- distance: number;
455
- };
456
- /** Converts an SVG elliptical arc (SVG 1.1 F.6.5) to cubic segments, at most 90° each. */
457
- declare function arcToCubics(from: Point, cmd: {
458
- rx: number;
459
- ry: number;
460
- rotation: number;
461
- largeArc: boolean;
462
- sweep: boolean;
463
- x: number;
464
- y: number;
465
- }): Point[][];
466
- /**
467
- * Converts SVG path data or parsed commands to a `BezierPath` (absolute `M` / `L` / `Q` /
468
- * `C` / `Z`); elliptical arcs become cubic Béziers (at most 90° each).
469
- */
470
- declare function toBezierPath(input: BezierPathInput): BezierPath;
471
- /** Splits a path into contours of segments. Zero-length segments are dropped. */
472
- declare function pathToContours(input: BezierPathInput): BezierContour[];
473
- /** Builds a path from contours (a closed contour's closing line is left to `Z`). */
474
- declare function contoursToPath(contours: readonly BezierContour[]): BezierPath;
475
- interface BezierPathToSvgOptions {
476
- /** Decimal places (default 3). */
477
- precision?: number;
478
- /** Added to every point before formatting. */
479
- offset?: {
480
- x: number;
481
- y: number;
482
- };
483
- }
484
- /** Writes a path as compact SVG path data. */
485
- declare function bezierPathToSvg(input: BezierPathInput, options?: BezierPathToSvgOptions): string;
486
- /** 2D affine matrix `[a, b, c, d, e, f]` mapping `(x, y)` to `(a x + c y + e, b x + d y + f)`. */
487
- type AffineMatrix = readonly [number, number, number, number, number, number];
488
- /** Applies an affine transform to every point (exact for Bézier curves). */
489
- declare function transformBezierPath(input: BezierPathInput, m: AffineMatrix): BezierPath;
490
- /** Number of drawing segments (`L` / `Q` / `C`, plus the closing line of `Z` when it has length). */
491
- declare function countPathSegments(input: BezierPathInput): {
492
- lines: number;
493
- quads: number;
494
- cubics: number;
495
- };
496
- /** The contour's segments, with the closing line added when the contour is closed (or filled). */
497
- declare function closeContour(contour: BezierContour, force?: boolean): BezierSegment[];
498
- /** Exact bounds of a path, or `null` when it has no points. */
499
- declare function bezierPathBounds(input: BezierPathInput): {
500
- minX: number;
501
- minY: number;
502
- maxX: number;
503
- maxY: number;
504
- } | null;
505
- /**
506
- * Signed area of the path as drawn: every subpath closed, contributions summed (positive
507
- * for counter-clockwise subpaths in a y-up frame). Exact for curves. Overlapping subpaths
508
- * count with their multiplicity; use `bezierPathArea` for the filled area.
509
- */
510
- declare function bezierPathSignedArea(input: BezierPathInput): number;
511
- /** Signed area of a closed chain of segments. */
512
- declare function contourSignedArea(segs: readonly BezierSegment[]): number;
513
- /** Arc length of a path (closing lines of closed subpaths included). */
514
- declare function bezierPathLength(input: BezierPathInput): number;
515
- /** Point, unit tangent and angle (radians) at an arc length along the path. */
516
- interface PathPointAtLength {
517
- point: Point;
518
- tangent: Point;
519
- angle: number;
520
- /** Subpath index. */
521
- contour: number;
522
- /** Segment index within the subpath (closing line last). */
523
- segment: number;
524
- /** Parameter within the segment. */
525
- t: number;
526
- }
527
- /**
528
- * The point at arc length `length` from the start of the path (clamped to the path). Arc
529
- * lengths run through the subpaths in order, as `bezierPathLength` counts them.
530
- */
531
- declare function bezierPathPointAtLength(input: BezierPathInput, length: number): PathPointAtLength | null;
532
- /**
533
- * Splits a segment chain by arc length: the part between `from` and `to` (measured from the
534
- * chain's start) as new segments.
535
- */
536
- declare function trimSegments(segs: readonly BezierSegment[], from: number, to: number, lengths?: number[]): Point[][];
537
- /**
538
- * Winding number of a set of closed segment chains around `point` (ray to +x, half-open
539
- * crossing rule). Points exactly on the outline may report either side.
540
- */
541
- declare function windingNumber(chains: readonly (readonly BezierSegment[])[], point: Point): number;
542
- /** Whether `point` is inside the filled path (every subpath closed for filling). */
543
- declare function pointInBezierPath(input: BezierPathInput, point: Point, fillRule?: PolygonFillRule): boolean;
544
- /** Distance from `point` to the path outline (closing lines of closed subpaths included). */
545
- declare function distanceToBezierPath(input: BezierPathInput | readonly BezierContour[], point: Point): number;
546
-
547
- export { formatNumber as $, type AffineMatrix as A, type BezierPathInput as B, type CanvasGradientDef as C, type ShapeRenderData as D, type EllipseShape as E, type FlattenOptions as F, type GetShapeRenderDataOptions as G, type StarShape as H, type SvgGradientStop as I, angleToSvgLinearCoords as J, arcToCubics as K, bezierPathBounds as L, type MultiPolygon as M, bezierPathLength as N, bezierPathPointAtLength as O, type PolygonBooleanOperation as P, bezierPathSignedArea as Q, type RectShape as R, type SvgGradientDef as S, bezierPathToSvg as T, closeContour as U, contourSignedArea as V, contoursToPath as W, countPathSegments as X, distanceToBezierPath as Y, dividePolygons as Z, flattenSvgPath as _, type BezierPath as a, getShapeRenderData as a0, getShapeSvg as a1, gradientToSvgDef as a2, intersectPolygons as a3, isCanvasGradient as a4, isShapeDescription as a5, multiPolygonArea as a6, multiPolygonBounds as a7, parseCssGradient as a8, parseSvgPath as a9, unionPolygons as aA, windingNumber as aB, xorPolygons as aC, pathToContours as aa, pointInBezierPath as ab, pointInMultiPolygon as ac, pointInRings as ad, polygonArea as ae, polygonBoolean as af, polygonToSvgPath as ag, resolveCanvasGradient as ah, ringSignedArea as ai, segmentBounds as aj, segmentCurvature as ak, segmentDerivative as al, segmentExtrema as am, segmentLength as an, segmentNearest as ao, segmentParamAtLength as ap, segmentPoint as aq, segmentTangent as ar, shapeToPolygon as as, simplifyRing as at, splitSegment as au, subSegment as av, subtractPolygons as aw, toBezierPath as ax, transformBezierPath as ay, trimSegments as az, type PolygonFillRule as b, type BezierSegment as c, type BezierContour as d, type ShapeDescription as e, type PolygonRing as f, type ShapeSize as g, type BezierCommand as h, type BezierPathToSvgOptions as i, CANVAS_GRADIENT_PRESETS as j, type CanvasLinearGradient as k, type CanvasRadialGradient as l, type GradientStop as m, type PathCommand as n, type PathPointAtLength as o, type PathShape as p, type PolygonBooleanOptions as q, type PolygonInput as r, type PolygonOperand as s, type PolygonPiece as t, type PolygonToPathOptions as u, type PolygonWithHoles as v, type RegularPolygonShape as w, SHAPE_KINDS as x, type ShapeKind as y, type ShapePaint as z };