@pixerate/editor 0.280.0 → 0.282.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/dist/animation-editor/index.cjs +59 -59
  2. package/dist/animation-editor/index.js +3 -3
  3. package/dist/brushes/index.cjs +76 -71
  4. package/dist/brushes/index.js +13 -8
  5. package/dist/brushes/schema.d.cts +1 -0
  6. package/dist/brushes/schema.d.ts +1 -0
  7. package/dist/brushes/types.d.cts +29 -3
  8. package/dist/brushes/types.d.ts +29 -3
  9. package/dist/{brushstrokeRender-EIK3625T.js → brushstrokeRender-4MA5CBW3.js} +3 -3
  10. package/dist/{brushstrokeRender-7HOMKZNO.cjs → brushstrokeRender-JVKVKWDA.cjs} +15 -15
  11. package/dist/canvas/edge-animation-tools.d.cts +115 -0
  12. package/dist/canvas/edge-animation-tools.d.ts +115 -0
  13. package/dist/canvas/edgeAnimation.d.cts +164 -0
  14. package/dist/canvas/edgeAnimation.d.ts +164 -0
  15. package/dist/canvas/edgePaths.d.cts +63 -0
  16. package/dist/canvas/edgePaths.d.ts +63 -0
  17. package/dist/canvas/index.cjs +691 -21
  18. package/dist/canvas/index.d.cts +3 -0
  19. package/dist/canvas/index.d.ts +3 -0
  20. package/dist/canvas/index.js +679 -9
  21. package/dist/{chunk-NJDEKU5D.js → chunk-2YGYYVSG.js} +1 -1
  22. package/dist/{chunk-JVFGK3DK.cjs → chunk-3JUKN3RM.cjs} +76 -53
  23. package/dist/{chunk-HN57I7KT.js → chunk-CG3FBNXE.js} +1 -1
  24. package/dist/{chunk-WFSYZO5Z.cjs → chunk-DFZ4I7EZ.cjs} +1 -1
  25. package/dist/{chunk-LZE2QZCT.js → chunk-IHMMHZGP.js} +1 -1
  26. package/dist/{chunk-K4ANWBF7.cjs → chunk-IJQ2YH2M.cjs} +35 -35
  27. package/dist/{chunk-HRUK5TFW.cjs → chunk-IUKPQCYQ.cjs} +164 -71
  28. package/dist/{chunk-WCC4NXWY.cjs → chunk-JD63B33V.cjs} +86 -86
  29. package/dist/{chunk-NJLPW4MM.js → chunk-KV7QHPKL.js} +27 -4
  30. package/dist/{chunk-H3EME3S5.cjs → chunk-MRIAR5DY.cjs} +2 -2
  31. package/dist/{chunk-ROURHJYT.js → chunk-NEDS6DSC.js} +1 -1
  32. package/dist/{chunk-FKO3CY2C.js → chunk-ULPXJ3NB.js} +1 -1
  33. package/dist/{chunk-WZYRYYXN.cjs → chunk-UOM5S4W5.cjs} +12 -12
  34. package/dist/{chunk-YOM76H2V.js → chunk-VEX6YVNG.js} +1 -1
  35. package/dist/{chunk-MNHP3AQT.cjs → chunk-WEXWDBUF.cjs} +23 -23
  36. package/dist/{chunk-PPDUCZZV.js → chunk-YRGTQLDN.js} +122 -29
  37. package/dist/image-editor/index.cjs +788 -788
  38. package/dist/image-editor/index.js +4 -4
  39. package/dist/paint-editor/antimatter.d.cts +154 -0
  40. package/dist/paint-editor/antimatter.d.ts +154 -0
  41. package/dist/paint-editor/brush-controls.d.cts +1 -0
  42. package/dist/paint-editor/brush-controls.d.ts +1 -0
  43. package/dist/paint-editor/brush-model.d.cts +9 -5
  44. package/dist/paint-editor/brush-model.d.ts +9 -5
  45. package/dist/paint-editor/controller.d.cts +23 -0
  46. package/dist/paint-editor/controller.d.ts +23 -0
  47. package/dist/paint-editor/index.cjs +1931 -891
  48. package/dist/paint-editor/index.d.cts +1 -0
  49. package/dist/paint-editor/index.d.ts +1 -0
  50. package/dist/paint-editor/index.js +1098 -58
  51. package/dist/paint-editor/mark-settings.d.cts +30 -0
  52. package/dist/paint-editor/mark-settings.d.ts +30 -0
  53. package/dist/paint-editor/stroke.d.cts +16 -0
  54. package/dist/paint-editor/stroke.d.ts +16 -0
  55. package/dist/paint-editor/strokes.d.cts +2 -0
  56. package/dist/paint-editor/strokes.d.ts +2 -0
  57. package/dist/paint-editor/ui.d.cts +4 -2
  58. package/dist/paint-editor/ui.d.ts +4 -2
  59. package/dist/vector/index.cjs +999 -999
  60. package/dist/vector/index.js +4 -4
  61. package/package.json +1 -1
  62. package/skills/pixerate-brushes/SKILL.md +1 -1
  63. package/skills/pixerate-canvas/SKILL.md +25 -2
  64. package/skills/pixerate-paint-editor/SKILL.md +8 -2
  65. package/skills/pixerate-paint-editor/references/antimatter.md +49 -0
  66. package/skills/pixerate-paint-editor/references/brush-facets.md +1 -0
@@ -0,0 +1,164 @@
1
+ /**
2
+ * Animated canvas edges: dots travelling along an edge, marching dashes, beams of light and a
3
+ * pulsing glow. An edge's animation is data (`edge.data.animation`, a {@link CanvasEdgeAnimation}),
4
+ * so it saves, undoes and copies with the edge. {@link getCanvasEdgeAnimationRender} turns it into a
5
+ * framework-neutral list of SVG elements with SMIL timing, which `<AnimatedEdge>` /
6
+ * `<EdgeAnimation>` (React and Svelte) render; {@link sampleCanvasEdgeAnimation} gives the same
7
+ * picture at a moment in time without a browser (thumbnails, exports, tests, reduced motion).
8
+ */
9
+ import type { CanvasConnectionLineType } from './connectors.js';
10
+ import { type MeasuredSvgPath, type SvgPathPoint } from './edgePaths.js';
11
+ /** What travels along the edge. */
12
+ export type CanvasEdgeAnimationKind = 'dots' | 'dash' | 'beam' | 'pulse';
13
+ /** Which way the animation runs: source → target, target → source, or back and forth. */
14
+ export type CanvasEdgeAnimationDirection = 'forward' | 'reverse' | 'alternate';
15
+ /** An edge's animation, stored at `edge.data.animation`. Every field but `kind` is optional. */
16
+ export interface CanvasEdgeAnimation {
17
+ kind: CanvasEdgeAnimationKind;
18
+ /** Travel speed in canvas units per second (`dots`, `dash`, `beam`). Defaults per kind. */
19
+ speed?: number;
20
+ /** Length of one cycle in ms; overrides `speed` (and is the only timing for `pulse`). */
21
+ duration?: number;
22
+ /** Default `forward` (source → target). */
23
+ direction?: CanvasEdgeAnimationDirection;
24
+ /** CSS colour. Default: the edge's stroke. */
25
+ color?: string;
26
+ /** Dot radius, or the stroke width of dashes, beams and the pulse, in canvas units. Defaults per kind. */
27
+ size?: number;
28
+ /** Number of dots or beams on the edge at once. Defaults per kind. */
29
+ count?: number;
30
+ /** Dash or beam length, in canvas units. Defaults per kind. */
31
+ length?: number;
32
+ /** Gap between dashes, in canvas units (`dash`). Default 6. */
33
+ gap?: number;
34
+ /** Glow radius (a blur behind the moving part), in canvas units. 0 is none. Defaults per kind. */
35
+ glow?: number;
36
+ /** Opacity of the edge's own stroke under the animation, 0–1. Default 1. */
37
+ trackOpacity?: number;
38
+ /** Held still at its first frame. Default false. */
39
+ paused?: boolean;
40
+ }
41
+ export interface CanvasEdgeAnimationKindInfo {
42
+ kind: CanvasEdgeAnimationKind;
43
+ title: string;
44
+ description: string;
45
+ /** The values used for fields an animation leaves out. */
46
+ defaults: Required<Omit<CanvasEdgeAnimation, 'kind' | 'color' | 'duration' | 'paused'>> & {
47
+ duration?: number;
48
+ };
49
+ }
50
+ /** The animation kinds, with what they look like and their defaults. */
51
+ export declare const CANVAS_EDGE_ANIMATION_KINDS: readonly CanvasEdgeAnimationKindInfo[];
52
+ /**
53
+ * Checks an animation and returns a clean copy (unknown fields dropped). Throws an error that says
54
+ * which field is wrong and what it accepts.
55
+ */
56
+ export declare function normalizeCanvasEdgeAnimation(input: unknown): CanvasEdgeAnimation;
57
+ /** The edge's animation, or null when it has none or it is not valid. */
58
+ export declare function getCanvasEdgeAnimation(edge: {
59
+ data?: Record<string, any>;
60
+ } | null | undefined): CanvasEdgeAnimation | null;
61
+ /** A copy of the edge with its animation set (checked first), or removed when `animation` is null. */
62
+ export declare function setCanvasEdgeAnimation<TEdge extends {
63
+ data?: Record<string, any>;
64
+ }>(edge: TEdge, animation: CanvasEdgeAnimation | null): TEdge;
65
+ /** The animation with every default filled in, as it will play. */
66
+ export declare function resolveCanvasEdgeAnimation(animation: CanvasEdgeAnimation): Required<Omit<CanvasEdgeAnimation, 'color' | 'duration'>> & Pick<CanvasEdgeAnimation, 'color' | 'duration'>;
67
+ /** SMIL timing for an element: rendered as `<animate>` / `<animateMotion>` children. */
68
+ export interface CanvasEdgeAnimationTiming {
69
+ /** Seconds per cycle (SMIL `dur`). */
70
+ dur: number;
71
+ /** Start offset in seconds; negative starts part-way through (SMIL `begin`). */
72
+ begin: number;
73
+ }
74
+ /** One SVG element of an animated edge. Coordinates are canvas units. */
75
+ export type CanvasEdgeAnimationElement = {
76
+ type: 'dot';
77
+ key: string;
78
+ r: number;
79
+ fill: string;
80
+ filter?: string;
81
+ /** Where the dot is at the first frame (used when paused or with reduced motion). */
82
+ at: SvgPathPoint;
83
+ /** Travel along the path: `keyPoints` / `keyTimes` for `<animateMotion>`. */
84
+ motion: CanvasEdgeAnimationTiming & {
85
+ keyPoints: string;
86
+ keyTimes: string;
87
+ };
88
+ } | {
89
+ type: 'stroke';
90
+ key: string;
91
+ stroke: string;
92
+ strokeWidth: number;
93
+ strokeLinecap: 'round' | 'butt';
94
+ strokeDasharray?: string;
95
+ strokeDashoffset?: number;
96
+ opacity?: number;
97
+ filter?: string;
98
+ /** `<animate>`s to add: attribute, values (`;`-separated, SMIL), timing. */
99
+ animate: Array<CanvasEdgeAnimationTiming & {
100
+ attributeName: 'stroke-dashoffset' | 'stroke-opacity' | 'stroke-width';
101
+ values: string;
102
+ }>;
103
+ };
104
+ export interface CanvasEdgeAnimationRender {
105
+ kind: CanvasEdgeAnimationKind;
106
+ /** Path length in canvas units. */
107
+ length: number;
108
+ /** Opacity for the edge's own stroke. */
109
+ trackOpacity: number;
110
+ /** Whether the elements should move (false when paused, reduced motion or a zero-length path). */
111
+ moving: boolean;
112
+ /**
113
+ * A blur filter to define in `<defs>` when anything glows. Its region is in user space (canvas
114
+ * units, `filterUnits="userSpaceOnUse"`): a straight edge has a zero-height box, and a filter
115
+ * sized to the box would hide it.
116
+ */
117
+ glowFilter?: {
118
+ id: string;
119
+ stdDeviation: number;
120
+ x: number;
121
+ y: number;
122
+ width: number;
123
+ height: number;
124
+ };
125
+ elements: CanvasEdgeAnimationElement[];
126
+ }
127
+ export interface CanvasEdgeAnimationRenderOptions {
128
+ /** SVG path data of the edge (`getCanvasEdgePath(...).path` or the path your edge draws). */
129
+ path: string;
130
+ /** A unique id for this edge's defs (the edge id). */
131
+ id: string;
132
+ /** Colour used when the animation has none (the edge's stroke). Default `currentColor`. */
133
+ stroke?: string;
134
+ /** Draw the first frame without movement (honour `prefers-reduced-motion`). Default false. */
135
+ reducedMotion?: boolean;
136
+ /** A measured path to reuse, when you already have one for `path`. */
137
+ measured?: MeasuredSvgPath;
138
+ }
139
+ /**
140
+ * How to draw an animated edge: SVG elements and SMIL timing, computed from the path. Dots use
141
+ * `<animateMotion>` along the path, dashes and beams animate `stroke-dashoffset`, the pulse animates
142
+ * opacity and width. Nothing here needs a DOM; the React and Svelte `<EdgeAnimation>` render it.
143
+ */
144
+ export declare function getCanvasEdgeAnimationRender(animation: CanvasEdgeAnimation, options: CanvasEdgeAnimationRenderOptions): CanvasEdgeAnimationRender;
145
+ /** The animated part of an edge at one moment. */
146
+ export interface CanvasEdgeAnimationFrame {
147
+ kind: CanvasEdgeAnimationKind;
148
+ length: number;
149
+ /** Dot positions (`dots`). */
150
+ dots: SvgPathPoint[];
151
+ /** Visible stretches of the path as [from, to] distances (`dash`, `beam`), clipped to the path. */
152
+ segments: Array<[number, number]>;
153
+ /** Stroke opacity and width (`pulse`). */
154
+ opacity: number;
155
+ strokeWidth: number;
156
+ }
157
+ /**
158
+ * Where everything is `timeMs` into the animation: the same picture the SVG shows at that time,
159
+ * computed without a browser (for thumbnails, exports, canvas renderers and tests). A paused
160
+ * animation always returns its first frame.
161
+ */
162
+ export declare function sampleCanvasEdgeAnimation(animation: CanvasEdgeAnimation, path: string | MeasuredSvgPath, timeMs: number): CanvasEdgeAnimationFrame;
163
+ /** Edge path styles `<AnimatedEdge>` can draw (read from `edge.data.pathType`). */
164
+ export type CanvasAnimatedEdgePathType = CanvasConnectionLineType;
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Edge path geometry for canvas edges, matching xyflow's (`getBezierPath`, `getStraightPath`,
3
+ * `getSimpleBezierPath`, `getSmoothStepPath`) so the same path is drawn with or without React Flow /
4
+ * Svelte Flow, plus a small SVG path measurer (`measureSvgPath`) for placing things along a path.
5
+ * No DOM and no xyflow import.
6
+ */
7
+ import type { CanvasConnectionLineType } from './connectors.cjs';
8
+ import type { Position } from './types.cjs';
9
+ export interface CanvasEdgePathParams {
10
+ sourceX: number;
11
+ sourceY: number;
12
+ targetX: number;
13
+ targetY: number;
14
+ /** Side of the source node the edge leaves from. Default `bottom`. */
15
+ sourcePosition?: Position;
16
+ /** Side of the target node the edge enters. Default `top`. */
17
+ targetPosition?: Position;
18
+ /** Path style, as xyflow's edge `type`. Default `default` (bézier). */
19
+ type?: CanvasConnectionLineType;
20
+ /** Bézier curvature (`default`). Default 0.25. */
21
+ curvature?: number;
22
+ /** Corner radius for `smoothstep`, in canvas units. Default 5 (`step` is 0). */
23
+ borderRadius?: number;
24
+ /** Distance the step paths run straight out of a handle before turning, in canvas units. Default 20. */
25
+ offset?: number;
26
+ }
27
+ export interface CanvasEdgePath {
28
+ /** SVG path data. */
29
+ path: string;
30
+ /** Where a label sits (xyflow's `labelX` / `labelY`). */
31
+ labelX: number;
32
+ labelY: number;
33
+ }
34
+ /**
35
+ * The SVG path of a canvas edge, the same as xyflow draws for that edge `type` (`default` bézier,
36
+ * `straight`, `step`, `smoothstep`, `simplebezier`), with the label position.
37
+ */
38
+ export declare function getCanvasEdgePath(params: CanvasEdgePathParams): CanvasEdgePath;
39
+ /** A point on a path with the direction of travel there (radians, 0 = +x). */
40
+ export interface SvgPathPoint {
41
+ x: number;
42
+ y: number;
43
+ angle: number;
44
+ }
45
+ export interface MeasuredSvgPath {
46
+ /** Total length in path units. */
47
+ length: number;
48
+ /** Bounding box of the flattened path. */
49
+ bounds: {
50
+ x: number;
51
+ y: number;
52
+ width: number;
53
+ height: number;
54
+ };
55
+ /** The point `distance` along the path (clamped to [0, length]). */
56
+ pointAt(distance: number): SvgPathPoint;
57
+ }
58
+ /**
59
+ * Measures SVG path data (M, L, H, V, C, S, Q, T, Z, absolute or relative; arcs are drawn as
60
+ * straight lines). Curves are flattened to `segments` pieces each (default 24), which is well under
61
+ * a canvas unit of error for edge-sized curves.
62
+ */
63
+ export declare function measureSvgPath(d: string, segments?: number): MeasuredSvgPath;
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Edge path geometry for canvas edges, matching xyflow's (`getBezierPath`, `getStraightPath`,
3
+ * `getSimpleBezierPath`, `getSmoothStepPath`) so the same path is drawn with or without React Flow /
4
+ * Svelte Flow, plus a small SVG path measurer (`measureSvgPath`) for placing things along a path.
5
+ * No DOM and no xyflow import.
6
+ */
7
+ import type { CanvasConnectionLineType } from './connectors.js';
8
+ import type { Position } from './types.js';
9
+ export interface CanvasEdgePathParams {
10
+ sourceX: number;
11
+ sourceY: number;
12
+ targetX: number;
13
+ targetY: number;
14
+ /** Side of the source node the edge leaves from. Default `bottom`. */
15
+ sourcePosition?: Position;
16
+ /** Side of the target node the edge enters. Default `top`. */
17
+ targetPosition?: Position;
18
+ /** Path style, as xyflow's edge `type`. Default `default` (bézier). */
19
+ type?: CanvasConnectionLineType;
20
+ /** Bézier curvature (`default`). Default 0.25. */
21
+ curvature?: number;
22
+ /** Corner radius for `smoothstep`, in canvas units. Default 5 (`step` is 0). */
23
+ borderRadius?: number;
24
+ /** Distance the step paths run straight out of a handle before turning, in canvas units. Default 20. */
25
+ offset?: number;
26
+ }
27
+ export interface CanvasEdgePath {
28
+ /** SVG path data. */
29
+ path: string;
30
+ /** Where a label sits (xyflow's `labelX` / `labelY`). */
31
+ labelX: number;
32
+ labelY: number;
33
+ }
34
+ /**
35
+ * The SVG path of a canvas edge, the same as xyflow draws for that edge `type` (`default` bézier,
36
+ * `straight`, `step`, `smoothstep`, `simplebezier`), with the label position.
37
+ */
38
+ export declare function getCanvasEdgePath(params: CanvasEdgePathParams): CanvasEdgePath;
39
+ /** A point on a path with the direction of travel there (radians, 0 = +x). */
40
+ export interface SvgPathPoint {
41
+ x: number;
42
+ y: number;
43
+ angle: number;
44
+ }
45
+ export interface MeasuredSvgPath {
46
+ /** Total length in path units. */
47
+ length: number;
48
+ /** Bounding box of the flattened path. */
49
+ bounds: {
50
+ x: number;
51
+ y: number;
52
+ width: number;
53
+ height: number;
54
+ };
55
+ /** The point `distance` along the path (clamped to [0, length]). */
56
+ pointAt(distance: number): SvgPathPoint;
57
+ }
58
+ /**
59
+ * Measures SVG path data (M, L, H, V, C, S, Q, T, Z, absolute or relative; arcs are drawn as
60
+ * straight lines). Curves are flattened to `segments` pieces each (default 24), which is well under
61
+ * a canvas unit of error for edge-sized curves.
62
+ */
63
+ export declare function measureSvgPath(d: string, segments?: number): MeasuredSvgPath;