@pixerate/editor 0.42.0 → 0.43.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/THIRD_PARTY_NOTICES.md +8 -0
- package/dist/canvas/index.d.cts +2 -2
- package/dist/canvas/index.d.ts +2 -2
- package/dist/{pathfinder-D7hXenzu.d.ts → pathfinder-D98S2lV5.d.ts} +1 -1
- package/dist/{pathfinder-BSW2ZTO6.d.cts → pathfinder-DKRcXiLS.d.cts} +1 -1
- package/dist/vector/index.cjs +2041 -424
- package/dist/vector/index.cjs.map +1 -1
- package/dist/vector/index.d.cts +606 -18
- package/dist/vector/index.d.ts +606 -18
- package/dist/vector/index.js +1820 -203
- package/dist/vector/index.js.map +1 -1
- package/package.json +1 -1
package/dist/vector/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as CanvasGradientDef, A as AffineMatrix, B as BezierPathInput, a as BezierPath, S as SvgGradientDef, b as StrokeJoin, c as StrokeCap, d as BezierSegment, P as PlanarMap, e as PathfinderOperation, f as PathfinderShape
|
|
1
|
+
import { C as CanvasGradientDef, A as AffineMatrix, B as BezierPathInput, a as BezierPath, S as SvgGradientDef, b as StrokeJoin, c as StrokeCap, d as BezierSegment, P as PlanarMap, e as PathfinderOperation, f as PathfinderShape } from '../pathfinder-D98S2lV5.js';
|
|
2
2
|
import { P as Point } from '../types-BFkYA4eF.js';
|
|
3
3
|
import { H as HistoryManager } from '../HistoryManager-DWSLd6Tf.js';
|
|
4
4
|
import { C as CommandSpec } from '../registry-DhVUZioj.js';
|
|
@@ -58,8 +58,93 @@ interface VectorSubpath {
|
|
|
58
58
|
/** Joins the last anchor back to the first. */
|
|
59
59
|
closed: boolean;
|
|
60
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Gradient styles: `linear` (start → end), `radial` (centred on the start, reaching the end;
|
|
63
|
+
* focal point and aspect), `conic` (an angle sweep around the start, from the end's direction
|
|
64
|
+
* towards the aspect handle's: clockwise on screen), `reflected` (linear mirrored about the
|
|
65
|
+
* start) and `diamond` (`|u| + |v|` in the gradient's frame: a rhombus through the end and the
|
|
66
|
+
* aspect handle).
|
|
67
|
+
*/
|
|
68
|
+
type VectorGradientType = 'linear' | 'radial' | 'conic' | 'reflected' | 'diamond';
|
|
69
|
+
declare const VECTOR_GRADIENT_TYPES: readonly VectorGradientType[];
|
|
70
|
+
/** What a gradient paints past its ends: the end colours, mirrored periods or repeated periods. */
|
|
71
|
+
type VectorGradientSpread = 'pad' | 'reflect' | 'repeat';
|
|
72
|
+
declare const VECTOR_GRADIENT_SPREADS: readonly VectorGradientSpread[];
|
|
73
|
+
/** Where colours mix between stops: sRGB (SVG's own), linear light or Oklab. */
|
|
74
|
+
type VectorGradientInterpolation = 'srgb' | 'linear' | 'oklab';
|
|
75
|
+
declare const VECTOR_GRADIENT_INTERPOLATIONS: readonly VectorGradientInterpolation[];
|
|
76
|
+
/**
|
|
77
|
+
* The space a gradient's points are in: fractions of the shape's bounding box (SVG's
|
|
78
|
+
* `objectBoundingBox`, the default) or the node's own coordinates (`userSpaceOnUse`).
|
|
79
|
+
*/
|
|
80
|
+
type VectorGradientUnits = 'objectBoundingBox' | 'userSpaceOnUse';
|
|
81
|
+
/**
|
|
82
|
+
* How a gradient lies on a stroke: `within` (laid over the stroke's area like a fill), `along`
|
|
83
|
+
* (t runs from 0 at the start of each subpath to 1 at its end) or `across` (from the stroke's
|
|
84
|
+
* left edge to its right edge, looking along the path).
|
|
85
|
+
*/
|
|
86
|
+
type VectorStrokeGradientMode = 'within' | 'along' | 'across';
|
|
87
|
+
declare const VECTOR_STROKE_GRADIENT_MODES: readonly VectorStrokeGradientMode[];
|
|
88
|
+
/** A colour stop. `opacity` multiplies the colour's own alpha. */
|
|
89
|
+
interface VectorGradientStop {
|
|
90
|
+
/** 0–1. */
|
|
91
|
+
offset: number;
|
|
92
|
+
color: string;
|
|
93
|
+
/** 0–1, default 1. */
|
|
94
|
+
opacity?: number;
|
|
95
|
+
/**
|
|
96
|
+
* Where, between this stop and the next (0–1 of the way), the colour is half-way between
|
|
97
|
+
* them. Default 0.5 (an even mix).
|
|
98
|
+
*/
|
|
99
|
+
midpoint?: number;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* A gradient paint. `CanvasGradientDef` (the canvas package's linear `angle` / radial
|
|
103
|
+
* `cx, cy, r` gradients) is a valid value: those fields are the shorthand form. Explicit
|
|
104
|
+
* geometry (`start` / `end`, in `units`) wins over the shorthand.
|
|
105
|
+
*/
|
|
106
|
+
interface VectorGradient {
|
|
107
|
+
type: VectorGradientType;
|
|
108
|
+
stops: VectorGradientStop[];
|
|
109
|
+
/**
|
|
110
|
+
* Shorthand direction in degrees, CSS style (0 points up, clockwise): a linear or reflected
|
|
111
|
+
* gradient's direction across the box (default 180), a conic gradient's start angle or a
|
|
112
|
+
* diamond's turn (default 90).
|
|
113
|
+
*/
|
|
114
|
+
angle?: number;
|
|
115
|
+
/** Shorthand centre and radius of radial, conic and diamond gradients (fractions of the box, default 0.5). */
|
|
116
|
+
cx?: number;
|
|
117
|
+
cy?: number;
|
|
118
|
+
r?: number;
|
|
119
|
+
/** Where t = 0: a linear gradient's start, the centre of the other styles. */
|
|
120
|
+
start?: Vec2;
|
|
121
|
+
/** Where t = 1 along the gradient's main axis (a radial gradient's radius). */
|
|
122
|
+
end?: Vec2;
|
|
123
|
+
/**
|
|
124
|
+
* The end of the secondary axis (radial, conic and diamond): its distance from `start` over
|
|
125
|
+
* the main axis' length is the aspect ratio. Absent: square to the main axis, as long.
|
|
126
|
+
*/
|
|
127
|
+
width?: Vec2 | null;
|
|
128
|
+
/** A radial gradient's focal point (where t = 0); absent: the centre. */
|
|
129
|
+
focal?: Vec2 | null;
|
|
130
|
+
/** Radius of the focal circle as a fraction of the radius (SVG `fr`, default 0). */
|
|
131
|
+
focalRadius?: number;
|
|
132
|
+
/** Space of `start`, `end`, `width` and `focal` (default `objectBoundingBox`). */
|
|
133
|
+
units?: VectorGradientUnits;
|
|
134
|
+
/** Default `pad`. */
|
|
135
|
+
spread?: VectorGradientSpread;
|
|
136
|
+
/** Default `srgb`. */
|
|
137
|
+
interpolation?: VectorGradientInterpolation;
|
|
138
|
+
/**
|
|
139
|
+
* 0–1: how far the colours follow a smooth spline through the stops instead of straight
|
|
140
|
+
* lines (Photoshop's Smoothness). Default 0.
|
|
141
|
+
*/
|
|
142
|
+
smoothness?: number;
|
|
143
|
+
/** On a stroke: how the gradient lies on it (default `within`). Ignored on fills. */
|
|
144
|
+
strokeMode?: VectorStrokeGradientMode;
|
|
145
|
+
}
|
|
61
146
|
/** A fill or stroke: any CSS colour, a gradient, or `null` / `'none'` for no paint. */
|
|
62
|
-
type VectorPaint = string | CanvasGradientDef | null;
|
|
147
|
+
type VectorPaint = string | VectorGradient | CanvasGradientDef | null;
|
|
63
148
|
type VectorFillRule = 'nonzero' | 'evenodd';
|
|
64
149
|
type VectorLineCap = 'butt' | 'round' | 'square';
|
|
65
150
|
type VectorLineJoin = 'miter' | 'round' | 'bevel';
|
|
@@ -236,7 +321,7 @@ interface VectorHandleRef extends VectorAnchorRef {
|
|
|
236
321
|
* blends the shape clicked first into the one clicked next (clicking an anchor of a closed path
|
|
237
322
|
* starts the blend there).
|
|
238
323
|
*/
|
|
239
|
-
type VectorTool = 'select' | 'direct' | 'pen' | 'pencil' | 'rect' | 'ellipse' | 'polygon' | 'star' | 'line' | 'scissors' | 'knife' | 'eraser' | 'width' | 'shapeBuilder' | 'paintBucket' | 'blend';
|
|
324
|
+
type VectorTool = 'select' | 'direct' | 'pen' | 'pencil' | 'rect' | 'ellipse' | 'polygon' | 'star' | 'line' | 'scissors' | 'knife' | 'eraser' | 'width' | 'shapeBuilder' | 'paintBucket' | 'blend' | 'gradient';
|
|
240
325
|
declare const VECTOR_TOOLS: readonly VectorTool[];
|
|
241
326
|
/** Keyboard modifiers held during a pointer event. */
|
|
242
327
|
interface VectorModifiers {
|
|
@@ -392,11 +477,6 @@ interface VectorSegmentRef {
|
|
|
392
477
|
segment: number;
|
|
393
478
|
}
|
|
394
479
|
|
|
395
|
-
/**
|
|
396
|
-
* Vector path geometry: anchors and handles to Bézier paths and back, bounds, hit-testing,
|
|
397
|
-
* affine transforms, segment splitting, anchor-type conversion and shape factories.
|
|
398
|
-
*/
|
|
399
|
-
|
|
400
480
|
declare const cloneAnchor: (a: VectorAnchor) => VectorAnchor;
|
|
401
481
|
declare const cloneSubpath: (s: VectorSubpath) => VectorSubpath;
|
|
402
482
|
/** A deep copy of a node (ids kept). */
|
|
@@ -577,6 +657,257 @@ declare function lineSubpath(a: Vec2, b: Vec2): VectorSubpath;
|
|
|
577
657
|
/** Rounds every coordinate to `precision` decimals (stable JSON and SVG output). */
|
|
578
658
|
declare function roundSubpaths(subpaths: readonly VectorSubpath[], precision?: number): VectorSubpath[];
|
|
579
659
|
|
|
660
|
+
/** True when `paint` is a gradient (any style). */
|
|
661
|
+
declare function isVectorGradient(paint: VectorPaint | undefined): paint is VectorGradient;
|
|
662
|
+
/** Straight-alpha sRGB channels, 0–1. */
|
|
663
|
+
type VectorRgba = [number, number, number, number];
|
|
664
|
+
/** A CSS colour as 0–1 channels (hex, `rgb()`, `transparent`, `black`, `white`), or null. */
|
|
665
|
+
declare function parseVectorColor(color: string): VectorRgba | null;
|
|
666
|
+
/** Fewest stops a gradient keeps when one is removed. */
|
|
667
|
+
declare const VECTOR_GRADIENT_MIN_STOPS = 2;
|
|
668
|
+
/**
|
|
669
|
+
* Where relative position `u` of a segment lands once its midpoint is `m` (0.5 = unchanged): the
|
|
670
|
+
* colour is half-way at `m`, linear on either side (photocraft `midpoint_remap`).
|
|
671
|
+
*/
|
|
672
|
+
declare function gradientMidpointRemap(u: number, m: number): number;
|
|
673
|
+
/** The stops sorted by offset (stable), offsets clamped to 0–1, unreadable offsets dropped. */
|
|
674
|
+
declare function sortedVectorGradientStops(g: Pick<VectorGradient, 'stops'>): VectorGradientStop[];
|
|
675
|
+
/** Does the gradient need extra stops to look the same in SVG (midpoints, smoothness or a non-sRGB space)? */
|
|
676
|
+
declare function vectorGradientNeedsExpansion(g: VectorGradient): boolean;
|
|
677
|
+
/** A gradient's colour ramp, prepared for sampling. */
|
|
678
|
+
interface VectorGradientRamp {
|
|
679
|
+
/** Straight-alpha sRGB at `t` (clamped to 0–1). */
|
|
680
|
+
sample(t: number): VectorRgba;
|
|
681
|
+
}
|
|
682
|
+
/**
|
|
683
|
+
* The colour ramp of a gradient (midpoints, smoothness and interpolation space applied), or null
|
|
684
|
+
* when a stop colour is not one `parseVectorColor` reads.
|
|
685
|
+
*/
|
|
686
|
+
declare function vectorGradientRamp(g: Pick<VectorGradient, 'stops' | 'interpolation' | 'smoothness'>): VectorGradientRamp | null;
|
|
687
|
+
/** What the gradient paints at `t` (0–1 along its stops): `#rrggbb` and opacity. */
|
|
688
|
+
declare function sampleVectorGradient(g: VectorGradient, t: number): {
|
|
689
|
+
color: string;
|
|
690
|
+
opacity: number;
|
|
691
|
+
};
|
|
692
|
+
/**
|
|
693
|
+
* Plain stops (no midpoints) that SVG's sRGB interpolation turns into the gradient's colours:
|
|
694
|
+
* the stops as they are when nothing needs expanding; one extra stop per off-centre midpoint for
|
|
695
|
+
* sRGB without smoothness (exact: the midpoint makes each half linear); otherwise stops placed
|
|
696
|
+
* adaptively until linear interpolation between them is within `tolerance` (0–1 per channel,
|
|
697
|
+
* default half a level) of the true curve everywhere they were checked.
|
|
698
|
+
*/
|
|
699
|
+
declare function expandVectorGradientStops(g: VectorGradient, options?: {
|
|
700
|
+
tolerance?: number;
|
|
701
|
+
}): VectorGradientStop[];
|
|
702
|
+
/** Linear interpolation between plain stops (what SVG draws from them), straight alpha. */
|
|
703
|
+
declare function samplePlainStops(stops: readonly VectorGradientStop[], t: number): VectorRgba;
|
|
704
|
+
/** The gradient with its stops reversed, each midpoint measured from the other side (vectorcraft `reverse`). */
|
|
705
|
+
declare function reverseVectorGradient<T extends Pick<VectorGradient, 'stops'>>(g: T): T;
|
|
706
|
+
/** A stop added at `offset` painting what the gradient paints there; returns the stops and its index. */
|
|
707
|
+
declare function insertVectorGradientStop(g: VectorGradient, offset: number): {
|
|
708
|
+
stops: VectorGradientStop[];
|
|
709
|
+
index: number;
|
|
710
|
+
};
|
|
711
|
+
/** Stop `index` moved to `offset` (re-sorted); returns the stops and its new index. */
|
|
712
|
+
declare function moveVectorGradientStop(stops: readonly VectorGradientStop[], index: number, offset: number): {
|
|
713
|
+
stops: VectorGradientStop[];
|
|
714
|
+
index: number;
|
|
715
|
+
};
|
|
716
|
+
/** The stops without stop `index`, or null when that would leave fewer than two. */
|
|
717
|
+
declare function removeVectorGradientStop(stops: readonly VectorGradientStop[], index: number): VectorGradientStop[] | null;
|
|
718
|
+
/** Where (0–1 along the gradient) the midpoint after stop `index` sits, or null for the last stop. */
|
|
719
|
+
declare function vectorGradientMidpointPosition(stops: readonly VectorGradientStop[], index: number): number | null;
|
|
720
|
+
/** The midpoint of stop `index` that puts it at position `pos` (clamped to 0.05–0.95), or null. */
|
|
721
|
+
declare function vectorGradientMidpointFromPosition(stops: readonly VectorGradientStop[], index: number, pos: number): number | null;
|
|
722
|
+
/**
|
|
723
|
+
* The part of the gradient from `from` to `to` (0–1, either order) as plain stops over 0–1
|
|
724
|
+
* (vectorcraft `span`): the colours at both ends plus the expanded stops between them.
|
|
725
|
+
*/
|
|
726
|
+
declare function spanVectorGradientStops(g: VectorGradient, from: number, to: number, expanded?: VectorGradientStop[]): VectorGradientStop[];
|
|
727
|
+
/** A gradient's frame points, in its units (see `VectorGradient`). */
|
|
728
|
+
interface VectorGradientPoints {
|
|
729
|
+
start: Vec2;
|
|
730
|
+
end: Vec2;
|
|
731
|
+
width: Vec2;
|
|
732
|
+
focal: Vec2 | null;
|
|
733
|
+
focalRadius: number;
|
|
734
|
+
units: VectorGradientUnits;
|
|
735
|
+
}
|
|
736
|
+
/** Whether the gradient carries its own points (rather than the angle / centre shorthand). */
|
|
737
|
+
declare const hasExplicitGradientGeometry: (g: VectorGradient) => boolean;
|
|
738
|
+
/** The gradient's frame points in its units, the shorthand resolved (it is always in the box). */
|
|
739
|
+
declare function vectorGradientPoints(g: VectorGradient): VectorGradientPoints;
|
|
740
|
+
/**
|
|
741
|
+
* The unit box → `bounds` matrix of `objectBoundingBox` gradients. A side with no extent (a
|
|
742
|
+
* horizontal or vertical line) takes the other side's, centred, so the gradient still paints
|
|
743
|
+
* (SVG paints nothing there).
|
|
744
|
+
*/
|
|
745
|
+
declare function vectorBoxMatrix(bounds: VectorBounds | null | undefined): VectorMatrix;
|
|
746
|
+
/** The gradient's units → node space (the box matrix for `objectBoundingBox`, else the identity). */
|
|
747
|
+
declare function vectorGradientUnitsMatrix(g: VectorGradient, bounds: VectorBounds | null | undefined): VectorMatrix;
|
|
748
|
+
/** The gradient's unit frame → node space: u = 1 at the end, v = 1 at the width point. */
|
|
749
|
+
declare function vectorGradientMatrix(g: VectorGradient, bounds: VectorBounds | null | undefined): VectorMatrix;
|
|
750
|
+
/**
|
|
751
|
+
* t of a radial gradient at unit-frame point `q` with the focal circle centred on `f` with radius
|
|
752
|
+
* `fr` and the end circle the unit circle (SVG's two-point conical gradient). With `fr = 0` this
|
|
753
|
+
* is the focal ray: t is the distance from the focal point to `q` over the distance from it to
|
|
754
|
+
* the circle along the same ray (effectcraft `GradientRamp::t`, vectorcraft `param_at`).
|
|
755
|
+
*/
|
|
756
|
+
declare function vectorGradientFocalParam(q: Vec2, f?: Vec2, fr?: number): number;
|
|
757
|
+
/**
|
|
758
|
+
* The raw gradient parameter (before the spread) of a style at unit-frame point `q`: linear `u`,
|
|
759
|
+
* reflected `|u|`, diamond `|u| + |v|`, conic the turn from the u axis towards the v axis (0–1),
|
|
760
|
+
* radial the distance through the focal circle (photocraft `gradient_t`).
|
|
761
|
+
*/
|
|
762
|
+
declare function vectorGradientParam(type: VectorGradientType, q: Vec2, focal?: {
|
|
763
|
+
f: Vec2;
|
|
764
|
+
fr: number;
|
|
765
|
+
} | null): number;
|
|
766
|
+
/** `t` folded into 0–1 by a spread mode. */
|
|
767
|
+
declare function applyVectorGradientSpread(t: number, spread?: VectorGradientSpread): number;
|
|
768
|
+
/** The gradient's t (spread applied) at node-space point `p` of a shape with box `bounds`. */
|
|
769
|
+
declare function vectorGradientTAt(g: VectorGradient, bounds: VectorBounds | null | undefined, p: Vec2): number;
|
|
770
|
+
/** What the gradient paints at node-space point `p` (straight-alpha sRGB, 0–1). */
|
|
771
|
+
declare function sampleVectorGradientAt(g: VectorGradient, bounds: VectorBounds | null | undefined, p: Vec2): VectorRgba;
|
|
772
|
+
/** The main axis length over the secondary's: |width − start| / |end − start| (signed by side). */
|
|
773
|
+
declare function vectorGradientAspect(g: VectorGradient): number;
|
|
774
|
+
/** The gradient with explicit points (in its units) replacing the shorthand. */
|
|
775
|
+
declare function explicitVectorGradient(g: VectorGradient): VectorGradient;
|
|
776
|
+
/**
|
|
777
|
+
* The gradient in the node's own space (`userSpaceOnUse`), painting what it paints on a shape
|
|
778
|
+
* with box `bounds` (vectorcraft `GradientPaint::pin`): its points mapped through the box.
|
|
779
|
+
*/
|
|
780
|
+
declare function pinVectorGradient(g: VectorGradient, bounds: VectorBounds | null | undefined): VectorGradient;
|
|
781
|
+
/**
|
|
782
|
+
* The gradient after the node's geometry is mapped by `m`: a `userSpaceOnUse` gradient's points
|
|
783
|
+
* are mapped too (any affine map keeps every style's t, since t is measured in the frame the
|
|
784
|
+
* three points span); a box gradient follows the box and is unchanged.
|
|
785
|
+
*/
|
|
786
|
+
declare function transformVectorGradient(g: VectorGradient, m: VectorMatrix): VectorGradient;
|
|
787
|
+
/** A paint after its node's geometry is mapped by `m` (colours unchanged). */
|
|
788
|
+
declare function transformVectorPaint<T extends VectorPaint | undefined>(paint: T, m: VectorMatrix): T;
|
|
789
|
+
/**
|
|
790
|
+
* An on-canvas handle of a gradient: `start` (a radial, conic or diamond gradient's centre),
|
|
791
|
+
* `end` (a linear or reflected gradient's end), `radius` (the end of the others), `aspect` (the
|
|
792
|
+
* secondary axis' end) and `focal` (radial).
|
|
793
|
+
*/
|
|
794
|
+
type VectorGradientHandle = 'start' | 'end' | 'radius' | 'aspect' | 'focal';
|
|
795
|
+
/** Whether the style has a centre with a radius (rather than a start and an end). */
|
|
796
|
+
declare const isCentredVectorGradient: (type: VectorGradientType) => type is "radial" | "conic" | "diamond";
|
|
797
|
+
/** The handles of a gradient in the space `toWorld` maps the node's space to (the document, the screen). */
|
|
798
|
+
declare function vectorGradientHandles(g: VectorGradient, bounds: VectorBounds | null | undefined, toWorld?: VectorMatrix): {
|
|
799
|
+
start: Vec2;
|
|
800
|
+
end: Vec2;
|
|
801
|
+
aspect: Vec2 | null;
|
|
802
|
+
focal: Vec2 | null;
|
|
803
|
+
};
|
|
804
|
+
/**
|
|
805
|
+
* The gradient (pinned to the node's space) with a handle dragged to node-space point `to`.
|
|
806
|
+
* `start` moves the whole gradient by `to − from`; `end` / `radius` move the end, the secondary
|
|
807
|
+
* axis and focal point following; `aspect` sets the secondary axis' length square to the main
|
|
808
|
+
* one; `focal` sets the focal point (pulled inside the circle; null centres it).
|
|
809
|
+
*/
|
|
810
|
+
declare function moveVectorGradientHandle(g: VectorGradient, bounds: VectorBounds | null | undefined, handle: VectorGradientHandle, to: Vec2, from?: Vec2): VectorGradient;
|
|
811
|
+
/** The gradient set to run from `start` to `end` (node space), its secondary axis square to it with its aspect kept. */
|
|
812
|
+
declare function setVectorGradientVector(g: VectorGradient, bounds: VectorBounds | null | undefined, start: Vec2, end: Vec2): VectorGradient;
|
|
813
|
+
/** Most periods a spread is expanded to (vectorcraft `MAX_PERIODS`). */
|
|
814
|
+
declare const VECTOR_GRADIENT_MAX_PERIODS = 64;
|
|
815
|
+
/**
|
|
816
|
+
* Stops repeating the gradient's plain stops over periods `lo` … `hi` (integers, at most
|
|
817
|
+
* `VECTOR_GRADIENT_MAX_PERIODS`), period `k` mirrored when `mirrored(k)`; offsets over 0–1 span
|
|
818
|
+
* the whole range (vectorcraft `spread::expand`, which emulates `reflect` and `repeat` this way).
|
|
819
|
+
*/
|
|
820
|
+
declare function periodicVectorGradientStops(stops: readonly VectorGradientStop[], lo: number, hi: number, mirrored: (k: number) => boolean): VectorGradientStop[];
|
|
821
|
+
/**
|
|
822
|
+
* A linear or reflected gradient's spread as stop periods over `area` (node space), for
|
|
823
|
+
* renderers (and combinations) without the spread mode: vectorcraft's SVG import emulates
|
|
824
|
+
* `reflect` and `repeat` this way. Returns where the periods start and end and their stops, or
|
|
825
|
+
* null when a linear gradient pads (nothing to repeat). Reflected gradients always get at least
|
|
826
|
+
* the period either side of the start (the one before it mirrored). `from` / `to` are the
|
|
827
|
+
* periods' ends along the frame's u axis (`matrix` maps the frame to node space).
|
|
828
|
+
*/
|
|
829
|
+
declare function expandVectorGradientSpread(g: VectorGradient, bounds: VectorBounds | null | undefined, area: VectorBounds): {
|
|
830
|
+
start: Vec2;
|
|
831
|
+
end: Vec2;
|
|
832
|
+
from: number;
|
|
833
|
+
to: number;
|
|
834
|
+
matrix: VectorMatrix;
|
|
835
|
+
stops: VectorGradientStop[];
|
|
836
|
+
capped: boolean;
|
|
837
|
+
} | null;
|
|
838
|
+
/**
|
|
839
|
+
* A `<pattern>` paint server in user space: draw `gradients` (inside it or in `<defs>`) and then
|
|
840
|
+
* each tile (`d` filled with `fill`) in order, all in the painted element's user space (the
|
|
841
|
+
* `viewBox` in `attrs` matches the tile, so keep it). Conic and diamond gradients, and gradients along
|
|
842
|
+
* or across a stroke, take this form.
|
|
843
|
+
*/
|
|
844
|
+
interface VectorSvgPatternDef {
|
|
845
|
+
id: string;
|
|
846
|
+
type: 'pattern';
|
|
847
|
+
/** `x`, `y`, `width`, `height`, `patternUnits="userSpaceOnUse"` and the matching `viewBox`. */
|
|
848
|
+
attrs: Record<string, string | number>;
|
|
849
|
+
gradients: SvgGradientDef[];
|
|
850
|
+
tiles: {
|
|
851
|
+
d: string;
|
|
852
|
+
fill: string;
|
|
853
|
+
}[];
|
|
854
|
+
}
|
|
855
|
+
/** A paint server for `fill` / `stroke`: a gradient element or a pattern of gradient tiles. */
|
|
856
|
+
type VectorPaintDef = SvgGradientDef | VectorSvgPatternDef;
|
|
857
|
+
interface VectorGradientSvgOptions {
|
|
858
|
+
/** The shape's box in its own space (for `objectBoundingBox` gradients). */
|
|
859
|
+
bounds?: VectorBounds | null;
|
|
860
|
+
/** The area the paint must cover (pattern tiles, spread periods); default `bounds` padded by 1. */
|
|
861
|
+
area?: VectorBounds | null;
|
|
862
|
+
/** Wedges of a conic gradient (default 72: 5° each). */
|
|
863
|
+
wedges?: number;
|
|
864
|
+
precision?: number;
|
|
865
|
+
}
|
|
866
|
+
/** The area a gradient on a shape with box `bounds` paints (the box padded by 1). */
|
|
867
|
+
declare const vectorGradientArea: (bounds: VectorBounds | null | undefined) => VectorBounds;
|
|
868
|
+
/**
|
|
869
|
+
* A user-space pattern tile over `area`. Without a `viewBox` SVG puts the content's origin at the
|
|
870
|
+
* tile's corner; the matching `viewBox` keeps the content in the painted element's user space.
|
|
871
|
+
*/
|
|
872
|
+
declare function patternAttrs(area: VectorBounds): Record<string, string>;
|
|
873
|
+
/**
|
|
874
|
+
* The SVG paint servers of a gradient on a shape: the first def's id is `id` (reference it as
|
|
875
|
+
* `url(#id)`), any others are what it uses. All are in the user space of the element painted
|
|
876
|
+
* (the node's own space).
|
|
877
|
+
*/
|
|
878
|
+
declare function vectorGradientSvgDefs(g: VectorGradient, id: string, options?: VectorGradientSvgOptions): VectorPaintDef[];
|
|
879
|
+
/**
|
|
880
|
+
* What a `userSpaceOnUse` paint server from `vectorGradientSvgDefs` paints at point `p` (straight
|
|
881
|
+
* alpha, 0–1) the way an SVG renderer would: a gradient's stops interpolated in sRGB, a pattern's
|
|
882
|
+
* topmost tile containing `p`. Null for a point no tile covers.
|
|
883
|
+
*/
|
|
884
|
+
declare function sampleVectorPaintDefAt(defs: readonly VectorPaintDef[], id: string, p: Vec2): VectorRgba | null;
|
|
885
|
+
/**
|
|
886
|
+
* A gradient from untrusted input (agent commands, SVG data attributes), or null when it is not
|
|
887
|
+
* one: unknown fields dropped, numbers clamped, at least one stop.
|
|
888
|
+
*/
|
|
889
|
+
declare function sanitizeVectorGradient(input: unknown): VectorGradient | null;
|
|
890
|
+
/**
|
|
891
|
+
* A gradient changed to style `type`, keeping its stops, colour settings and placement: explicit
|
|
892
|
+
* points stay where they are (a linear end becomes a radius), shorthand is redone for the style.
|
|
893
|
+
*/
|
|
894
|
+
declare function convertVectorGradient(g: VectorGradient, type: VectorGradientType): VectorGradient;
|
|
895
|
+
/** A default gradient for a paint that was a colour (or nothing): the colour fading to white. */
|
|
896
|
+
declare function defaultVectorGradient(type?: VectorGradientType, from?: VectorPaint): VectorGradient;
|
|
897
|
+
/**
|
|
898
|
+
* Changes to a gradient (`vector.setGradient`, the gradient editor): any gradient field, plus
|
|
899
|
+
* `aspect` (the secondary axis' length over the main one, square to it) and `reverse`. `focal` or
|
|
900
|
+
* `width` set to null removes them.
|
|
901
|
+
*/
|
|
902
|
+
interface VectorGradientPatch extends Partial<Omit<VectorGradient, 'focal' | 'width'>> {
|
|
903
|
+
focal?: Vec2 | null;
|
|
904
|
+
width?: Vec2 | null;
|
|
905
|
+
aspect?: number;
|
|
906
|
+
reverse?: boolean;
|
|
907
|
+
}
|
|
908
|
+
/** `g` with `patch` applied (a style change converts it first), or null when the result is not a gradient. */
|
|
909
|
+
declare function applyVectorGradientPatch(g: VectorGradient, patch: VectorGradientPatch): VectorGradient | null;
|
|
910
|
+
|
|
580
911
|
interface VectorSvgExportOptions {
|
|
581
912
|
/** Decimal places for coordinates (default 3). */
|
|
582
913
|
precision?: number;
|
|
@@ -599,10 +930,23 @@ interface VectorSvgExportOptions {
|
|
|
599
930
|
declare function vectorCornersAttribute(subpaths: readonly VectorSubpath[], precision?: number): string;
|
|
600
931
|
/** Puts `data-vector-corners` back on subpaths (malformed entries are ignored). */
|
|
601
932
|
declare function applyVectorCornersAttribute(subpaths: VectorSubpath[], value: string): VectorSubpath[];
|
|
602
|
-
/**
|
|
603
|
-
|
|
933
|
+
/** Where a paint goes: what `vectorPaintToSvg` needs to place a gradient on a shape. */
|
|
934
|
+
interface VectorPaintSvgOptions {
|
|
935
|
+
/** The path painted (its box places `objectBoundingBox` gradients; strokes need its geometry). */
|
|
936
|
+
node?: VectorPathNode;
|
|
937
|
+
/** `stroke` lays `along` / `across` gradients on the stroke and covers its reach (default `fill`). */
|
|
938
|
+
role?: 'fill' | 'stroke';
|
|
939
|
+
precision?: number;
|
|
940
|
+
}
|
|
941
|
+
/** The box of a path's drawn outline in its own space (null when it has no points). */
|
|
942
|
+
declare function vectorPathLocalBounds(node: VectorPathNode): VectorBounds | null;
|
|
943
|
+
/**
|
|
944
|
+
* A paint as an SVG attribute value plus the paint servers it needs (`url(#id)` refers to the
|
|
945
|
+
* first). Gradients sit in the painted element's user space (the node's own space).
|
|
946
|
+
*/
|
|
947
|
+
declare function vectorPaintToSvg(paint: VectorPaint | undefined, gradientId: string, options?: VectorPaintSvgOptions): {
|
|
604
948
|
value: string;
|
|
605
|
-
|
|
949
|
+
defs: VectorPaintDef[];
|
|
606
950
|
};
|
|
607
951
|
/** The parts of an aligned or arrowed stroke (see `VectorRenderPath.strokeParts`). */
|
|
608
952
|
interface VectorRenderStrokeParts {
|
|
@@ -833,6 +1177,85 @@ declare function pressureWidthProfile(samples: readonly {
|
|
|
833
1177
|
tolerance?: number;
|
|
834
1178
|
}): VectorWidthPoint[];
|
|
835
1179
|
|
|
1180
|
+
/**
|
|
1181
|
+
* The Gradient tool's on-canvas annotator: a bar from the start (or centre) handle to the end (or
|
|
1182
|
+
* radius) handle with the colour stops under it and midpoint diamonds above it, plus a radial,
|
|
1183
|
+
* conic or diamond gradient's extent outline, aspect handle and (radial) focal point. All in
|
|
1184
|
+
* screen pixels, for hit-testing and the overlay.
|
|
1185
|
+
*
|
|
1186
|
+
* After vectorcraft `crates/tools/src/xform/gradient.rs` (`Annotator`: stop chips below the bar,
|
|
1187
|
+
* midpoints above it, a stop dragged off the bar is removed, a click on the bar adds one), ArtCraft,
|
|
1188
|
+
* MIT OR Apache-2.0 — see THIRD_PARTY_NOTICES.md.
|
|
1189
|
+
*/
|
|
1190
|
+
|
|
1191
|
+
/** Which paint of the selection the Gradient tool and the gradient editor work on. */
|
|
1192
|
+
type VectorGradientTarget = 'fill' | 'stroke';
|
|
1193
|
+
/** A part of the annotator under the pointer. */
|
|
1194
|
+
type VectorGradientPart = {
|
|
1195
|
+
kind: 'handle';
|
|
1196
|
+
handle: VectorGradientHandle;
|
|
1197
|
+
} | {
|
|
1198
|
+
kind: 'stop';
|
|
1199
|
+
index: number;
|
|
1200
|
+
} | {
|
|
1201
|
+
kind: 'midpoint';
|
|
1202
|
+
index: number;
|
|
1203
|
+
}
|
|
1204
|
+
/** The bar at `offset` (0–1): a click adds a stop there, a drag moves the gradient. */
|
|
1205
|
+
| {
|
|
1206
|
+
kind: 'bar';
|
|
1207
|
+
offset: number;
|
|
1208
|
+
};
|
|
1209
|
+
/** Distance of the stop chips below the bar, the midpoint diamonds above it (screen pixels). */
|
|
1210
|
+
declare const VECTOR_GRADIENT_STOP_GAP = 12;
|
|
1211
|
+
declare const VECTOR_GRADIENT_MIDPOINT_GAP = 9;
|
|
1212
|
+
/** How far off the bar a dragged stop goes before it is removed (screen pixels). */
|
|
1213
|
+
declare const VECTOR_GRADIENT_OFF_BAR = 24;
|
|
1214
|
+
interface VectorGradientAnnotator {
|
|
1215
|
+
nodeId: string;
|
|
1216
|
+
target: VectorGradientTarget;
|
|
1217
|
+
gradient: VectorGradient;
|
|
1218
|
+
/** The path's box in its own space. */
|
|
1219
|
+
bounds: VectorBounds | null;
|
|
1220
|
+
/** The path's own space → document. */
|
|
1221
|
+
world: AffineMatrix;
|
|
1222
|
+
/** Screen positions of the handles. */
|
|
1223
|
+
start: Vec2;
|
|
1224
|
+
end: Vec2;
|
|
1225
|
+
/** Radial, conic and diamond gradients. */
|
|
1226
|
+
aspect: Vec2 | null;
|
|
1227
|
+
/** Radial gradients. */
|
|
1228
|
+
focal: Vec2 | null;
|
|
1229
|
+
/** Unit normal to the bar towards the stop chips (screen). */
|
|
1230
|
+
normal: Vec2;
|
|
1231
|
+
/** Stops (sorted, as the gradient stores them) with their chips' screen positions. */
|
|
1232
|
+
stops: (VectorGradientStop & {
|
|
1233
|
+
index: number;
|
|
1234
|
+
x: number;
|
|
1235
|
+
y: number;
|
|
1236
|
+
})[];
|
|
1237
|
+
/** The midpoint diamond after each stop but the last (screen). */
|
|
1238
|
+
midpoints: {
|
|
1239
|
+
index: number;
|
|
1240
|
+
x: number;
|
|
1241
|
+
y: number;
|
|
1242
|
+
midpoint: number;
|
|
1243
|
+
}[];
|
|
1244
|
+
/** Screen path of the extent: an ellipse (radial, conic) or a rhombus (diamond). */
|
|
1245
|
+
extent: string | null;
|
|
1246
|
+
}
|
|
1247
|
+
/** The path whose `target` paint the annotator shows: the first path of the selection with a gradient there. */
|
|
1248
|
+
declare function vectorGradientTargetPath(doc: VectorDocument, selection: readonly string[], target: VectorGradientTarget): VectorPathNode | null;
|
|
1249
|
+
/** The annotator of the selection's gradient (`target` paint), in screen pixels, or null when it has none. */
|
|
1250
|
+
declare function getVectorGradientAnnotator(doc: VectorDocument, selection: readonly string[], viewport: VectorViewport, target: VectorGradientTarget): VectorGradientAnnotator | null;
|
|
1251
|
+
/** Where `p` lies relative to the bar: offset along it (0 at the start, 1 at the end) and distance towards the stop chips. */
|
|
1252
|
+
declare function vectorGradientBarPosition(a: Pick<VectorGradientAnnotator, 'start' | 'end' | 'normal'>, p: Vec2): {
|
|
1253
|
+
offset: number;
|
|
1254
|
+
across: number;
|
|
1255
|
+
};
|
|
1256
|
+
/** The annotator part under screen point `p`: stops, then midpoints, the handles and the bar. */
|
|
1257
|
+
declare function hitVectorGradientAnnotator(a: VectorGradientAnnotator, p: Vec2): VectorGradientPart | null;
|
|
1258
|
+
|
|
836
1259
|
/**
|
|
837
1260
|
* What a guide line shows: `align` lines run from a target through the snapped point or box,
|
|
838
1261
|
* `construction` lines from where a drawn point leaves, `spacing` marks equal gaps and `size`
|
|
@@ -1170,6 +1593,8 @@ interface VectorHover {
|
|
|
1170
1593
|
};
|
|
1171
1594
|
/** A spot on a stroke away from its width points (width tool). */
|
|
1172
1595
|
strokeSpot?: VectorStrokeSpot;
|
|
1596
|
+
/** A part of the gradient annotator (gradient tool). */
|
|
1597
|
+
gradient?: VectorGradientPart;
|
|
1173
1598
|
}
|
|
1174
1599
|
/** The drag in progress, for overlays and status text. */
|
|
1175
1600
|
type VectorInteraction = {
|
|
@@ -1224,6 +1649,13 @@ type VectorInteraction = {
|
|
|
1224
1649
|
} | {
|
|
1225
1650
|
type: 'pen';
|
|
1226
1651
|
nodeId: string;
|
|
1652
|
+
}
|
|
1653
|
+
/** A gradient tool drag: drawing a new vector, or a handle, stop, midpoint or the bar (`removing`: a stop dragged off the bar). */
|
|
1654
|
+
| {
|
|
1655
|
+
type: 'gradient';
|
|
1656
|
+
part: 'create' | VectorGradientPart['kind'];
|
|
1657
|
+
handle?: VectorGradientHandle;
|
|
1658
|
+
removing?: boolean;
|
|
1227
1659
|
} | {
|
|
1228
1660
|
type: 'pan';
|
|
1229
1661
|
};
|
|
@@ -1269,6 +1701,11 @@ interface VectorEditorState {
|
|
|
1269
1701
|
blendStart: VectorBlendStart | null;
|
|
1270
1702
|
/** Options new blends get. */
|
|
1271
1703
|
blendDefaults: VectorBlendOptions;
|
|
1704
|
+
/** The paint the gradient tool and gradient editor work on, and the selected stop (index into the sorted stops). */
|
|
1705
|
+
gradientEdit: {
|
|
1706
|
+
target: VectorGradientTarget;
|
|
1707
|
+
stop: number | null;
|
|
1708
|
+
};
|
|
1272
1709
|
canUndo: boolean;
|
|
1273
1710
|
canRedo: boolean;
|
|
1274
1711
|
undoLabel: string;
|
|
@@ -1524,6 +1961,7 @@ declare class VectorEditorController {
|
|
|
1524
1961
|
private blendStart;
|
|
1525
1962
|
/** Options new blends get (the toolbars edit them along with the selected blend's). */
|
|
1526
1963
|
private blendDefaults;
|
|
1964
|
+
private gradientEdit;
|
|
1527
1965
|
/** What the highlight shows, to skip notifying when the pointer stays over the same face. */
|
|
1528
1966
|
private builderHoverKey;
|
|
1529
1967
|
private readonly createId;
|
|
@@ -1536,7 +1974,13 @@ declare class VectorEditorController {
|
|
|
1536
1974
|
private revision;
|
|
1537
1975
|
private state;
|
|
1538
1976
|
constructor(options?: VectorEditorOptions);
|
|
1539
|
-
/**
|
|
1977
|
+
/** Listens to the history (once; again after `destroy`). */
|
|
1978
|
+
private connect;
|
|
1979
|
+
private historyDiffers;
|
|
1980
|
+
/**
|
|
1981
|
+
* Stops listening to the history and drops all listeners. A later `subscribe` reconnects, so a
|
|
1982
|
+
* controller torn down by React StrictMode's double effect keeps working when it is reused.
|
|
1983
|
+
*/
|
|
1540
1984
|
destroy(): void;
|
|
1541
1985
|
/** The current snapshot (stable until the next change). */
|
|
1542
1986
|
getState: () => VectorEditorState;
|
|
@@ -1658,6 +2102,47 @@ declare class VectorEditorController {
|
|
|
1658
2102
|
} | null, options?: {
|
|
1659
2103
|
ids?: readonly string[];
|
|
1660
2104
|
}): VectorActionResult;
|
|
2105
|
+
/** Which paint (fill or stroke) the gradient tool and editor work on. */
|
|
2106
|
+
setGradientTarget(target: VectorGradientTarget): void;
|
|
2107
|
+
/** Selects a stop of the gradient being edited (index into its sorted stops), or none. */
|
|
2108
|
+
selectGradientStop(index: number | null): void;
|
|
2109
|
+
/** The gradient tool's annotator for the selection (screen pixels), or null when its paint is not a gradient. */
|
|
2110
|
+
getGradientAnnotator(): VectorGradientAnnotator | null;
|
|
2111
|
+
/** Unlocked paths of `ids` (default: the selection). */
|
|
2112
|
+
private gradientPaths;
|
|
2113
|
+
/**
|
|
2114
|
+
* Edits the gradient of the `target` paint (default: the editor's) of the selected (or given)
|
|
2115
|
+
* paths with `patch`: a colour or no paint becomes a gradient (`patch.type`, default linear,
|
|
2116
|
+
* from the colour to white). Consecutive edits with the same `merge` key are one undo step.
|
|
2117
|
+
*/
|
|
2118
|
+
setGradient(patch: VectorGradientPatch, options?: {
|
|
2119
|
+
ids?: readonly string[];
|
|
2120
|
+
target?: VectorGradientTarget;
|
|
2121
|
+
label?: string;
|
|
2122
|
+
merge?: string;
|
|
2123
|
+
}): VectorActionResult;
|
|
2124
|
+
/** Applies `fn` to every target gradient of the selection (paths whose paint is not a gradient are skipped). */
|
|
2125
|
+
private editGradients;
|
|
2126
|
+
/** Changes stop `index` (colour, opacity, offset or midpoint) of the selection's gradients; selects it. */
|
|
2127
|
+
setGradientStop(index: number, patch: {
|
|
2128
|
+
color?: string;
|
|
2129
|
+
opacity?: number;
|
|
2130
|
+
offset?: number;
|
|
2131
|
+
midpoint?: number;
|
|
2132
|
+
}, options?: {
|
|
2133
|
+
merge?: string;
|
|
2134
|
+
}): VectorActionResult;
|
|
2135
|
+
/** Adds a stop at `offset` (painting what the gradient paints there) to the selection's gradients and selects it. */
|
|
2136
|
+
addGradientStop(offset: number): VectorActionResult;
|
|
2137
|
+
/** Removes stop `index` of the selection's gradients (never below two stops). */
|
|
2138
|
+
removeGradientStop(index: number): VectorActionResult;
|
|
2139
|
+
/** Reverses the selection's gradients (stops and midpoints). */
|
|
2140
|
+
reverseGradient(): VectorActionResult;
|
|
2141
|
+
/** `doc` with path `id`'s `target` paint replaced. */
|
|
2142
|
+
private withGradient;
|
|
2143
|
+
private downGradient;
|
|
2144
|
+
private moveGradient;
|
|
2145
|
+
private upGradient;
|
|
1661
2146
|
/** Removes one width point of a path's profile. */
|
|
1662
2147
|
removeWidthPoint(ref: Pick<VectorWidthPointRef, 'nodeId' | 'index'>): VectorActionResult;
|
|
1663
2148
|
/** Removes width points (default: the selected ones — the width tool's Delete), as one undo step. */
|
|
@@ -2357,8 +2842,12 @@ interface VectorSceneRenderData {
|
|
|
2357
2842
|
width: number;
|
|
2358
2843
|
height: number;
|
|
2359
2844
|
background?: string;
|
|
2360
|
-
/**
|
|
2361
|
-
|
|
2845
|
+
/**
|
|
2846
|
+
* Paint servers referenced by `fill` / `stroke` values: `<linearGradient>` /
|
|
2847
|
+
* `<radialGradient>` descriptors and `pattern`s (conic, diamond and stroke-mode gradients:
|
|
2848
|
+
* draw each of `gradients`, then each tile filled, inside a `<pattern>`).
|
|
2849
|
+
*/
|
|
2850
|
+
defs: VectorPaintDef[];
|
|
2362
2851
|
/** Visible nodes, bottom to top. */
|
|
2363
2852
|
nodes: VectorRenderNode[];
|
|
2364
2853
|
}
|
|
@@ -2528,9 +3017,62 @@ interface VectorOverlayRenderData {
|
|
|
2528
3017
|
hovered: boolean;
|
|
2529
3018
|
}[];
|
|
2530
3019
|
};
|
|
3020
|
+
/** The gradient tool's annotator over the selection's gradient (screen space), or null. */
|
|
3021
|
+
gradient: VectorRenderGradientAnnotator | null;
|
|
2531
3022
|
/** A short status, e.g. "W 120 × H 80" or "45°". */
|
|
2532
3023
|
status: string | null;
|
|
2533
3024
|
}
|
|
3025
|
+
/**
|
|
3026
|
+
* The gradient annotator in screen pixels: draw the `extent` outline (dashed), the bar from
|
|
3027
|
+
* `start` to `end`, the handles, each stop's chip (a swatch at `x, y` with a tick to `barX, barY`;
|
|
3028
|
+
* `removing`: the dragged stop is off the bar and will be deleted, draw it faded) and the
|
|
3029
|
+
* midpoint diamonds.
|
|
3030
|
+
*/
|
|
3031
|
+
interface VectorRenderGradientAnnotator {
|
|
3032
|
+
nodeId: string;
|
|
3033
|
+
type: VectorGradientType;
|
|
3034
|
+
start: {
|
|
3035
|
+
x: number;
|
|
3036
|
+
y: number;
|
|
3037
|
+
hovered: boolean;
|
|
3038
|
+
};
|
|
3039
|
+
/** `radius` for radial, conic and diamond gradients. */
|
|
3040
|
+
end: {
|
|
3041
|
+
x: number;
|
|
3042
|
+
y: number;
|
|
3043
|
+
hovered: boolean;
|
|
3044
|
+
handle: 'end' | 'radius';
|
|
3045
|
+
};
|
|
3046
|
+
aspect: {
|
|
3047
|
+
x: number;
|
|
3048
|
+
y: number;
|
|
3049
|
+
hovered: boolean;
|
|
3050
|
+
} | null;
|
|
3051
|
+
focal: {
|
|
3052
|
+
x: number;
|
|
3053
|
+
y: number;
|
|
3054
|
+
hovered: boolean;
|
|
3055
|
+
} | null;
|
|
3056
|
+
stops: {
|
|
3057
|
+
index: number;
|
|
3058
|
+
x: number;
|
|
3059
|
+
y: number;
|
|
3060
|
+
barX: number;
|
|
3061
|
+
barY: number;
|
|
3062
|
+
color: string;
|
|
3063
|
+
opacity: number;
|
|
3064
|
+
selected: boolean;
|
|
3065
|
+
hovered: boolean;
|
|
3066
|
+
}[];
|
|
3067
|
+
midpoints: {
|
|
3068
|
+
index: number;
|
|
3069
|
+
x: number;
|
|
3070
|
+
y: number;
|
|
3071
|
+
hovered: boolean;
|
|
3072
|
+
}[];
|
|
3073
|
+
extent: string | null;
|
|
3074
|
+
removing: boolean;
|
|
3075
|
+
}
|
|
2534
3076
|
/** Distance between the Shape Builder's hatch lines over a face (screen pixels). */
|
|
2535
3077
|
declare const VECTOR_BUILDER_HATCH_GAP = 6;
|
|
2536
3078
|
/**
|
|
@@ -2680,6 +3222,38 @@ declare const VECTOR_CORNER_KIND_LABELS: Readonly<Record<VectorCornerKind, strin
|
|
|
2680
3222
|
declare const VECTOR_ARROWHEAD_LABELS: Readonly<Record<VectorArrowhead, string>>;
|
|
2681
3223
|
/** A paint as `#rrggbb` for `<input type="color">`, or null for none, gradients and other CSS colours. */
|
|
2682
3224
|
declare function vectorPaintToHex(paint: VectorPaint | undefined): string | null;
|
|
3225
|
+
declare const VECTOR_GRADIENT_TYPE_LABELS: Readonly<Record<VectorGradientType, string>>;
|
|
3226
|
+
declare const VECTOR_GRADIENT_SPREAD_LABELS: Readonly<Record<VectorGradientSpread, string>>;
|
|
3227
|
+
declare const VECTOR_GRADIENT_INTERPOLATION_LABELS: Readonly<Record<VectorGradientInterpolation, string>>;
|
|
3228
|
+
declare const VECTOR_STROKE_GRADIENT_MODE_LABELS: Readonly<Record<VectorStrokeGradientMode, string>>;
|
|
3229
|
+
/** What a gradient editor shows for the selection's `target` paint (see `getVectorGradientEditor`). */
|
|
3230
|
+
interface VectorGradientEditorData {
|
|
3231
|
+
target: 'fill' | 'stroke';
|
|
3232
|
+
/** The first selected path's paint is a gradient. */
|
|
3233
|
+
gradient: VectorGradient | null;
|
|
3234
|
+
/** The paint as a `#rrggbb` colour when it is one (what a new gradient starts from). */
|
|
3235
|
+
color: string | null;
|
|
3236
|
+
/** Sorted stops; `index` is what `setGradientStop` takes. */
|
|
3237
|
+
stops: (VectorGradientStop & {
|
|
3238
|
+
index: number;
|
|
3239
|
+
selected: boolean;
|
|
3240
|
+
})[];
|
|
3241
|
+
selected: (VectorGradientStop & {
|
|
3242
|
+
index: number;
|
|
3243
|
+
last: boolean;
|
|
3244
|
+
}) | null;
|
|
3245
|
+
/** A CSS `linear-gradient(to right, …)` of the ramp (midpoints and colour space expanded). */
|
|
3246
|
+
preview: string | null;
|
|
3247
|
+
type: VectorGradientType | null;
|
|
3248
|
+
spread: VectorGradientSpread;
|
|
3249
|
+
interpolation: VectorGradientInterpolation;
|
|
3250
|
+
smoothness: number;
|
|
3251
|
+
strokeMode: VectorStrokeGradientMode;
|
|
3252
|
+
/** The selected paths' gradients differ. */
|
|
3253
|
+
mixed: boolean;
|
|
3254
|
+
}
|
|
3255
|
+
/** The gradient editor of the selection's fill or stroke (`state.gradientEdit.target`), or null with nothing selected. */
|
|
3256
|
+
declare function getVectorGradientEditor(state: Pick<VectorEditorState, 'document' | 'selection' | 'gradientEdit'>): VectorGradientEditorData | null;
|
|
2683
3257
|
/** A path-editing button of the bundled toolbars. */
|
|
2684
3258
|
interface VectorPathAction {
|
|
2685
3259
|
id: 'join' | 'average' | 'cut' | 'clean' | 'smooth' | 'outline';
|
|
@@ -3267,7 +3841,7 @@ declare function vectorFillMap(doc: VectorDocument, gap?: number): PlanarMap | n
|
|
|
3267
3841
|
* pair turns the same way), so a nonzero fill keeps its holes.
|
|
3268
3842
|
* - **In-betweens** follow the shapes' best-fit rotation and scale (Procrustes), with the
|
|
3269
3843
|
* leftover difference blended in linearly, so a turning shape turns instead of collapsing.
|
|
3270
|
-
* - **Paint**: colours mix in OKLab, gradients of one
|
|
3844
|
+
* - **Paint**: colours mix in OKLab, gradients of one style resample their stops to a common
|
|
3271
3845
|
* set, a missing paint fades from transparent; stroke width, opacity, dashes, arrowhead
|
|
3272
3846
|
* scales and width profiles interpolate, and the rest switches halfway.
|
|
3273
3847
|
* - **Transforms**: both shapes are blended in their parent's space; the in-between's rigid
|
|
@@ -3368,8 +3942,11 @@ declare function interpolateMorphContours(a: readonly VectorMorphContour[], b: r
|
|
|
3368
3942
|
declare function interpolateRigidMatrix(a: AffineMatrix, b: AffineMatrix, t: number): AffineMatrix;
|
|
3369
3943
|
/** Two colours mixed in OKLab (premultiplied alpha); unreadable colours switch halfway. */
|
|
3370
3944
|
declare function interpolateVectorColor(a: string, b: string, t: number): string;
|
|
3371
|
-
/**
|
|
3372
|
-
|
|
3945
|
+
/**
|
|
3946
|
+
* A gradient's stops resampled at `offsets`, each painting what the gradient paints there (its
|
|
3947
|
+
* midpoints, smoothness and interpolation space included).
|
|
3948
|
+
*/
|
|
3949
|
+
declare function resampleGradientStops(g: VectorGradient, offsets: readonly number[]): VectorGradientStop[];
|
|
3373
3950
|
/**
|
|
3374
3951
|
* Interpolates paints: colours in OKLab, gradients of one kind with their stops resampled to a
|
|
3375
3952
|
* common set, a colour and a gradient through a gradient of that colour, and a missing paint
|
|
@@ -3561,4 +4138,15 @@ declare function repeatPaths(paths: readonly BezierPath[], r: VectorEffectParams
|
|
|
3561
4138
|
/** The middle of the paths' bounds (the origin when they are empty). */
|
|
3562
4139
|
declare function pathsCenter(paths: readonly BezierPath[]): Vec2;
|
|
3563
4140
|
|
|
3564
|
-
|
|
4141
|
+
/**
|
|
4142
|
+
* The paint server of a gradient along or across the stroke of `node` (in its own space): a
|
|
4143
|
+
* pattern whose first def id is `id`. `area` defaults to the path's box padded by the stroke's
|
|
4144
|
+
* reach.
|
|
4145
|
+
*/
|
|
4146
|
+
declare function vectorStrokeGradientDefs(g: VectorGradient, id: string, node: VectorPathNode, options?: {
|
|
4147
|
+
bounds?: VectorBounds | null;
|
|
4148
|
+
area?: VectorBounds | null;
|
|
4149
|
+
precision?: number;
|
|
4150
|
+
}): VectorPaintDef[];
|
|
4151
|
+
|
|
4152
|
+
export { type AddVectorNodeOptions, AffineMatrix, DEFAULT_VECTOR_BLEND_DISTANCE, DEFAULT_VECTOR_BLEND_STEPS, DEFAULT_VECTOR_PATH_EDIT, DEFAULT_VECTOR_SNAP, IDENTITY_MATRIX, KAPPA, LazyMouse, type NearestSegment, type RecognizeInkOptions, SvgGradientDef, VECTOR_ARROWHEADS, VECTOR_ARROWHEAD_LABELS, VECTOR_BLEND_MAX_SMOOTH_STEPS, VECTOR_BLEND_MAX_STEPS, VECTOR_BLEND_SPACINGS, VECTOR_BLEND_SPACING_LABELS, VECTOR_BUILDER_HATCH_GAP, VECTOR_CLIPBOARD_TYPE, VECTOR_CONSTRUCTION_ANGLES, VECTOR_CORNER_KINDS, VECTOR_CORNER_KIND_LABELS, VECTOR_CORNER_WIDGET_INSET, VECTOR_EDIT_TOGGLES, VECTOR_EFFECT_DEFAULTS, VECTOR_EFFECT_LABELS, VECTOR_EFFECT_MENU, VECTOR_EFFECT_PARAM_SPECS, VECTOR_EFFECT_TYPES, VECTOR_FILL_GAP, VECTOR_GRADIENT_INTERPOLATIONS, VECTOR_GRADIENT_INTERPOLATION_LABELS, VECTOR_GRADIENT_MAX_PERIODS, VECTOR_GRADIENT_MIDPOINT_GAP, VECTOR_GRADIENT_MIN_STOPS, VECTOR_GRADIENT_OFF_BAR, VECTOR_GRADIENT_SPREADS, VECTOR_GRADIENT_SPREAD_LABELS, VECTOR_GRADIENT_STOP_GAP, VECTOR_GRADIENT_TYPES, VECTOR_GRADIENT_TYPE_LABELS, VECTOR_INK_MAX_CORNERS, VECTOR_MERGE_MODES, VECTOR_OVERLAY_THEME, VECTOR_PATHFINDER_ACTIONS, VECTOR_PATHFINDER_LABELS, VECTOR_PATHFINDER_OPERATIONS, VECTOR_PATH_ACTIONS, VECTOR_PENCIL_STRING_PX, VECTOR_PRESSURE_NOMINAL, VECTOR_ROTATE_HANDLE_OFFSET, VECTOR_STROKE_ALIGN_LABELS, VECTOR_STROKE_GRADIENT_MODES, VECTOR_STROKE_GRADIENT_MODE_LABELS, VECTOR_STYLE_KEYS, VECTOR_TOOLS, VECTOR_TOOL_GLYPHS, VECTOR_TOOL_SHORTCUTS, VECTOR_TRANSFORM_HANDLES, VECTOR_WIDTH_PRESETS, VECTOR_WIDTH_PRESET_IDS, VECTOR_WIDTH_PROFILE_MAX_POINTS, VECTOR_WIDTH_PROFILE_MAX_SCALE, VECTOR_WIDTH_SAME_T, type VariableStrokeOptions, type Vec2, type VectorActionResult, type VectorAlign, type VectorAnchor, type VectorAnchorRef, type VectorAnchorType, type VectorAppearanceShape, type VectorArrange, type VectorArrowAlign, type VectorArrowhead, type VectorArrowheadShape, type VectorAverageAxis, type VectorBlend, type VectorBlendControls, type VectorBlendInput, type VectorBlendOptions, type VectorBlendRail, type VectorBlendSpacing, type VectorBlendStart, type VectorBooleanOperand, type VectorBooleanOperation, type VectorBounds, type VectorBuilderHit, type VectorBuilderLinePiece, type VectorBuilderPreview, type VectorBuilderReplacement, type VectorBuilderTouched, type VectorCommandOptions, type VectorCorner, type VectorCornerInfo, type VectorCornerKind, type VectorCornerWidget, type VectorDefaults, type VectorDistribute, type VectorDocument, VectorEditorController, type VectorEditorOptions, type VectorEditorState, type VectorEffect, type VectorEffectParamSpec, type VectorEffectParamsMap, type VectorEffectType, type VectorEffectsPanelData, type VectorEffectsPanelItem, type VectorFillRule, type VectorGradient, type VectorGradientAnnotator, type VectorGradientEditorData, type VectorGradientHandle, type VectorGradientInterpolation, type VectorGradientPart, type VectorGradientPatch, type VectorGradientPoints, type VectorGradientRamp, type VectorGradientSpread, type VectorGradientStop, type VectorGradientSvgOptions, type VectorGradientTarget, type VectorGradientType, type VectorGradientUnits, type VectorGroupNode, type VectorGuideKind, type VectorGuideLabel, type VectorGuideLine, type VectorHandleRef, type VectorHitTestOptions, type VectorHover, type VectorInkShape, type VectorInteraction, type VectorKeyInput, type VectorLineCap, type VectorLineJoin, type VectorMatrix, type VectorMergeMode, type VectorModifiers, type VectorMorph, type VectorMorphContour, type VectorMorphCorrespondence, type VectorMorphOptions, type VectorNode, type VectorNodeListing, type VectorOverlayRenderData, type VectorPaint, type VectorPaintDef, type VectorPaintSvgOptions, type VectorPathAction, type VectorPathEditOptions, type VectorPathEntry, type VectorPathKeyframe, type VectorPathNode, type VectorPathfinderAction, type VectorPathfinderOperation, type VectorPathfinderPaint, type VectorPointSnap, type VectorPointerInput, type VectorRectSnap, type VectorRenderAnchor, type VectorRenderCornerWidget, type VectorRenderGradientAnnotator, type VectorRenderGroup, type VectorRenderGuideLabel, type VectorRenderGuideLine, type VectorRenderHandle, type VectorRenderNode, type VectorRenderPath, type VectorRenderStrokeParts, type VectorRenderWidthPoint, type VectorRepeaterCopy, type VectorRgba, type VectorScaleSnap, type VectorSceneRenderData, type VectorSegmentRef, type VectorSelectionBoxGeometry, type VectorSelectionFrame, type VectorSelectionStyle, type VectorShapeBuilderFace, type VectorShapeBuilderMap, type VectorShapeBuilderPlan, type VectorShapeBuilderResult, type VectorShapeInput, type VectorSnapGuides, type VectorSnapKind, type VectorSnapLeave, type VectorSnapOptions, VectorSnapTargets, type VectorStrokeAlign, type VectorStrokeGradientMode, type VectorStrokeParts, type VectorStrokeSpot, type VectorStyle, type VectorSubpath, type VectorSvgExportOptions, type VectorSvgImportOptions, type VectorSvgPatternDef, type VectorTaperOptions, type VectorTool, type VectorTransformHandle, type VectorViewport, type VectorWaveOptions, type VectorWidthHandle, type VectorWidthPoint, type VectorWidthPointEdit, type VectorWidthPointRef, type VectorWidthPreset, type VectorWidthPresetInfo, activeVectorEffects, addBuilderHit, applyMatrix, applyMatrixLinear, applyVectorBlendOptions, applyVectorCornersAttribute, applyVectorEffects, applyVectorGradientPatch, applyVectorGradientSpread, arrowheadInset, arrowheadPath, arrowheadWeight, bendSegment, bezierToSubpaths, boundsFromPoints, boundsIntersect, clearVectorLiveBooleanCache, cloneAnchor, cloneSubpath, cloneVectorDocument, cloneVectorNode, collectPathNodes, constrainToLeave, convertAnchor, convertVectorGradient, cornerBisectorPoint, cornerRadiusChange, cornerSetback, correspondMorphContours, createVectorCommands, createVectorEffect, createVectorMorph, curvatureMoveAnchor, cutSubpathAt, dashIntervals, decomposeRigid, defaultVectorGradient, effectPathLength, effectPathVertexCount, effectiveStrokeAlign, ellipseSubpath, eraseFromFill, eraseFromOutline, eraserRegion, evaluateVectorPathKeyframes, expandVectorAppearance, expandVectorAppearances, expandVectorBlend, expandVectorCorners, expandVectorCornersOf, expandVectorGradientSpread, expandVectorGradientStops, explicitVectorGradient, findVectorNode, fitCornerRadius, foldVectorBooleanOperands, generateVectorBlendChildren, generateWidthProfile, getAnchor, getAnchorWorld, getEditablePathIds, getTransformHandlePositions, getVectorBlendControls, getVectorCornerWidgets, getVectorEffectsPanel, getVectorEnteredGroups, getVectorGradientAnnotator, getVectorGradientEditor, getVectorOverlayRenderData, getVectorSceneRenderData, getVectorSelectionBoxGeometry, getVectorSelectionFrame, getVectorSelectionStyle, getVectorWidthHandles, getVisibleAnchors, getVisibleHandles, gradientMidpointRemap, hasExplicitGradientGeometry, hasOwnVectorAppearance, hasPaint, hasStrokeExtras, hasVectorAppearance, hasVectorCorners, hitTestVectorNode, hitTestVectorNodes, hitTestVectorStroke, hitVectorGradientAnnotator, inferAnchorType, insertAnchor, insertVectorGradientStop, insertWidthPoint, interpolateMorphContours, interpolateRigidMatrix, interpolateVectorColor, interpolateVectorPaint, interpolateVectorPaths, interpolateVectorStyle, interpolateWidthProfiles, invertMatrix, isCentredVectorGradient, isClosedBezierShape, isIdentityMatrix, isUniformWidthProfile, isVectorBlendGroup, isVectorGradient, isVectorLiveBoolean, isVectorTextTarget, joinSubpaths, knifePath, lineSubpath, locateVectorNode, matrixRotation, mergePaths, mirrorWidthProfile, morphContourToSubpath, morphPathsCross, moveAnchorHandle, moveVectorGradientHandle, moveVectorGradientStop, multiplyMatrices, nearestSegment, nearestStrokePosition, nextVectorCornerKind, nodeMatrix, normalizeVectorEffectParams, offsetPaths, parseSvgTransform, parseVectorColor, parseVectorSvg, pathsCenter, patternAttrs, periodicVectorGradientStops, pinVectorGradient, planShapeBuilder, polygonSubpath, polylineBounds, pressureWidthProfile, puckerBloatPaths, recognizeInkShape, rectSubpath, refineMorphContour, refreshVectorBlends, releaseVectorBlend, removeAnchorKeepingShape, removeAnchors, removeAnchorsKeepingShape, removeRedundantPoints, removeVectorGradientStop, removeWidthPoints, repeatPaths, resampleGradientStops, resolveVectorBlendOptions, reverseMorphContour, reverseSubpath, reverseVectorGradient, reverseWidthProfile, rotateMatrix, roundCornerPaths, roundSubpaths, samplePlainStops, samplePolyline, sampleVectorGradient, sampleVectorGradientAt, sampleVectorPaintDefAt, sanitizeVectorEffects, sanitizeVectorGradient, sanitizeWidthProfile, scaleFor, scaleMatrix, setAnchorCorner, setSubpathCorners, setVectorGradientVector, setWidthPoint, simplifyPolyline, smoothSubpath, sortedVectorGradientStops, spanVectorGradientStops, splitIntoFaces, splitSubpathAt, starSubpath, strokePositionPoint, strokeWidthProfileOf, subpathEnclosesArea, subpathPointAt, subpathSegment, subpathSegmentCount, subpathToMorphContour, subpathsToBezier, taperWaveFactor, toVectorKeyInput, toVectorModifiers, toVectorPointerInput, transformVectorEffects, transformVectorGradient, transformVectorNode, transformVectorPaint, translateAnchor, translateMatrix, trimIntervals, trimPaths, trimPathsIndividually, turnMorphContour, twistPaths, unionBounds, variableStrokeOutline, variableStrokeRings, vectorAppearanceNodes, vectorAppearanceOutline, vectorAppearanceShapes, vectorBlendColorDistance, vectorBlendKeyTargets, vectorBlendKeys, vectorBlendRail, vectorBlendRailAt, vectorBlendSpine, vectorBlendStepCount, vectorBoxMatrix, vectorBuilderErasedEdges, vectorCornerAt, vectorCorners, vectorCornersAttribute, vectorDiamondPath, vectorDocumentToSvg, vectorEnteredGroups, vectorFillMap, vectorGradientArea, vectorGradientAspect, vectorGradientBarPosition, vectorGradientFocalParam, vectorGradientHandles, vectorGradientMatrix, vectorGradientMidpointFromPosition, vectorGradientMidpointPosition, vectorGradientNeedsExpansion, vectorGradientParam, vectorGradientPoints, vectorGradientRamp, vectorGradientSvgDefs, vectorGradientTAt, vectorGradientTargetPath, vectorGradientUnitsMatrix, vectorInkShapeName, vectorLiveBooleanSteps, vectorNodeBounds, vectorNodeRotation, vectorNodeToBezier, vectorOperandOperation, vectorPaintToHex, vectorPaintToSvg, vectorParentMatrix, vectorPathData, vectorPathEntries, vectorPathLocalBounds, vectorPathWorldBezier, vectorPathfinderShape, vectorRepeaterCopies, vectorResizeCursor, vectorResultStyle, vectorShapeBuilderHit, vectorShapeBuilderMap, vectorStrokeGradientDefs, vectorStrokeLineArea, vectorStrokeOutline, vectorStrokeOutlinePath, vectorStrokeParts, vectorStrokeReach, vectorStrokeSvgParts, vectorStrokeWidthGeometry, vectorToolLabel, vectorWorldMatrix, walkVectorNodes, widthProfileAt, widthProfileFromAttribute, widthProfileMaxScale, widthProfilePreset, widthProfilePresetId, widthProfileToAttribute, wigglePaths, zigzagPaths };
|