@pixerate/editor 0.254.0 → 0.255.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/index.cjs +2 -2
- package/dist/agent/index.js +1 -1
- package/dist/animation-editor/index.cjs +59 -59
- package/dist/animation-editor/index.js +3 -3
- package/dist/brushes/index.cjs +31 -29
- package/dist/brushes/index.d.cts +1 -1
- package/dist/brushes/index.d.ts +1 -1
- package/dist/brushes/index.js +27 -25
- package/dist/brushes/library.d.cts +17 -0
- package/dist/brushes/library.d.ts +17 -0
- package/dist/{brushstrokeRender-5PYSKZIJ.js → brushstrokeRender-HCOQUSWW.js} +53 -18
- package/dist/{brushstrokeRender-7FLLSQEC.cjs → brushstrokeRender-ZZOXI5O5.cjs} +55 -20
- package/dist/canvas/brushTypes.d.cts +22 -3
- package/dist/canvas/brushTypes.d.ts +22 -3
- package/dist/canvas/brushstroke.d.cts +34 -12
- package/dist/canvas/brushstroke.d.ts +34 -12
- package/dist/canvas/brushstrokeRender.d.cts +14 -8
- package/dist/canvas/brushstrokeRender.d.ts +14 -8
- package/dist/canvas/changeFeed.d.cts +6 -0
- package/dist/canvas/changeFeed.d.ts +6 -0
- package/dist/canvas/drawController.d.cts +11 -3
- package/dist/canvas/drawController.d.ts +11 -3
- package/dist/canvas/freehand.d.cts +6 -1
- package/dist/canvas/freehand.d.ts +6 -1
- package/dist/canvas/index.cjs +123 -104
- package/dist/canvas/index.js +25 -6
- package/dist/{chunk-XVIK73LS.js → chunk-5P4JEOIV.js} +4 -4
- package/dist/{chunk-JPEHXIB5.cjs → chunk-5YWWQ36H.cjs} +66 -21
- package/dist/{chunk-CHAWTXBE.cjs → chunk-6WCQ35GI.cjs} +4 -4
- package/dist/{chunk-GYMMNCFT.js → chunk-AF23QK5F.js} +56 -11
- package/dist/{chunk-JFHBXNR2.cjs → chunk-B7V34GIH.cjs} +86 -86
- package/dist/{chunk-QC3OXRE4.js → chunk-DMTEQ6SH.js} +1 -1
- package/dist/{chunk-TLOGFIIV.cjs → chunk-GCTUOTCW.cjs} +35 -35
- package/dist/{chunk-34KLWUH4.cjs → chunk-HIMGBZAM.cjs} +1133 -597
- package/dist/{chunk-7P6VF3FG.js → chunk-HYWRU5VX.js} +1 -1
- package/dist/{chunk-QPHNVZHO.js → chunk-JVRLGV3C.js} +1118 -582
- package/dist/{chunk-LFMKWGFL.cjs → chunk-LRNUZKWV.cjs} +22 -8
- package/dist/chunk-PGPFWC35.cjs +517 -0
- package/dist/{chunk-QLSGTCYT.cjs → chunk-TBAVCLEQ.cjs} +23 -23
- package/dist/{chunk-2ZJ4DT3M.js → chunk-VUKUTT2W.js} +1 -1
- package/dist/{chunk-5JNA6LLY.js → chunk-WYGSR3IJ.js} +22 -8
- package/dist/chunk-YHUMGBZD.js +517 -0
- package/dist/commands/builtins.d.cts +1 -1
- package/dist/commands/builtins.d.ts +1 -1
- package/dist/commands/index.cjs +2 -2
- package/dist/commands/index.js +1 -1
- package/dist/image-editor/brush-presets.d.cts +32 -0
- package/dist/image-editor/brush-presets.d.ts +32 -0
- package/dist/image-editor/controller.d.cts +15 -0
- package/dist/image-editor/controller.d.ts +15 -0
- package/dist/image-editor/index.cjs +848 -775
- package/dist/image-editor/index.d.cts +1 -0
- package/dist/image-editor/index.d.ts +1 -0
- package/dist/image-editor/index.js +81 -8
- package/dist/image-editor/types.d.cts +7 -0
- package/dist/image-editor/types.d.ts +7 -0
- package/dist/paint-editor/index.cjs +80 -80
- package/dist/paint-editor/index.js +13 -13
- package/dist/vector/brushstroke.d.cts +21 -5
- package/dist/vector/brushstroke.d.ts +21 -5
- package/dist/vector/controller.d.cts +14 -1
- package/dist/vector/controller.d.ts +14 -1
- package/dist/vector/index.cjs +1220 -1199
- package/dist/vector/index.js +34 -13
- package/dist/vector/types.d.cts +7 -0
- package/dist/vector/types.d.ts +7 -0
- package/package.json +1 -1
- package/skills/pixerate-brushes/SKILL.md +9 -3
- package/skills/pixerate-canvas/SKILL.md +10 -5
- package/skills/pixerate-image-editor/SKILL.md +2 -1
- package/skills/pixerate-vector/SKILL.md +1 -1
- package/dist/chunk-HS6QDWDF.cjs +0 -1029
- package/dist/chunk-MTKY6K3Q.js +0 -1029
|
@@ -8,8 +8,10 @@
|
|
|
8
8
|
import { brushstrokeScaleBucket } from '../paint/brushstroke-scale.js';
|
|
9
9
|
import { type PathShape, type ShapeDescription, type ShapeSize } from './shapeGeometry.js';
|
|
10
10
|
import type { Point } from './types.js';
|
|
11
|
-
import type { CanvasBrush, CanvasBrushPaint, CanvasBrushPreset, CanvasBrushstroke } from './brushTypes.js';
|
|
12
|
-
|
|
11
|
+
import type { CanvasBrush, CanvasBrushPaint, CanvasBrushPreset, CanvasBrushSpec, CanvasBrushstroke } from './brushTypes.js';
|
|
12
|
+
import type { BrushLibrary } from '../brushes/library.js';
|
|
13
|
+
import type { BrushPreviewRenderer } from '../brushes/tools.js';
|
|
14
|
+
export type { CanvasBrush, CanvasBrushPaint, CanvasBrushPaintMapping, CanvasBrushPaintStop, CanvasBrushPaper, CanvasBrushPreset, CanvasBrushSettings, CanvasBrushSpec, CanvasBrushstroke } from './brushTypes.js';
|
|
13
15
|
export { brushstrokeScaleBucket };
|
|
14
16
|
/** A brushed stroke's image, placed in the path's coordinates (the shape's view box). */
|
|
15
17
|
export interface CanvasBrushstrokeImage {
|
|
@@ -40,9 +42,12 @@ export declare function pathDataToPolyline(d: string, step?: number): Point[];
|
|
|
40
42
|
export declare function profileAlongPolyline(points: readonly Point[], values: readonly number[], count?: number): number[];
|
|
41
43
|
/** The renderer chunk (`./brushstrokeRender.ts`). */
|
|
42
44
|
export interface CanvasBrushstrokeRenderer {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
/** The presets, then the saved brushes given (facet brushes) the canvas profile admits. */
|
|
46
|
+
listCanvasBrushes(user?: readonly unknown[]): CanvasBrushPreset[];
|
|
47
|
+
/** Throws for an unknown brush or one the canvas profile refuses; the result is the paint engine's brush. */
|
|
48
|
+
resolveCanvasBrush(brush: CanvasBrush, width: number | undefined, spec?: unknown): unknown;
|
|
49
|
+
/** A saved brush checked against the canvas profile (throws with the reason and fix). */
|
|
50
|
+
readCanvasBrushSpec(spec: unknown): unknown;
|
|
46
51
|
/** Throws for paint that is not a colour or gradient paint a canvas stroke can use; the result is the paint engine's `PaintSource`. */
|
|
47
52
|
resolveCanvasPaint(paint: unknown): unknown;
|
|
48
53
|
renderShapeBrushstrokeNow(shape: BrushedPathShape, scale: number, place?: {
|
|
@@ -52,7 +57,7 @@ export interface CanvasBrushstrokeRenderer {
|
|
|
52
57
|
};
|
|
53
58
|
unit?: number;
|
|
54
59
|
}): CanvasBrushstrokeImage | null;
|
|
55
|
-
brushSwatchNow(brush: CanvasBrush, options: CanvasBrushSwatchOptions): string;
|
|
60
|
+
brushSwatchNow(brush: CanvasBrush, options: CanvasBrushSwatchOptions, spec?: CanvasBrushSpec): string;
|
|
56
61
|
brushedShapeSvgNow(shape: BrushedPathShape, size: ShapeSize, scale: number, place?: {
|
|
57
62
|
origin?: {
|
|
58
63
|
x: number;
|
|
@@ -66,13 +71,24 @@ export interface CanvasBrushstrokeRenderer {
|
|
|
66
71
|
* colour parser). Called for you by the functions below; call it early to warm up.
|
|
67
72
|
*/
|
|
68
73
|
export declare function loadCanvasBrushstrokeRenderer(): Promise<CanvasBrushstrokeRenderer>;
|
|
69
|
-
/** The dry paint presets a freehand stroke can use (wet, mixer, blender, smudge and eraser presets are left out). */
|
|
70
|
-
export declare function listCanvasBrushes(): Promise<CanvasBrushPreset[]>;
|
|
71
74
|
/**
|
|
72
|
-
*
|
|
73
|
-
*
|
|
75
|
+
* The brushes a freehand stroke can use: the presets `CANVAS_PROFILE` admits (dry dab brushes; wet,
|
|
76
|
+
* mixer, blender, smudge, eraser and light presets are left out), then the saved brushes of
|
|
77
|
+
* `library` it admits.
|
|
74
78
|
*/
|
|
75
|
-
export declare function
|
|
79
|
+
export declare function listCanvasBrushes(library?: Pick<BrushLibrary, 'list'>): Promise<CanvasBrushPreset[]>;
|
|
80
|
+
/**
|
|
81
|
+
* The saved brush a stroke should embed for `brush`: the library's brush when `brush` names a saved
|
|
82
|
+
* one (checked against the canvas profile), else undefined (a preset or tip settings). Throws
|
|
83
|
+
* saying why a saved brush can't brush a stroke.
|
|
84
|
+
*/
|
|
85
|
+
export declare function resolveCanvasBrushSpec(brush: CanvasBrush, library?: Pick<BrushLibrary, 'get' | 'isBuiltin'>): Promise<CanvasBrushSpec | undefined>;
|
|
86
|
+
/**
|
|
87
|
+
* Checks a brush: an unknown id, a brush the canvas profile refuses (wet, a tool, light…), or
|
|
88
|
+
* settings that are not an object throw an error saying why and which brushes can be used.
|
|
89
|
+
* `spec` is the saved brush `brush` names (`resolveCanvasBrushSpec`).
|
|
90
|
+
*/
|
|
91
|
+
export declare function validateCanvasBrush(brush: CanvasBrush, spec?: CanvasBrushSpec): Promise<void>;
|
|
76
92
|
/**
|
|
77
93
|
* Checks a brushed stroke's `paint` (a colour or gradient paint): bad stops, an unknown mapping,
|
|
78
94
|
* or a mapping that needs timed samples (`velocity`, `time`) throw an error saying what to use.
|
|
@@ -119,4 +135,10 @@ export interface CanvasBrushSwatchOptions {
|
|
|
119
135
|
* and grain), its size capped to fit, as a PNG data URL ('' when nothing renders). Throws for an
|
|
120
136
|
* unknown or non-dry brush.
|
|
121
137
|
*/
|
|
122
|
-
export declare function renderCanvasBrushSwatch(brush: CanvasBrush, options?: CanvasBrushSwatchOptions): Promise<string>;
|
|
138
|
+
export declare function renderCanvasBrushSwatch(brush: CanvasBrush, options?: CanvasBrushSwatchOptions, spec?: CanvasBrushSpec): Promise<string>;
|
|
139
|
+
/**
|
|
140
|
+
* `preview_brush` for brushed strokes (canvas and vector): the brush library tools' renderer
|
|
141
|
+
* (`createBrushLibraryToolProvider(library, { profile: CANVAS_PROFILE, renderPreview: renderCanvasBrushPreview })`),
|
|
142
|
+
* a swatch of the brush as a canvas stroke paints it. Loads the renderer on first use.
|
|
143
|
+
*/
|
|
144
|
+
export declare const renderCanvasBrushPreview: BrushPreviewRenderer;
|
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The lazily loaded half of brushed freehand strokes (`./brushstroke.ts` imports it on first use):
|
|
3
|
-
* the paint engine's dry brushstroke renderer, the
|
|
4
|
-
* every import of the paint engine in this file, so the canvas
|
|
3
|
+
* the paint engine's dry brushstroke renderer, the brush presets and host profile, and a CSS
|
|
4
|
+
* colour parser. Keep every import of the paint engine and the presets in this file, so the canvas
|
|
5
|
+
* entry never reaches them statically.
|
|
5
6
|
*/
|
|
6
7
|
import { type BrushstrokeBrush } from '../paint/brushstroke.cjs';
|
|
7
8
|
import { type PaintSource } from '../paint/gradient-paint.cjs';
|
|
9
|
+
import type { Brush } from '../brushes/types.cjs';
|
|
8
10
|
import { type ShapeSize } from './shapeGeometry.cjs';
|
|
9
|
-
import { type BrushedPathShape, type CanvasBrushSwatchOptions, type CanvasBrush, type CanvasBrushPaint, type CanvasBrushPreset, type CanvasBrushstrokeImage } from './brushstroke.cjs';
|
|
10
|
-
|
|
11
|
+
import { type BrushedPathShape, type CanvasBrushSwatchOptions, type CanvasBrush, type CanvasBrushPaint, type CanvasBrushPreset, type CanvasBrushSpec, type CanvasBrushstrokeImage } from './brushstroke.cjs';
|
|
12
|
+
/** A saved brush, normalised and checked against the canvas profile; throws saying why it can't brush a stroke. */
|
|
13
|
+
export declare function readCanvasBrushSpec(spec: CanvasBrushSpec | unknown): Brush;
|
|
14
|
+
/** The presets, then the saved brushes (`user`, facet brushes) the canvas can paint. */
|
|
15
|
+
export declare function listCanvasBrushes(user?: readonly unknown[]): CanvasBrushPreset[];
|
|
11
16
|
/**
|
|
12
|
-
* The paint engine brush for a canvas brush at diameter `width` (undefined: the
|
|
13
|
-
* or the settings' `size`, else 3)
|
|
17
|
+
* The paint engine brush for a canvas brush at diameter `width` (undefined: the brush's own size,
|
|
18
|
+
* or the settings' `size`, else 3). `spec` is the saved brush a stroke embeds when `brush` names
|
|
19
|
+
* one. Throws with the reason and the usable ids.
|
|
14
20
|
*/
|
|
15
|
-
export declare function resolveCanvasBrush(brush: CanvasBrush, width: number | undefined): BrushstrokeBrush;
|
|
21
|
+
export declare function resolveCanvasBrush(brush: CanvasBrush, width: number | undefined, spec?: CanvasBrushSpec | unknown): BrushstrokeBrush;
|
|
16
22
|
/**
|
|
17
23
|
* The paint engine's `PaintSource` for a brushed stroke's `paint`; throws with what is wrong.
|
|
18
24
|
* Mappings that need timed samples (`velocity`, `time`) are refused: canvas strokes carry no timing.
|
|
@@ -32,4 +38,4 @@ export declare function brushedShapeSvgNow(shape: BrushedPathShape, size: ShapeS
|
|
|
32
38
|
};
|
|
33
39
|
unit?: number;
|
|
34
40
|
}): string;
|
|
35
|
-
export declare function brushSwatchNow(brush: CanvasBrush, options: CanvasBrushSwatchOptions): string;
|
|
41
|
+
export declare function brushSwatchNow(brush: CanvasBrush, options: CanvasBrushSwatchOptions, spec?: CanvasBrushSpec): string;
|
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The lazily loaded half of brushed freehand strokes (`./brushstroke.ts` imports it on first use):
|
|
3
|
-
* the paint engine's dry brushstroke renderer, the
|
|
4
|
-
* every import of the paint engine in this file, so the canvas
|
|
3
|
+
* the paint engine's dry brushstroke renderer, the brush presets and host profile, and a CSS
|
|
4
|
+
* colour parser. Keep every import of the paint engine and the presets in this file, so the canvas
|
|
5
|
+
* entry never reaches them statically.
|
|
5
6
|
*/
|
|
6
7
|
import { type BrushstrokeBrush } from '../paint/brushstroke.js';
|
|
7
8
|
import { type PaintSource } from '../paint/gradient-paint.js';
|
|
9
|
+
import type { Brush } from '../brushes/types.js';
|
|
8
10
|
import { type ShapeSize } from './shapeGeometry.js';
|
|
9
|
-
import { type BrushedPathShape, type CanvasBrushSwatchOptions, type CanvasBrush, type CanvasBrushPaint, type CanvasBrushPreset, type CanvasBrushstrokeImage } from './brushstroke.js';
|
|
10
|
-
|
|
11
|
+
import { type BrushedPathShape, type CanvasBrushSwatchOptions, type CanvasBrush, type CanvasBrushPaint, type CanvasBrushPreset, type CanvasBrushSpec, type CanvasBrushstrokeImage } from './brushstroke.js';
|
|
12
|
+
/** A saved brush, normalised and checked against the canvas profile; throws saying why it can't brush a stroke. */
|
|
13
|
+
export declare function readCanvasBrushSpec(spec: CanvasBrushSpec | unknown): Brush;
|
|
14
|
+
/** The presets, then the saved brushes (`user`, facet brushes) the canvas can paint. */
|
|
15
|
+
export declare function listCanvasBrushes(user?: readonly unknown[]): CanvasBrushPreset[];
|
|
11
16
|
/**
|
|
12
|
-
* The paint engine brush for a canvas brush at diameter `width` (undefined: the
|
|
13
|
-
* or the settings' `size`, else 3)
|
|
17
|
+
* The paint engine brush for a canvas brush at diameter `width` (undefined: the brush's own size,
|
|
18
|
+
* or the settings' `size`, else 3). `spec` is the saved brush a stroke embeds when `brush` names
|
|
19
|
+
* one. Throws with the reason and the usable ids.
|
|
14
20
|
*/
|
|
15
|
-
export declare function resolveCanvasBrush(brush: CanvasBrush, width: number | undefined): BrushstrokeBrush;
|
|
21
|
+
export declare function resolveCanvasBrush(brush: CanvasBrush, width: number | undefined, spec?: CanvasBrushSpec | unknown): BrushstrokeBrush;
|
|
16
22
|
/**
|
|
17
23
|
* The paint engine's `PaintSource` for a brushed stroke's `paint`; throws with what is wrong.
|
|
18
24
|
* Mappings that need timed samples (`velocity`, `time`) are refused: canvas strokes carry no timing.
|
|
@@ -32,4 +38,4 @@ export declare function brushedShapeSvgNow(shape: BrushedPathShape, size: ShapeS
|
|
|
32
38
|
};
|
|
33
39
|
unit?: number;
|
|
34
40
|
}): string;
|
|
35
|
-
export declare function brushSwatchNow(brush: CanvasBrush, options: CanvasBrushSwatchOptions): string;
|
|
41
|
+
export declare function brushSwatchNow(brush: CanvasBrush, options: CanvasBrushSwatchOptions, spec?: CanvasBrushSpec): string;
|
|
@@ -39,6 +39,12 @@ export interface CanvasChange<TNode extends CanvasNode = CanvasNode, TEdge exten
|
|
|
39
39
|
};
|
|
40
40
|
/** A node is being dragged or resized: more changes of the same gesture will follow. */
|
|
41
41
|
inGesture: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* The drag or resize that earlier changes reported (`inGesture`) has ended. Set on the first
|
|
44
|
+
* change after it, which the feed reports even when nothing else changed: a drop often only
|
|
45
|
+
* clears the runtime `dragging` flag, and followers need to know the gesture is over.
|
|
46
|
+
*/
|
|
47
|
+
gestureEnded?: true;
|
|
42
48
|
/** Milliseconds since the epoch. */
|
|
43
49
|
at: number;
|
|
44
50
|
}
|
|
@@ -39,6 +39,12 @@ export interface CanvasChange<TNode extends CanvasNode = CanvasNode, TEdge exten
|
|
|
39
39
|
};
|
|
40
40
|
/** A node is being dragged or resized: more changes of the same gesture will follow. */
|
|
41
41
|
inGesture: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* The drag or resize that earlier changes reported (`inGesture`) has ended. Set on the first
|
|
44
|
+
* change after it, which the feed reports even when nothing else changed: a drop often only
|
|
45
|
+
* clears the runtime `dragging` flag, and followers need to know the gesture is over.
|
|
46
|
+
*/
|
|
47
|
+
gestureEnded?: true;
|
|
42
48
|
/** Milliseconds since the epoch. */
|
|
43
49
|
at: number;
|
|
44
50
|
}
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
import type { ArrangeHistoryTarget } from './arrangeController.cjs';
|
|
6
6
|
import type { CanvasNode, Point } from './types.cjs';
|
|
7
7
|
import { type FreehandDrawOptions, type FreehandPenSample, type FreehandStroke, type FreehandStrokeStyle, type FreehandTool } from './freehand.cjs';
|
|
8
|
-
import {
|
|
8
|
+
import { type CanvasBrush } from './brushstroke.cjs';
|
|
9
|
+
import type { BrushLibrary } from '../brushes/library.cjs';
|
|
9
10
|
/** A stroke drawn by code or an agent (`drawStroke`). */
|
|
10
11
|
export interface DrawStrokeInput {
|
|
11
12
|
/** Points in canvas (flow) coordinates, at least one. */
|
|
@@ -36,6 +37,11 @@ export interface DrawStrokeResult<TNode extends CanvasNode = CanvasNode> {
|
|
|
36
37
|
brush?: unknown;
|
|
37
38
|
}
|
|
38
39
|
export interface CanvasDrawControllerOptions<TNode extends CanvasNode = CanvasNode> {
|
|
40
|
+
/**
|
|
41
|
+
* The brush library whose saved brushes strokes may use besides the presets (the canvas
|
|
42
|
+
* profile decides which). Share one with the paint editor so a brush saved there draws here.
|
|
43
|
+
*/
|
|
44
|
+
brushLibrary?: Pick<BrushLibrary, 'list' | 'get' | 'isBuiltin'>;
|
|
39
45
|
getNodes: () => TNode[];
|
|
40
46
|
setNodes: (nodes: TNode[]) => void;
|
|
41
47
|
history?: ArrangeHistoryTarget;
|
|
@@ -68,8 +74,10 @@ export declare function createCanvasDrawController<TNode extends CanvasNode = Ca
|
|
|
68
74
|
width: number;
|
|
69
75
|
height: number;
|
|
70
76
|
} | undefined;
|
|
71
|
-
/** The
|
|
72
|
-
listBrushes:
|
|
77
|
+
/** The presets and saved brushes (of `brushLibrary`) a stroke can be brushed with (loads the paint engine). */
|
|
78
|
+
listBrushes: () => Promise<import("./brushTypes.cjs").CanvasBrushPreset[]>;
|
|
79
|
+
/** The saved brush to embed for a brush id (undefined for presets and tip settings); for a brush picker. */
|
|
80
|
+
brushSpec: (brush: CanvasBrush) => Promise<import("./brushTypes.cjs").CanvasBrushSpec | undefined>;
|
|
73
81
|
};
|
|
74
82
|
export type CanvasDrawController = ReturnType<typeof createCanvasDrawController>;
|
|
75
83
|
/** Modifier options when computing bounds while dragging/drawing. */
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
import type { ArrangeHistoryTarget } from './arrangeController.js';
|
|
6
6
|
import type { CanvasNode, Point } from './types.js';
|
|
7
7
|
import { type FreehandDrawOptions, type FreehandPenSample, type FreehandStroke, type FreehandStrokeStyle, type FreehandTool } from './freehand.js';
|
|
8
|
-
import {
|
|
8
|
+
import { type CanvasBrush } from './brushstroke.js';
|
|
9
|
+
import type { BrushLibrary } from '../brushes/library.js';
|
|
9
10
|
/** A stroke drawn by code or an agent (`drawStroke`). */
|
|
10
11
|
export interface DrawStrokeInput {
|
|
11
12
|
/** Points in canvas (flow) coordinates, at least one. */
|
|
@@ -36,6 +37,11 @@ export interface DrawStrokeResult<TNode extends CanvasNode = CanvasNode> {
|
|
|
36
37
|
brush?: unknown;
|
|
37
38
|
}
|
|
38
39
|
export interface CanvasDrawControllerOptions<TNode extends CanvasNode = CanvasNode> {
|
|
40
|
+
/**
|
|
41
|
+
* The brush library whose saved brushes strokes may use besides the presets (the canvas
|
|
42
|
+
* profile decides which). Share one with the paint editor so a brush saved there draws here.
|
|
43
|
+
*/
|
|
44
|
+
brushLibrary?: Pick<BrushLibrary, 'list' | 'get' | 'isBuiltin'>;
|
|
39
45
|
getNodes: () => TNode[];
|
|
40
46
|
setNodes: (nodes: TNode[]) => void;
|
|
41
47
|
history?: ArrangeHistoryTarget;
|
|
@@ -68,8 +74,10 @@ export declare function createCanvasDrawController<TNode extends CanvasNode = Ca
|
|
|
68
74
|
width: number;
|
|
69
75
|
height: number;
|
|
70
76
|
} | undefined;
|
|
71
|
-
/** The
|
|
72
|
-
listBrushes:
|
|
77
|
+
/** The presets and saved brushes (of `brushLibrary`) a stroke can be brushed with (loads the paint engine). */
|
|
78
|
+
listBrushes: () => Promise<import("./brushTypes.js").CanvasBrushPreset[]>;
|
|
79
|
+
/** The saved brush to embed for a brush id (undefined for presets and tip settings); for a brush picker. */
|
|
80
|
+
brushSpec: (brush: CanvasBrush) => Promise<import("./brushTypes.js").CanvasBrushSpec | undefined>;
|
|
73
81
|
};
|
|
74
82
|
export type CanvasDrawController = ReturnType<typeof createCanvasDrawController>;
|
|
75
83
|
/** Modifier options when computing bounds while dragging/drawing. */
|
|
@@ -6,7 +6,7 @@ import type { CanvasNode, Point, Rect } from './types.cjs';
|
|
|
6
6
|
import { type FitPathDataOptions } from './curveFit.cjs';
|
|
7
7
|
export type FreehandTool = 'select' | 'pen' | 'highlighter' | 'eraser';
|
|
8
8
|
import type { CanvasGradientDef } from './gradient.cjs';
|
|
9
|
-
import type { CanvasBrush, CanvasBrushPaint, CanvasBrushstroke } from './brushTypes.cjs';
|
|
9
|
+
import type { CanvasBrush, CanvasBrushPaint, CanvasBrushSpec, CanvasBrushstroke } from './brushTypes.cjs';
|
|
10
10
|
export interface FreehandStrokeStyle {
|
|
11
11
|
/** Stroke color (any CSS color string) or gradient definition. */
|
|
12
12
|
color: string | CanvasGradientDef;
|
|
@@ -36,6 +36,11 @@ export interface FreehandStrokeStyle {
|
|
|
36
36
|
* along the path; `color` still gives the alpha and fills `paint` stops. Only with `brush`.
|
|
37
37
|
*/
|
|
38
38
|
paint?: CanvasBrushPaint;
|
|
39
|
+
/**
|
|
40
|
+
* The saved brush `brush` names, when it is one from a brush library rather than a preset:
|
|
41
|
+
* strokes embed it so they render without the library. A brush picker sets it with `brush`.
|
|
42
|
+
*/
|
|
43
|
+
brushSpec?: CanvasBrushSpec;
|
|
39
44
|
}
|
|
40
45
|
/** Pen data for one freehand point (Pointer Events: pressure 0..1, tilt in degrees). */
|
|
41
46
|
export interface FreehandPenSample {
|
|
@@ -6,7 +6,7 @@ import type { CanvasNode, Point, Rect } from './types.js';
|
|
|
6
6
|
import { type FitPathDataOptions } from './curveFit.js';
|
|
7
7
|
export type FreehandTool = 'select' | 'pen' | 'highlighter' | 'eraser';
|
|
8
8
|
import type { CanvasGradientDef } from './gradient.js';
|
|
9
|
-
import type { CanvasBrush, CanvasBrushPaint, CanvasBrushstroke } from './brushTypes.js';
|
|
9
|
+
import type { CanvasBrush, CanvasBrushPaint, CanvasBrushSpec, CanvasBrushstroke } from './brushTypes.js';
|
|
10
10
|
export interface FreehandStrokeStyle {
|
|
11
11
|
/** Stroke color (any CSS color string) or gradient definition. */
|
|
12
12
|
color: string | CanvasGradientDef;
|
|
@@ -36,6 +36,11 @@ export interface FreehandStrokeStyle {
|
|
|
36
36
|
* along the path; `color` still gives the alpha and fills `paint` stops. Only with `brush`.
|
|
37
37
|
*/
|
|
38
38
|
paint?: CanvasBrushPaint;
|
|
39
|
+
/**
|
|
40
|
+
* The saved brush `brush` names, when it is one from a brush library rather than a preset:
|
|
41
|
+
* strokes embed it so they render without the library. A brush picker sets it with `brush`.
|
|
42
|
+
*/
|
|
43
|
+
brushSpec?: CanvasBrushSpec;
|
|
39
44
|
}
|
|
40
45
|
/** Pen data for one freehand point (Pointer Events: pressure 0..1, tilt in degrees). */
|
|
41
46
|
export interface FreehandPenSample {
|