@pixerate/editor 0.29.0 → 0.31.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/animation/index.cjs +6 -2
- package/dist/animation/index.cjs.map +1 -1
- package/dist/animation/index.d.cts +2 -2
- package/dist/animation/index.d.ts +2 -2
- package/dist/animation/index.js +17 -13
- package/dist/canvas/index.cjs +618 -33
- package/dist/canvas/index.cjs.map +1 -1
- package/dist/canvas/index.d.cts +193 -9
- package/dist/canvas/index.d.ts +193 -9
- package/dist/canvas/index.js +603 -18
- package/dist/canvas/index.js.map +1 -1
- package/dist/chunk-UB2OY7FD.js +262 -0
- package/dist/chunk-UB2OY7FD.js.map +1 -0
- package/dist/{chunk-PWJARCI4.js → chunk-W7BOBWZD.js} +5 -196
- package/dist/chunk-W7BOBWZD.js.map +1 -0
- package/dist/{chunk-TTYCN6ZH.cjs → chunk-XHRZSB77.cjs} +8 -199
- package/dist/chunk-XHRZSB77.cjs.map +1 -0
- package/dist/chunk-XZ4L3R4K.cjs +262 -0
- package/dist/chunk-XZ4L3R4K.cjs.map +1 -0
- package/dist/{easing-B6iAnJHk.d.cts → easing-DTmX99QG.d.cts} +20 -6
- package/dist/{easing-B6iAnJHk.d.ts → easing-DTmX99QG.d.ts} +20 -6
- package/dist/parameters/index.cjs +38 -1
- package/dist/parameters/index.cjs.map +1 -1
- package/dist/parameters/index.d.cts +32 -2
- package/dist/parameters/index.d.ts +32 -2
- package/dist/parameters/index.js +37 -0
- package/dist/parameters/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-PWJARCI4.js.map +0 -1
- package/dist/chunk-TTYCN6ZH.cjs.map +0 -1
package/dist/canvas/index.d.cts
CHANGED
|
@@ -4,8 +4,8 @@ import { Clock, AnimationValueType, AnimationValue, AnimationTrack, AnimationLoo
|
|
|
4
4
|
export { ANIMATION_TIME_EPSILON, AnimationKeyframe, AnimationPlayerOptions, ManualClock, OklabColor, createAnimationPlayer, evaluateTrack, formatOklab, interpolateAnimationValue, isAnimationKeyframe, mixColorsOklab, normalizeKeyframes, oklabToRgb, pageHidden, parseOklab, realClock, rgbToOklab, wrapAnimationTime } from '../animation/index.cjs';
|
|
5
5
|
import { C as Command, M as MergedExecutionOptions } from '../types-DsiXGmjo.cjs';
|
|
6
6
|
import { d as TokenModeContext, r as TokenType, o as TokenScope, f as TokenLiteral, c as TokenVariable, e as TokenResolution, T as TokenState } from '../model-C1zApQM8.cjs';
|
|
7
|
-
import { A as AnimationEasing } from '../easing-
|
|
8
|
-
export { a as ANIMATION_EASING_LABELS, b as ANIMATION_EASING_PRESETS, c as AnimationEasingPreset, C as CUBIC_BEZIER_PRESETS, d as CubicBezierEasing, S as SpringEasing, e as cubicBezierAt, f as easingFromInfluence, g as easingLabel, h as easingToCss, i as
|
|
7
|
+
import { A as AnimationEasing } from '../easing-DTmX99QG.cjs';
|
|
8
|
+
export { a as ANIMATION_EASING_LABELS, b as ANIMATION_EASING_PRESETS, c as AnimationEasingPreset, C as CUBIC_BEZIER_PRESETS, d as CubicBezierEasing, E as ElasticEasing, S as SpringEasing, e as cubicBezierAt, f as easingFromInfluence, g as easingLabel, h as easingToCss, i as elasticAt, j as evaluateEasing, k as isAnimationEasing, p as parseCssEasing, r as resolveEasing, s as springAt } from '../easing-DTmX99QG.cjs';
|
|
9
9
|
|
|
10
10
|
declare const DEFAULT_NODE_WIDTH = 200;
|
|
11
11
|
declare const DEFAULT_NODE_HEIGHT = 60;
|
|
@@ -664,17 +664,85 @@ declare const xorPolygons: (a: PolygonInput, b: PolygonInput, options?: PolygonB
|
|
|
664
664
|
*/
|
|
665
665
|
declare function dividePolygons(operands: PolygonInput[], options?: PolygonBooleanOptions): PolygonPiece[];
|
|
666
666
|
|
|
667
|
+
/**
|
|
668
|
+
* Canvas gradient models, parsing, presets, and SVG defs generation.
|
|
669
|
+
* Supports linear and radial gradients for shape fills, strokes, and freehand drawing.
|
|
670
|
+
*/
|
|
671
|
+
interface GradientStop {
|
|
672
|
+
offset: number;
|
|
673
|
+
color: string;
|
|
674
|
+
opacity?: number;
|
|
675
|
+
}
|
|
676
|
+
interface CanvasLinearGradient {
|
|
677
|
+
type: 'linear';
|
|
678
|
+
angle?: number;
|
|
679
|
+
stops: GradientStop[];
|
|
680
|
+
}
|
|
681
|
+
interface CanvasRadialGradient {
|
|
682
|
+
type: 'radial';
|
|
683
|
+
cx?: number;
|
|
684
|
+
cy?: number;
|
|
685
|
+
r?: number;
|
|
686
|
+
stops: GradientStop[];
|
|
687
|
+
}
|
|
688
|
+
type CanvasGradientDef = CanvasLinearGradient | CanvasRadialGradient;
|
|
689
|
+
interface SvgGradientStop {
|
|
690
|
+
offset: string;
|
|
691
|
+
stopColor: string;
|
|
692
|
+
stopOpacity?: number;
|
|
693
|
+
}
|
|
694
|
+
interface SvgGradientDef {
|
|
695
|
+
id: string;
|
|
696
|
+
type: 'linear' | 'radial';
|
|
697
|
+
attrs: Record<string, string | number>;
|
|
698
|
+
stops: SvgGradientStop[];
|
|
699
|
+
}
|
|
700
|
+
declare const CANVAS_GRADIENT_PRESETS: Record<string, CanvasLinearGradient>;
|
|
701
|
+
/** Whether an arbitrary value matches a CanvasGradientDef object. */
|
|
702
|
+
declare function isCanvasGradient(value: unknown): value is CanvasGradientDef;
|
|
703
|
+
/**
|
|
704
|
+
* Parses CSS linear-gradient or radial-gradient strings into CanvasGradientDef.
|
|
705
|
+
* Supports forms like:
|
|
706
|
+
* - linear-gradient(90deg, #ff0000 0%, #0000ff 100%)
|
|
707
|
+
* - linear-gradient(to right, red, blue)
|
|
708
|
+
* - radial-gradient(circle, red 0%, blue 100%)
|
|
709
|
+
*/
|
|
710
|
+
declare function parseCssGradient(css: string): CanvasGradientDef | null;
|
|
711
|
+
/**
|
|
712
|
+
* Resolves a paint value (which could be a CSS color, preset name, CSS gradient string, or CanvasGradientDef)
|
|
713
|
+
* into either a CanvasGradientDef (if gradient) or null (if solid color or invalid).
|
|
714
|
+
*/
|
|
715
|
+
declare function resolveCanvasGradient(value: unknown): CanvasGradientDef | null;
|
|
716
|
+
/**
|
|
717
|
+
* Converts degrees clockwise (CSS angle: 0 = top, 90 = right, 180 = bottom, 270 = left)
|
|
718
|
+
* to SVG linearGradient vector coordinates (x1, y1, x2, y2) normalized [0, 1].
|
|
719
|
+
*/
|
|
720
|
+
declare function angleToSvgLinearCoords(angleDeg?: number): {
|
|
721
|
+
x1: number;
|
|
722
|
+
y1: number;
|
|
723
|
+
x2: number;
|
|
724
|
+
y2: number;
|
|
725
|
+
};
|
|
726
|
+
/**
|
|
727
|
+
* Converts a CanvasGradientDef to an SvgGradientDef descriptor ready for rendering `<linearGradient>` / `<radialGradient>`.
|
|
728
|
+
*/
|
|
729
|
+
declare function gradientToSvgDef(gradient: CanvasGradientDef, id: string): SvgGradientDef;
|
|
730
|
+
|
|
667
731
|
/**
|
|
668
732
|
* Shape geometry: shape descriptions (rect, rounded rect, ellipse, regular polygon, star and
|
|
669
733
|
* SVG path data) to polygons, SVG path parsing / flattening, and polygons back to path data.
|
|
670
734
|
*/
|
|
671
735
|
|
|
672
|
-
/** Paint shared by every shape kind. Colours are any CSS colour. */
|
|
736
|
+
/** Paint shared by every shape kind. Colours are any CSS colour, preset name, or gradient definition. */
|
|
673
737
|
interface ShapePaint {
|
|
674
|
-
fill?: string;
|
|
675
|
-
stroke?: string;
|
|
738
|
+
fill?: string | CanvasGradientDef;
|
|
739
|
+
stroke?: string | CanvasGradientDef;
|
|
676
740
|
strokeWidth?: number;
|
|
677
741
|
opacity?: number;
|
|
742
|
+
strokeLinecap?: 'round' | 'butt' | 'square';
|
|
743
|
+
strokeLinejoin?: 'round' | 'bevel' | 'miter';
|
|
744
|
+
fillGradient?: CanvasGradientDef;
|
|
745
|
+
strokeGradient?: CanvasGradientDef;
|
|
678
746
|
}
|
|
679
747
|
interface ShapeBase extends ShapePaint {
|
|
680
748
|
/** Clockwise rotation in degrees (on a y-down canvas) about the centre of the node box. */
|
|
@@ -804,13 +872,23 @@ interface ShapeRenderData {
|
|
|
804
872
|
stroke: string;
|
|
805
873
|
strokeWidth: number;
|
|
806
874
|
opacity?: number;
|
|
875
|
+
strokeLinecap?: 'round' | 'butt' | 'square';
|
|
876
|
+
strokeLinejoin?: 'round' | 'bevel' | 'miter';
|
|
877
|
+
/** Gradient def for the fill, when fill uses a gradient. */
|
|
878
|
+
fillGradient?: SvgGradientDef;
|
|
879
|
+
/** Gradient def for the stroke, when stroke uses a gradient. */
|
|
880
|
+
strokeGradient?: SvgGradientDef;
|
|
881
|
+
}
|
|
882
|
+
interface GetShapeRenderDataOptions {
|
|
883
|
+
/** Unique ID suffix or base ID used when generating SVG gradient IDs (default: auto random). */
|
|
884
|
+
id?: string;
|
|
807
885
|
}
|
|
808
886
|
/**
|
|
809
887
|
* Resolves the SVG drawing of a shape for a node size. Without a size, a path's view box
|
|
810
888
|
* size (or 100x100) is used. Paint defaults: `fill: currentColor`, `stroke: none`,
|
|
811
|
-
* `strokeWidth: 1`.
|
|
889
|
+
* `strokeWidth: 1`. Supports solid colors, CSS gradients, presets, and CanvasGradientDef.
|
|
812
890
|
*/
|
|
813
|
-
declare function getShapeRenderData(shape: ShapeDescription, size?: Partial<ShapeSize
|
|
891
|
+
declare function getShapeRenderData(shape: ShapeDescription, size?: Partial<ShapeSize>, options?: GetShapeRenderDataOptions): ShapeRenderData;
|
|
814
892
|
/**
|
|
815
893
|
* Converts a shape to rings in node-local pixels (rotation applied), flattening curves at
|
|
816
894
|
* `tolerance`. Returns the rings with the fill rule they must be read with.
|
|
@@ -1429,7 +1507,7 @@ interface OutlineShapeStrokesOptions extends ShapePathEditBaseOptions {
|
|
|
1429
1507
|
*/
|
|
1430
1508
|
keepFill?: boolean;
|
|
1431
1509
|
}
|
|
1432
|
-
/** Whether a shape draws a stroke (a stroke colour other than `none` and a positive width). */
|
|
1510
|
+
/** Whether a shape draws a stroke (a stroke colour or gradient other than `none` and a positive width). */
|
|
1433
1511
|
declare function hasVisibleStroke(shape: ShapeDescription | null): boolean;
|
|
1434
1512
|
/** Checks whether `offsetShapeNodes` can run (it cannot predict an `empty` result). */
|
|
1435
1513
|
declare function canOffsetShapeNodes(nodes: CanvasNode[], ids: Iterable<string>): {
|
|
@@ -3310,4 +3388,110 @@ declare const CANVAS_COMPONENT_DRAG_TYPE = "application/x-pixerate-component";
|
|
|
3310
3388
|
/** Reads the component id a components panel put on a drag (or `undefined`). */
|
|
3311
3389
|
declare function getCanvasComponentDragId(dataTransfer: Pick<DataTransfer, 'getData'> | null | undefined): string | undefined;
|
|
3312
3390
|
|
|
3313
|
-
export { ANIMATABLE_PROPERTIES, ANIMATION_DATA_KEY, AUTO_LAYOUT_DATA_KEY, type AddCanvasVariantOptions, type AffineMatrix, AlignEdge, AlignNodesOptions, type AnimatableProperty, type AnimateNodeOptions, type AnimationDocument, AnimationEasing, AnimationEditError, type AnimationEditErrorCode, type AnimationFrame, type AnimationHistoryTarget, type AnimationKeyframeClipboard, AnimationLoopMode, type AnimationMotionPath, type AnimationOverrides, AnimationPlayer, AnimationPlayerState, type AnimationPropertyOptions, type AnimationStop, AnimationTrack, AnimationValue, AnimationValueType, type ArrangeHistoryTarget, type AutoLayout, type AutoLayoutAlignContent, type AutoLayoutAlignCross, type AutoLayoutAlignMain, type AutoLayoutCellAlign, type AutoLayoutChild, type AutoLayoutConstraints, type AutoLayoutGrid, type AutoLayoutGridArea, type AutoLayoutGridCell, type AutoLayoutGridGeometry, type AutoLayoutGridTrack, type AutoLayoutHorizontalConstraint, type AutoLayoutInsertTarget, type AutoLayoutMeasure, type AutoLayoutMode, type AutoLayoutOptions, type AutoLayoutPadding, type AutoLayoutSize, type AutoLayoutSizing, type AutoLayoutSizingPair, type AutoLayoutVerticalConstraint, type BezierCommand, type BezierContour, type BezierPath, type BezierPathInput, type BezierPathToSvgOptions, type BezierSegment, CANVAS_COMPONENT_DRAG_TYPE, CANVAS_TOKEN_PROPERTIES, CHILD_LAYOUT_DATA_KEY, COMPONENT_DATA_KEY, COMPONENT_OVERRIDES_DATA_KEY, COMPONENT_PROPERTY_REFS_DATA_KEY, COMPONENT_SET_DATA_KEY, COMPONENT_SOURCE_DATA_KEY, CONNECTION_LINE_TYPES, CSS_ANIMATION_PROPERTIES, type CanvasAnimationController, type CanvasAnimationControllerOptions, type CanvasAnimationState, CanvasArrangeAction, type CanvasArrangeController, type CanvasArrangeControllerOptions, type CanvasAutoLayoutController, type CanvasAutoLayoutControllerOptions, CanvasClipboardPayload, type CanvasComponentData, type CanvasComponentErrorCode, type CanvasComponentInfo, type CanvasComponentPropertyDef, type CanvasComponentPropertyField, type CanvasComponentPropertyType, type CanvasComponentPropertyValue, type CanvasComponentResult, type CanvasComponentSetData, type CanvasComponentSetInfo, type CanvasComponentSyncOptions, type CanvasComponentsController, type CanvasComponentsControllerOptions, type CanvasConnectionLineType, CanvasEdge, type CanvasHeightOptions, type CanvasInstanceData, type CanvasInstanceInfo, type CanvasInstancePropertyInfo, CanvasLayoutOptions, CanvasNode, CanvasNodeStyle, CanvasNodeUpdate, type CanvasScene, type CanvasScenesOptions, type CanvasScenesState, CanvasScenesStore, type CanvasTokenBindingInfo, type CanvasTokenOptions, type CanvasTokenProperty, type CanvasViewport, Clock, type CombineShapeNodesOptions, type CombineShapeNodesRefusal, type CombineShapeNodesResult, type ConnectorSnap, type ConnectorSnapOptions, type ConnectorSnapTarget, type CreateCanvasComponentOptions, type CreateCanvasInstanceOptions, type CssAnimationExport, type CssExportOptions, type CssPropertyAnimation, type CubicSegment, DEFAULT_NODE_HEIGHT, DEFAULT_NODE_WIDTH, DEFAULT_PLACEMENT_GAP, type DashedPath, DirectionalDisplacementOptions, DistributeAxis, DistributeMode, DistributeNodesOptions, type DividePathsResult, type EllipseShape, type EvaluateAnimationOptions, FanOutTrajectoryOptions, type FitCubicsOptions, type FitPathDataOptions, type FitViewportOptions, type FlattenOptions, type GuideIndex, type GuideLine, INSTANCE_DATA_KEY, IncrementalLayoutOptions, type KeyframeDragState, type KeyframePatch, type KeyframeRangeOptions, type KeyframeRef, type KeyframeSnap, MAX_KEYFRAME_REFS, MatchSizeOptions, type MeasureGuide, type MeasureSelectionOptions, type MeasureSelectionResult, type MoveKeyframesResult, type MultiNodeTransitionOptions, type MultiPolygon, type NodeAnimation, NodeRectOptions, NodeTransition, type OffsetPathOptions, type OffsetShapeNodesOptions, type OutlineShapeStrokesOptions, type OutlineStrokeOptions, type PathBooleanOperation, type PathBooleanResult, type PathCommand, type PathOperand, type PathOperandInput, PathOpsError, type PathOpsOptions, type PathOpsReport, type PathPiece, type PathPointAtLength, type PathShape, PlaceBesideOptions, Point, type PolygonBooleanOperation, type PolygonBooleanOptions, type PolygonFillRule, type PolygonInput, type PolygonOperand, type PolygonPiece, type PolygonRing, type PolygonToPathOptions, type PolygonWithHoles, Position, type PositionChangeLike, RESIZE_HANDLES, type RecordAnimationOptions, Rect, type RectShape, ReflowDisplacementOptions, type RegularPolygonShape, type ResizeHandle, SHAPE_DATA_KEY, SHAPE_KINDS, SHAPE_NODE_TYPE, SHAPE_OPERATIONS, type SampleAnimationOptions, type ScaleKeyframesOptions, type SerializedCanvasScenes, type SetCanvasVariantPropertiesOptions, type SetKeyframeOptions, type ShapeDescription, type ShapeKind, type ShapeNodePolygonOptions, type ShapeOperation, type ShapePaint, type ShapePathEditOperation, type ShapePathEditRefusal, type ShapePathEditResult, type ShapeRenderData, type ShapeSize, Side, SizeDimension, type SnapGuidesOptions, type SnapNodeDragOptions, type SnapNodeDragResult, type SnapNodeResizeOptions, type SnapNodeResizeResult, type SnapResizeOptions, type SnapResizeResult, type SnapResult, type StarShape, StreamingLayoutManager, type StreamingLayoutManagerOptions, type StrokeCap, type StrokeJoin, TOKEN_BINDINGS_DATA_KEY, TOKEN_MODES_DATA_KEY, type TimelineKeyframe, type TimelineRow, type TimelineRowsOptions, TrajectoryFunction, type WebAnimationSpec, XYPosition, ZOrderOperation, addCanvasVariant, addKeyframesAtTime, animateNode, applyAnimation, applyAnimationOverrides, applyConstraints, applyShapeCombination, applyShapeReplacement, arcToCubics, bezierPathArea, bezierPathBounds, bezierPathLength, bezierPathPointAtLength, bezierPathSignedArea, bezierPathToSvg, bindCanvasComponentProperty, bindCanvasToken, blendLayout, boundsOf, calculateDagreReflowDisplacement, calculateDirectionalDisplacement, canCombineShapeNodes, canOffsetShapeNodes, canOutlineShapeNodeStrokes, canvasHeight, centerNodes, centre, clampAnimationValue, clampLayoutSize, closeContour, collectDescendantIds, combineCanvasComponentsAsVariants, combineShapeNodes, computeNodesBoundingBox, computeSnapGuides, connectedOnly, contourSignedArea, contoursToPath, copyKeyframes, countPathSegments, createBezierTrajectory, createCanvasAnimationController, createCanvasArrangeController, createCanvasAutoLayoutController, createCanvasComponent, createCanvasComponentsController, createCanvasInstance, createCanvasScenesStore, createFanOutTrajectory, createGuideIndex, createNodeGuideIndex, cubicPointAt, cubicsToPathData, dashContours, defaultEasing, deleteKeyframes, detachCanvasInstance, detachTokenBindings, diffOverrideGroups, distanceToBezierPath, dividePaths, dividePolygons, ensureLayout, estimateCanvasHeight, estimateNodeSize, evaluateAnimation, excludePaths, exportCssAnimation, findConnectorSnap, findVariant, fitCubicRun, fitCubics, fitFreehandPath, fitPathData, fitViewportToNodes, fitViewportToRect, flattenSvgPath, flowSide, formatAnimationTime, formatNumber, formatVariantName, getAnimatableProperty, getAnimatedProperties, getAnimatedValue, getAnimationDuration, getAnimationTrack, getAutoLayout, getAutoLayoutGrid, getAutoLayoutInsertTarget, getBindableTokenProperties, getCanvasComponentDragId, getCanvasTokenProperty, getCenteredNodePosition, getChildLayout, getComponentData, getComponentInstances, getComponentPropertyDefs, getComponentPropertyRefs, getComponentSourceId, getCssPropertyAnimations, getDefaultVariant, getEffectiveTokenModes, getFlowChildren, getInstanceData, getInstanceProperties, getInstanceStatus, getKeyframeTimes, getLayerName, getLayoutParent, getLayoutSizing, getLayoutedNodes, getNextVariantValues, getNodeAnimation, getNodeOverrides, getNodeShape, getNodeTokenBindings, getNodeTokenModes, getOwningComponent, getOwningInstance, getResizingNodeRect, getRootInstance, getShapeRenderData, getShapeSvg, getTimelineRows, getTimelineTicks, getTokenPropertyScope, getTokensForProperty, getVariantConflicts, getVariantOptions, getVariantSet, getVariantValues, handlePoint, hasVisibleStroke, inferResizeHandle, inspectCanvasInstance, inspectNodeTokens, intersectPaths, intersectPolygons, isAutoLayoutFrame, isCanvasComponent, isCanvasComponentSet, isCanvasInstance, isCssExportExact, isEventFromTextInput, isInsideInstance, isKeyframeSelected, isMeasureModifierHeld, isNodeAnimated, isShapeDescription, isShapeNode, isStraightCubic, isValidCanvasEdge, isValidCanvasNode, isValidCanvasScene, isValidUrl, layoutAll, layoutBounds, layoutFrame, layoutUp, layoutUpMany, linearPositionTrajectory, linearTrajectory, listCanvasComponents, makeSizingCoherent, measureBetween, measureLabel, measureSelection, measureToLine, mergeNodeUpdates, moveKeyframes, moveLayoutChild, multiPolygonArea, multiPolygonBounds, nearestHandlePositions, normalizeBezierPath, offsetPath, offsetShapeNodes, oppositePosition, outlineShapeNodeStrokes, outlineStroke, overlaps, parseCanvasClipboardData, parseCanvasScenes, parseKeyframeClipboard, parseNodeStyleDeclarations, parseSvgPath, parseVariantName, pasteKeyframes, pathBoolean, pathToContours, placeBeside, playWebAnimations, pointInBezierPath, pointInMultiPolygon, pointInRings, polygonArea, polygonBoolean, polygonToSvgPath, positionToSide, pruneCanvasTokenModes, pushCanvasInstanceOverrides, readAnimatableValue, readNodeStyleProperty, readOverrideGroup, recordAnimationChanges, relayoutUpdates, remapPastedNodes, removeCanvasVariant, removeTrack, renameCanvasVariantProperty, renameCanvasVariantValue, repositionNodesTo, resetCanvasInstanceOverrides, resizeHandleAxes, resolveCanvasTokens, resolvePadding, restoreCanvasMainComponent, revertShapeCombination, ringSignedArea, runMultiNodeTransition, sampleAnimationFrames, scaleKeyframes, segmentBounds, segmentCurvature, segmentDerivative, segmentExtrema, segmentLength, segmentNearest, segmentParamAtLength, segmentPoint, segmentTangent, serializeCanvasNodes, setCanvasComponentProperty, setCanvasInstanceProperties, setCanvasTokenMode, setCanvasVariantProperties, setKeyframe, setKeyframeEasing, setMotionPath, setTrackEnabled, shapeNodeToBezierPath, shapeNodeToPolygon, shapeToBezierPath, shapeToPolygon, sideToPosition, simplifyRing, snapKeyframeDelta, snapNodeDrag, snapNodeResize, snapResize, snapTimeToFrame, snapToGrid, splitSegment, strokeOutlineRings, subSegment, subtractPaths, subtractPolygons, swapCanvasInstance, syncAllCanvasInstances, syncCanvasComponents, syncCanvasInstance, timeToX, toBezierPath, toWebAnimations, transformBezierPath, trimSegments, unionPolygons, unitePaths, updateKeyframe, windingNumber, withNodeAnimation, withStyleOpacity, wouldCreateComponentCycle, writeNodeStyleProperty, writeOverrideGroup, xToTime, xorPolygons };
|
|
3391
|
+
/**
|
|
3392
|
+
* Freehand drawing utilities: stroke smoothing, cubic Bézier conversion,
|
|
3393
|
+
* ShapeNode generation, and spatial eraser hit-testing within the xyflow framework.
|
|
3394
|
+
*/
|
|
3395
|
+
|
|
3396
|
+
type FreehandTool = 'select' | 'pen' | 'highlighter' | 'eraser';
|
|
3397
|
+
|
|
3398
|
+
interface FreehandStrokeStyle {
|
|
3399
|
+
/** Stroke color (any CSS color string) or gradient definition. */
|
|
3400
|
+
color: string | CanvasGradientDef;
|
|
3401
|
+
/** Stroke width in flow canvas units. */
|
|
3402
|
+
width: number;
|
|
3403
|
+
/** Stroke opacity (0 to 1). */
|
|
3404
|
+
opacity: number;
|
|
3405
|
+
/** SVG stroke-linecap: 'round', 'butt', or 'square'. */
|
|
3406
|
+
cap?: 'round' | 'butt' | 'square';
|
|
3407
|
+
/** SVG stroke-linejoin: 'round', 'bevel', or 'miter'. */
|
|
3408
|
+
join?: 'round' | 'bevel' | 'miter';
|
|
3409
|
+
/** Optional gradient definition for the stroke. */
|
|
3410
|
+
gradient?: CanvasGradientDef;
|
|
3411
|
+
}
|
|
3412
|
+
interface FreehandDrawOptions {
|
|
3413
|
+
/** Cubic curve fitting tolerance (default: 1.0). Lower is tighter to points. */
|
|
3414
|
+
tolerance?: number;
|
|
3415
|
+
/** Corner angle threshold in degrees for sharp corners (default: 40). */
|
|
3416
|
+
cornerAngleDeg?: number;
|
|
3417
|
+
/** Real-time point streamlining / smoothing factor in [0, 1] (default: 0.35). 0 disables smoothing. */
|
|
3418
|
+
streamline?: number;
|
|
3419
|
+
}
|
|
3420
|
+
interface FreehandStroke {
|
|
3421
|
+
id: string;
|
|
3422
|
+
tool: FreehandTool;
|
|
3423
|
+
points: Point[];
|
|
3424
|
+
style: FreehandStrokeStyle;
|
|
3425
|
+
startTime?: number;
|
|
3426
|
+
}
|
|
3427
|
+
/**
|
|
3428
|
+
* Returns default stroke styles tailored for specific drawing tools.
|
|
3429
|
+
*/
|
|
3430
|
+
declare function createDefaultStrokeStyle(tool: FreehandTool): FreehandStrokeStyle;
|
|
3431
|
+
/**
|
|
3432
|
+
* Smooths jittery pointer samples using an exponential moving average.
|
|
3433
|
+
* The first and last points are anchored to guarantee stroke start and end precision.
|
|
3434
|
+
*/
|
|
3435
|
+
declare function streamlinePoints(points: readonly Point[], factor?: number): Point[];
|
|
3436
|
+
/**
|
|
3437
|
+
* Computes the tight axis-aligned bounding box of a sequence of points,
|
|
3438
|
+
* optionally expanded by a margin (such as strokeWidth / 2).
|
|
3439
|
+
*/
|
|
3440
|
+
declare function strokeBoundingBox(points: readonly Point[], margin?: number): Rect;
|
|
3441
|
+
/**
|
|
3442
|
+
* Converts a sequence of points into an SVG path `d` string.
|
|
3443
|
+
* Gracefully handles single points (dots) and two-point line segments.
|
|
3444
|
+
*/
|
|
3445
|
+
declare function strokePointsToPathData(points: readonly Point[], options?: Omit<FitPathDataOptions, 'closed'>): string;
|
|
3446
|
+
interface StrokeToShapeNodeOptions {
|
|
3447
|
+
id?: string;
|
|
3448
|
+
tolerance?: number;
|
|
3449
|
+
cornerAngleDeg?: number;
|
|
3450
|
+
}
|
|
3451
|
+
/**
|
|
3452
|
+
* Converts a completed freehand stroke into a native xyflow `ShapeNode`.
|
|
3453
|
+
* The geometry is normalized to node-local space with `viewBox`, ensuring crisp
|
|
3454
|
+
* scaling, non-scaling strokes, and full compatibility with existing shape ops.
|
|
3455
|
+
*/
|
|
3456
|
+
declare function strokeToShapeNode(stroke: FreehandStroke, options?: StrokeToShapeNodeOptions): CanvasNode;
|
|
3457
|
+
/**
|
|
3458
|
+
* Finds all stroke shape nodes intersecting a given point within a hit radius.
|
|
3459
|
+
* Ideal for object eraser interactions.
|
|
3460
|
+
*/
|
|
3461
|
+
declare function findStrokesAtPoint(point: Point, nodes: readonly CanvasNode[], radius?: number): CanvasNode[];
|
|
3462
|
+
|
|
3463
|
+
/**
|
|
3464
|
+
* Headless controller managing freehand drawing lifecycle, tool selection,
|
|
3465
|
+
* real-time pointer capture, ShapeNode creation, and undoable history actions.
|
|
3466
|
+
*/
|
|
3467
|
+
|
|
3468
|
+
interface CanvasDrawControllerOptions<TNode extends CanvasNode = CanvasNode> {
|
|
3469
|
+
getNodes: () => TNode[];
|
|
3470
|
+
setNodes: (nodes: TNode[]) => void;
|
|
3471
|
+
history?: ArrangeHistoryTarget;
|
|
3472
|
+
tool?: FreehandTool;
|
|
3473
|
+
style?: Partial<FreehandStrokeStyle>;
|
|
3474
|
+
drawOptions?: FreehandDrawOptions;
|
|
3475
|
+
generateNodeId?: () => string;
|
|
3476
|
+
onToolChange?: (tool: FreehandTool) => void;
|
|
3477
|
+
onStyleChange?: (style: FreehandStrokeStyle) => void;
|
|
3478
|
+
onActiveStrokeChange?: (stroke: FreehandStroke | null) => void;
|
|
3479
|
+
onStrokeComplete?: (node: TNode) => void;
|
|
3480
|
+
onNodesErase?: (erasedNodes: TNode[]) => void;
|
|
3481
|
+
}
|
|
3482
|
+
declare function createCanvasDrawController<TNode extends CanvasNode = CanvasNode>(options: CanvasDrawControllerOptions<TNode>): {
|
|
3483
|
+
readonly tool: FreehandTool;
|
|
3484
|
+
setTool: (tool: FreehandTool) => void;
|
|
3485
|
+
readonly style: FreehandStrokeStyle;
|
|
3486
|
+
setStyle: (style: Partial<FreehandStrokeStyle>) => void;
|
|
3487
|
+
readonly activeStroke: FreehandStroke | null;
|
|
3488
|
+
readonly isDrawing: boolean;
|
|
3489
|
+
startStroke: (point: Point) => void;
|
|
3490
|
+
continueStroke: (point: Point) => void;
|
|
3491
|
+
endStroke: () => TNode | null;
|
|
3492
|
+
cancelStroke: () => void;
|
|
3493
|
+
eraseAt: (point: Point, radius?: number) => TNode[];
|
|
3494
|
+
};
|
|
3495
|
+
type CanvasDrawController = ReturnType<typeof createCanvasDrawController>;
|
|
3496
|
+
|
|
3497
|
+
export { ANIMATABLE_PROPERTIES, ANIMATION_DATA_KEY, AUTO_LAYOUT_DATA_KEY, type AddCanvasVariantOptions, type AffineMatrix, AlignEdge, AlignNodesOptions, type AnimatableProperty, type AnimateNodeOptions, type AnimationDocument, AnimationEasing, AnimationEditError, type AnimationEditErrorCode, type AnimationFrame, type AnimationHistoryTarget, type AnimationKeyframeClipboard, AnimationLoopMode, type AnimationMotionPath, type AnimationOverrides, AnimationPlayer, AnimationPlayerState, type AnimationPropertyOptions, type AnimationStop, AnimationTrack, AnimationValue, AnimationValueType, type ArrangeHistoryTarget, type AutoLayout, type AutoLayoutAlignContent, type AutoLayoutAlignCross, type AutoLayoutAlignMain, type AutoLayoutCellAlign, type AutoLayoutChild, type AutoLayoutConstraints, type AutoLayoutGrid, type AutoLayoutGridArea, type AutoLayoutGridCell, type AutoLayoutGridGeometry, type AutoLayoutGridTrack, type AutoLayoutHorizontalConstraint, type AutoLayoutInsertTarget, type AutoLayoutMeasure, type AutoLayoutMode, type AutoLayoutOptions, type AutoLayoutPadding, type AutoLayoutSize, type AutoLayoutSizing, type AutoLayoutSizingPair, type AutoLayoutVerticalConstraint, type BezierCommand, type BezierContour, type BezierPath, type BezierPathInput, type BezierPathToSvgOptions, type BezierSegment, CANVAS_COMPONENT_DRAG_TYPE, CANVAS_GRADIENT_PRESETS, CANVAS_TOKEN_PROPERTIES, CHILD_LAYOUT_DATA_KEY, COMPONENT_DATA_KEY, COMPONENT_OVERRIDES_DATA_KEY, COMPONENT_PROPERTY_REFS_DATA_KEY, COMPONENT_SET_DATA_KEY, COMPONENT_SOURCE_DATA_KEY, CONNECTION_LINE_TYPES, CSS_ANIMATION_PROPERTIES, type CanvasAnimationController, type CanvasAnimationControllerOptions, type CanvasAnimationState, CanvasArrangeAction, type CanvasArrangeController, type CanvasArrangeControllerOptions, type CanvasAutoLayoutController, type CanvasAutoLayoutControllerOptions, CanvasClipboardPayload, type CanvasComponentData, type CanvasComponentErrorCode, type CanvasComponentInfo, type CanvasComponentPropertyDef, type CanvasComponentPropertyField, type CanvasComponentPropertyType, type CanvasComponentPropertyValue, type CanvasComponentResult, type CanvasComponentSetData, type CanvasComponentSetInfo, type CanvasComponentSyncOptions, type CanvasComponentsController, type CanvasComponentsControllerOptions, type CanvasConnectionLineType, type CanvasDrawController, type CanvasDrawControllerOptions, CanvasEdge, type CanvasGradientDef, type CanvasHeightOptions, type CanvasInstanceData, type CanvasInstanceInfo, type CanvasInstancePropertyInfo, CanvasLayoutOptions, type CanvasLinearGradient, CanvasNode, CanvasNodeStyle, CanvasNodeUpdate, type CanvasRadialGradient, type CanvasScene, type CanvasScenesOptions, type CanvasScenesState, CanvasScenesStore, type CanvasTokenBindingInfo, type CanvasTokenOptions, type CanvasTokenProperty, type CanvasViewport, Clock, type CombineShapeNodesOptions, type CombineShapeNodesRefusal, type CombineShapeNodesResult, type ConnectorSnap, type ConnectorSnapOptions, type ConnectorSnapTarget, type CreateCanvasComponentOptions, type CreateCanvasInstanceOptions, type CssAnimationExport, type CssExportOptions, type CssPropertyAnimation, type CubicSegment, DEFAULT_NODE_HEIGHT, DEFAULT_NODE_WIDTH, DEFAULT_PLACEMENT_GAP, type DashedPath, DirectionalDisplacementOptions, DistributeAxis, DistributeMode, DistributeNodesOptions, type DividePathsResult, type EllipseShape, type EvaluateAnimationOptions, FanOutTrajectoryOptions, type FitCubicsOptions, type FitPathDataOptions, type FitViewportOptions, type FlattenOptions, type FreehandDrawOptions, type FreehandStroke, type FreehandStrokeStyle, type FreehandTool, type GetShapeRenderDataOptions, type GradientStop, type GuideIndex, type GuideLine, INSTANCE_DATA_KEY, IncrementalLayoutOptions, type KeyframeDragState, type KeyframePatch, type KeyframeRangeOptions, type KeyframeRef, type KeyframeSnap, MAX_KEYFRAME_REFS, MatchSizeOptions, type MeasureGuide, type MeasureSelectionOptions, type MeasureSelectionResult, type MoveKeyframesResult, type MultiNodeTransitionOptions, type MultiPolygon, type NodeAnimation, NodeRectOptions, NodeTransition, type OffsetPathOptions, type OffsetShapeNodesOptions, type OutlineShapeStrokesOptions, type OutlineStrokeOptions, type PathBooleanOperation, type PathBooleanResult, type PathCommand, type PathOperand, type PathOperandInput, PathOpsError, type PathOpsOptions, type PathOpsReport, type PathPiece, type PathPointAtLength, type PathShape, PlaceBesideOptions, Point, type PolygonBooleanOperation, type PolygonBooleanOptions, type PolygonFillRule, type PolygonInput, type PolygonOperand, type PolygonPiece, type PolygonRing, type PolygonToPathOptions, type PolygonWithHoles, Position, type PositionChangeLike, RESIZE_HANDLES, type RecordAnimationOptions, Rect, type RectShape, ReflowDisplacementOptions, type RegularPolygonShape, type ResizeHandle, SHAPE_DATA_KEY, SHAPE_KINDS, SHAPE_NODE_TYPE, SHAPE_OPERATIONS, type SampleAnimationOptions, type ScaleKeyframesOptions, type SerializedCanvasScenes, type SetCanvasVariantPropertiesOptions, type SetKeyframeOptions, type ShapeDescription, type ShapeKind, type ShapeNodePolygonOptions, type ShapeOperation, type ShapePaint, type ShapePathEditOperation, type ShapePathEditRefusal, type ShapePathEditResult, type ShapeRenderData, type ShapeSize, Side, SizeDimension, type SnapGuidesOptions, type SnapNodeDragOptions, type SnapNodeDragResult, type SnapNodeResizeOptions, type SnapNodeResizeResult, type SnapResizeOptions, type SnapResizeResult, type SnapResult, type StarShape, StreamingLayoutManager, type StreamingLayoutManagerOptions, type StrokeCap, type StrokeJoin, type StrokeToShapeNodeOptions, type SvgGradientDef, type SvgGradientStop, TOKEN_BINDINGS_DATA_KEY, TOKEN_MODES_DATA_KEY, type TimelineKeyframe, type TimelineRow, type TimelineRowsOptions, TrajectoryFunction, type WebAnimationSpec, XYPosition, ZOrderOperation, addCanvasVariant, addKeyframesAtTime, angleToSvgLinearCoords, animateNode, applyAnimation, applyAnimationOverrides, applyConstraints, applyShapeCombination, applyShapeReplacement, arcToCubics, bezierPathArea, bezierPathBounds, bezierPathLength, bezierPathPointAtLength, bezierPathSignedArea, bezierPathToSvg, bindCanvasComponentProperty, bindCanvasToken, blendLayout, boundsOf, calculateDagreReflowDisplacement, calculateDirectionalDisplacement, canCombineShapeNodes, canOffsetShapeNodes, canOutlineShapeNodeStrokes, canvasHeight, centerNodes, centre, clampAnimationValue, clampLayoutSize, closeContour, collectDescendantIds, combineCanvasComponentsAsVariants, combineShapeNodes, computeNodesBoundingBox, computeSnapGuides, connectedOnly, contourSignedArea, contoursToPath, copyKeyframes, countPathSegments, createBezierTrajectory, createCanvasAnimationController, createCanvasArrangeController, createCanvasAutoLayoutController, createCanvasComponent, createCanvasComponentsController, createCanvasDrawController, createCanvasInstance, createCanvasScenesStore, createDefaultStrokeStyle, createFanOutTrajectory, createGuideIndex, createNodeGuideIndex, cubicPointAt, cubicsToPathData, dashContours, defaultEasing, deleteKeyframes, detachCanvasInstance, detachTokenBindings, diffOverrideGroups, distanceToBezierPath, dividePaths, dividePolygons, ensureLayout, estimateCanvasHeight, estimateNodeSize, evaluateAnimation, excludePaths, exportCssAnimation, findConnectorSnap, findStrokesAtPoint, findVariant, fitCubicRun, fitCubics, fitFreehandPath, fitPathData, fitViewportToNodes, fitViewportToRect, flattenSvgPath, flowSide, formatAnimationTime, formatNumber, formatVariantName, getAnimatableProperty, getAnimatedProperties, getAnimatedValue, getAnimationDuration, getAnimationTrack, getAutoLayout, getAutoLayoutGrid, getAutoLayoutInsertTarget, getBindableTokenProperties, getCanvasComponentDragId, getCanvasTokenProperty, getCenteredNodePosition, getChildLayout, getComponentData, getComponentInstances, getComponentPropertyDefs, getComponentPropertyRefs, getComponentSourceId, getCssPropertyAnimations, getDefaultVariant, getEffectiveTokenModes, getFlowChildren, getInstanceData, getInstanceProperties, getInstanceStatus, getKeyframeTimes, getLayerName, getLayoutParent, getLayoutSizing, getLayoutedNodes, getNextVariantValues, getNodeAnimation, getNodeOverrides, getNodeShape, getNodeTokenBindings, getNodeTokenModes, getOwningComponent, getOwningInstance, getResizingNodeRect, getRootInstance, getShapeRenderData, getShapeSvg, getTimelineRows, getTimelineTicks, getTokenPropertyScope, getTokensForProperty, getVariantConflicts, getVariantOptions, getVariantSet, getVariantValues, gradientToSvgDef, handlePoint, hasVisibleStroke, inferResizeHandle, inspectCanvasInstance, inspectNodeTokens, intersectPaths, intersectPolygons, isAutoLayoutFrame, isCanvasComponent, isCanvasComponentSet, isCanvasGradient, isCanvasInstance, isCssExportExact, isEventFromTextInput, isInsideInstance, isKeyframeSelected, isMeasureModifierHeld, isNodeAnimated, isShapeDescription, isShapeNode, isStraightCubic, isValidCanvasEdge, isValidCanvasNode, isValidCanvasScene, isValidUrl, layoutAll, layoutBounds, layoutFrame, layoutUp, layoutUpMany, linearPositionTrajectory, linearTrajectory, listCanvasComponents, makeSizingCoherent, measureBetween, measureLabel, measureSelection, measureToLine, mergeNodeUpdates, moveKeyframes, moveLayoutChild, multiPolygonArea, multiPolygonBounds, nearestHandlePositions, normalizeBezierPath, offsetPath, offsetShapeNodes, oppositePosition, outlineShapeNodeStrokes, outlineStroke, overlaps, parseCanvasClipboardData, parseCanvasScenes, parseCssGradient, parseKeyframeClipboard, parseNodeStyleDeclarations, parseSvgPath, parseVariantName, pasteKeyframes, pathBoolean, pathToContours, placeBeside, playWebAnimations, pointInBezierPath, pointInMultiPolygon, pointInRings, polygonArea, polygonBoolean, polygonToSvgPath, positionToSide, pruneCanvasTokenModes, pushCanvasInstanceOverrides, readAnimatableValue, readNodeStyleProperty, readOverrideGroup, recordAnimationChanges, relayoutUpdates, remapPastedNodes, removeCanvasVariant, removeTrack, renameCanvasVariantProperty, renameCanvasVariantValue, repositionNodesTo, resetCanvasInstanceOverrides, resizeHandleAxes, resolveCanvasGradient, resolveCanvasTokens, resolvePadding, restoreCanvasMainComponent, revertShapeCombination, ringSignedArea, runMultiNodeTransition, sampleAnimationFrames, scaleKeyframes, segmentBounds, segmentCurvature, segmentDerivative, segmentExtrema, segmentLength, segmentNearest, segmentParamAtLength, segmentPoint, segmentTangent, serializeCanvasNodes, setCanvasComponentProperty, setCanvasInstanceProperties, setCanvasTokenMode, setCanvasVariantProperties, setKeyframe, setKeyframeEasing, setMotionPath, setTrackEnabled, shapeNodeToBezierPath, shapeNodeToPolygon, shapeToBezierPath, shapeToPolygon, sideToPosition, simplifyRing, snapKeyframeDelta, snapNodeDrag, snapNodeResize, snapResize, snapTimeToFrame, snapToGrid, splitSegment, streamlinePoints, strokeBoundingBox, strokeOutlineRings, strokePointsToPathData, strokeToShapeNode, subSegment, subtractPaths, subtractPolygons, swapCanvasInstance, syncAllCanvasInstances, syncCanvasComponents, syncCanvasInstance, timeToX, toBezierPath, toWebAnimations, transformBezierPath, trimSegments, unionPolygons, unitePaths, updateKeyframe, windingNumber, withNodeAnimation, withStyleOpacity, wouldCreateComponentCycle, writeNodeStyleProperty, writeOverrideGroup, xToTime, xorPolygons };
|
package/dist/canvas/index.d.ts
CHANGED
|
@@ -4,8 +4,8 @@ import { Clock, AnimationValueType, AnimationValue, AnimationTrack, AnimationLoo
|
|
|
4
4
|
export { ANIMATION_TIME_EPSILON, AnimationKeyframe, AnimationPlayerOptions, ManualClock, OklabColor, createAnimationPlayer, evaluateTrack, formatOklab, interpolateAnimationValue, isAnimationKeyframe, mixColorsOklab, normalizeKeyframes, oklabToRgb, pageHidden, parseOklab, realClock, rgbToOklab, wrapAnimationTime } from '../animation/index.js';
|
|
5
5
|
import { C as Command, M as MergedExecutionOptions } from '../types-DsiXGmjo.js';
|
|
6
6
|
import { d as TokenModeContext, r as TokenType, o as TokenScope, f as TokenLiteral, c as TokenVariable, e as TokenResolution, T as TokenState } from '../model-C1zApQM8.js';
|
|
7
|
-
import { A as AnimationEasing } from '../easing-
|
|
8
|
-
export { a as ANIMATION_EASING_LABELS, b as ANIMATION_EASING_PRESETS, c as AnimationEasingPreset, C as CUBIC_BEZIER_PRESETS, d as CubicBezierEasing, S as SpringEasing, e as cubicBezierAt, f as easingFromInfluence, g as easingLabel, h as easingToCss, i as
|
|
7
|
+
import { A as AnimationEasing } from '../easing-DTmX99QG.js';
|
|
8
|
+
export { a as ANIMATION_EASING_LABELS, b as ANIMATION_EASING_PRESETS, c as AnimationEasingPreset, C as CUBIC_BEZIER_PRESETS, d as CubicBezierEasing, E as ElasticEasing, S as SpringEasing, e as cubicBezierAt, f as easingFromInfluence, g as easingLabel, h as easingToCss, i as elasticAt, j as evaluateEasing, k as isAnimationEasing, p as parseCssEasing, r as resolveEasing, s as springAt } from '../easing-DTmX99QG.js';
|
|
9
9
|
|
|
10
10
|
declare const DEFAULT_NODE_WIDTH = 200;
|
|
11
11
|
declare const DEFAULT_NODE_HEIGHT = 60;
|
|
@@ -664,17 +664,85 @@ declare const xorPolygons: (a: PolygonInput, b: PolygonInput, options?: PolygonB
|
|
|
664
664
|
*/
|
|
665
665
|
declare function dividePolygons(operands: PolygonInput[], options?: PolygonBooleanOptions): PolygonPiece[];
|
|
666
666
|
|
|
667
|
+
/**
|
|
668
|
+
* Canvas gradient models, parsing, presets, and SVG defs generation.
|
|
669
|
+
* Supports linear and radial gradients for shape fills, strokes, and freehand drawing.
|
|
670
|
+
*/
|
|
671
|
+
interface GradientStop {
|
|
672
|
+
offset: number;
|
|
673
|
+
color: string;
|
|
674
|
+
opacity?: number;
|
|
675
|
+
}
|
|
676
|
+
interface CanvasLinearGradient {
|
|
677
|
+
type: 'linear';
|
|
678
|
+
angle?: number;
|
|
679
|
+
stops: GradientStop[];
|
|
680
|
+
}
|
|
681
|
+
interface CanvasRadialGradient {
|
|
682
|
+
type: 'radial';
|
|
683
|
+
cx?: number;
|
|
684
|
+
cy?: number;
|
|
685
|
+
r?: number;
|
|
686
|
+
stops: GradientStop[];
|
|
687
|
+
}
|
|
688
|
+
type CanvasGradientDef = CanvasLinearGradient | CanvasRadialGradient;
|
|
689
|
+
interface SvgGradientStop {
|
|
690
|
+
offset: string;
|
|
691
|
+
stopColor: string;
|
|
692
|
+
stopOpacity?: number;
|
|
693
|
+
}
|
|
694
|
+
interface SvgGradientDef {
|
|
695
|
+
id: string;
|
|
696
|
+
type: 'linear' | 'radial';
|
|
697
|
+
attrs: Record<string, string | number>;
|
|
698
|
+
stops: SvgGradientStop[];
|
|
699
|
+
}
|
|
700
|
+
declare const CANVAS_GRADIENT_PRESETS: Record<string, CanvasLinearGradient>;
|
|
701
|
+
/** Whether an arbitrary value matches a CanvasGradientDef object. */
|
|
702
|
+
declare function isCanvasGradient(value: unknown): value is CanvasGradientDef;
|
|
703
|
+
/**
|
|
704
|
+
* Parses CSS linear-gradient or radial-gradient strings into CanvasGradientDef.
|
|
705
|
+
* Supports forms like:
|
|
706
|
+
* - linear-gradient(90deg, #ff0000 0%, #0000ff 100%)
|
|
707
|
+
* - linear-gradient(to right, red, blue)
|
|
708
|
+
* - radial-gradient(circle, red 0%, blue 100%)
|
|
709
|
+
*/
|
|
710
|
+
declare function parseCssGradient(css: string): CanvasGradientDef | null;
|
|
711
|
+
/**
|
|
712
|
+
* Resolves a paint value (which could be a CSS color, preset name, CSS gradient string, or CanvasGradientDef)
|
|
713
|
+
* into either a CanvasGradientDef (if gradient) or null (if solid color or invalid).
|
|
714
|
+
*/
|
|
715
|
+
declare function resolveCanvasGradient(value: unknown): CanvasGradientDef | null;
|
|
716
|
+
/**
|
|
717
|
+
* Converts degrees clockwise (CSS angle: 0 = top, 90 = right, 180 = bottom, 270 = left)
|
|
718
|
+
* to SVG linearGradient vector coordinates (x1, y1, x2, y2) normalized [0, 1].
|
|
719
|
+
*/
|
|
720
|
+
declare function angleToSvgLinearCoords(angleDeg?: number): {
|
|
721
|
+
x1: number;
|
|
722
|
+
y1: number;
|
|
723
|
+
x2: number;
|
|
724
|
+
y2: number;
|
|
725
|
+
};
|
|
726
|
+
/**
|
|
727
|
+
* Converts a CanvasGradientDef to an SvgGradientDef descriptor ready for rendering `<linearGradient>` / `<radialGradient>`.
|
|
728
|
+
*/
|
|
729
|
+
declare function gradientToSvgDef(gradient: CanvasGradientDef, id: string): SvgGradientDef;
|
|
730
|
+
|
|
667
731
|
/**
|
|
668
732
|
* Shape geometry: shape descriptions (rect, rounded rect, ellipse, regular polygon, star and
|
|
669
733
|
* SVG path data) to polygons, SVG path parsing / flattening, and polygons back to path data.
|
|
670
734
|
*/
|
|
671
735
|
|
|
672
|
-
/** Paint shared by every shape kind. Colours are any CSS colour. */
|
|
736
|
+
/** Paint shared by every shape kind. Colours are any CSS colour, preset name, or gradient definition. */
|
|
673
737
|
interface ShapePaint {
|
|
674
|
-
fill?: string;
|
|
675
|
-
stroke?: string;
|
|
738
|
+
fill?: string | CanvasGradientDef;
|
|
739
|
+
stroke?: string | CanvasGradientDef;
|
|
676
740
|
strokeWidth?: number;
|
|
677
741
|
opacity?: number;
|
|
742
|
+
strokeLinecap?: 'round' | 'butt' | 'square';
|
|
743
|
+
strokeLinejoin?: 'round' | 'bevel' | 'miter';
|
|
744
|
+
fillGradient?: CanvasGradientDef;
|
|
745
|
+
strokeGradient?: CanvasGradientDef;
|
|
678
746
|
}
|
|
679
747
|
interface ShapeBase extends ShapePaint {
|
|
680
748
|
/** Clockwise rotation in degrees (on a y-down canvas) about the centre of the node box. */
|
|
@@ -804,13 +872,23 @@ interface ShapeRenderData {
|
|
|
804
872
|
stroke: string;
|
|
805
873
|
strokeWidth: number;
|
|
806
874
|
opacity?: number;
|
|
875
|
+
strokeLinecap?: 'round' | 'butt' | 'square';
|
|
876
|
+
strokeLinejoin?: 'round' | 'bevel' | 'miter';
|
|
877
|
+
/** Gradient def for the fill, when fill uses a gradient. */
|
|
878
|
+
fillGradient?: SvgGradientDef;
|
|
879
|
+
/** Gradient def for the stroke, when stroke uses a gradient. */
|
|
880
|
+
strokeGradient?: SvgGradientDef;
|
|
881
|
+
}
|
|
882
|
+
interface GetShapeRenderDataOptions {
|
|
883
|
+
/** Unique ID suffix or base ID used when generating SVG gradient IDs (default: auto random). */
|
|
884
|
+
id?: string;
|
|
807
885
|
}
|
|
808
886
|
/**
|
|
809
887
|
* Resolves the SVG drawing of a shape for a node size. Without a size, a path's view box
|
|
810
888
|
* size (or 100x100) is used. Paint defaults: `fill: currentColor`, `stroke: none`,
|
|
811
|
-
* `strokeWidth: 1`.
|
|
889
|
+
* `strokeWidth: 1`. Supports solid colors, CSS gradients, presets, and CanvasGradientDef.
|
|
812
890
|
*/
|
|
813
|
-
declare function getShapeRenderData(shape: ShapeDescription, size?: Partial<ShapeSize
|
|
891
|
+
declare function getShapeRenderData(shape: ShapeDescription, size?: Partial<ShapeSize>, options?: GetShapeRenderDataOptions): ShapeRenderData;
|
|
814
892
|
/**
|
|
815
893
|
* Converts a shape to rings in node-local pixels (rotation applied), flattening curves at
|
|
816
894
|
* `tolerance`. Returns the rings with the fill rule they must be read with.
|
|
@@ -1429,7 +1507,7 @@ interface OutlineShapeStrokesOptions extends ShapePathEditBaseOptions {
|
|
|
1429
1507
|
*/
|
|
1430
1508
|
keepFill?: boolean;
|
|
1431
1509
|
}
|
|
1432
|
-
/** Whether a shape draws a stroke (a stroke colour other than `none` and a positive width). */
|
|
1510
|
+
/** Whether a shape draws a stroke (a stroke colour or gradient other than `none` and a positive width). */
|
|
1433
1511
|
declare function hasVisibleStroke(shape: ShapeDescription | null): boolean;
|
|
1434
1512
|
/** Checks whether `offsetShapeNodes` can run (it cannot predict an `empty` result). */
|
|
1435
1513
|
declare function canOffsetShapeNodes(nodes: CanvasNode[], ids: Iterable<string>): {
|
|
@@ -3310,4 +3388,110 @@ declare const CANVAS_COMPONENT_DRAG_TYPE = "application/x-pixerate-component";
|
|
|
3310
3388
|
/** Reads the component id a components panel put on a drag (or `undefined`). */
|
|
3311
3389
|
declare function getCanvasComponentDragId(dataTransfer: Pick<DataTransfer, 'getData'> | null | undefined): string | undefined;
|
|
3312
3390
|
|
|
3313
|
-
export { ANIMATABLE_PROPERTIES, ANIMATION_DATA_KEY, AUTO_LAYOUT_DATA_KEY, type AddCanvasVariantOptions, type AffineMatrix, AlignEdge, AlignNodesOptions, type AnimatableProperty, type AnimateNodeOptions, type AnimationDocument, AnimationEasing, AnimationEditError, type AnimationEditErrorCode, type AnimationFrame, type AnimationHistoryTarget, type AnimationKeyframeClipboard, AnimationLoopMode, type AnimationMotionPath, type AnimationOverrides, AnimationPlayer, AnimationPlayerState, type AnimationPropertyOptions, type AnimationStop, AnimationTrack, AnimationValue, AnimationValueType, type ArrangeHistoryTarget, type AutoLayout, type AutoLayoutAlignContent, type AutoLayoutAlignCross, type AutoLayoutAlignMain, type AutoLayoutCellAlign, type AutoLayoutChild, type AutoLayoutConstraints, type AutoLayoutGrid, type AutoLayoutGridArea, type AutoLayoutGridCell, type AutoLayoutGridGeometry, type AutoLayoutGridTrack, type AutoLayoutHorizontalConstraint, type AutoLayoutInsertTarget, type AutoLayoutMeasure, type AutoLayoutMode, type AutoLayoutOptions, type AutoLayoutPadding, type AutoLayoutSize, type AutoLayoutSizing, type AutoLayoutSizingPair, type AutoLayoutVerticalConstraint, type BezierCommand, type BezierContour, type BezierPath, type BezierPathInput, type BezierPathToSvgOptions, type BezierSegment, CANVAS_COMPONENT_DRAG_TYPE, CANVAS_TOKEN_PROPERTIES, CHILD_LAYOUT_DATA_KEY, COMPONENT_DATA_KEY, COMPONENT_OVERRIDES_DATA_KEY, COMPONENT_PROPERTY_REFS_DATA_KEY, COMPONENT_SET_DATA_KEY, COMPONENT_SOURCE_DATA_KEY, CONNECTION_LINE_TYPES, CSS_ANIMATION_PROPERTIES, type CanvasAnimationController, type CanvasAnimationControllerOptions, type CanvasAnimationState, CanvasArrangeAction, type CanvasArrangeController, type CanvasArrangeControllerOptions, type CanvasAutoLayoutController, type CanvasAutoLayoutControllerOptions, CanvasClipboardPayload, type CanvasComponentData, type CanvasComponentErrorCode, type CanvasComponentInfo, type CanvasComponentPropertyDef, type CanvasComponentPropertyField, type CanvasComponentPropertyType, type CanvasComponentPropertyValue, type CanvasComponentResult, type CanvasComponentSetData, type CanvasComponentSetInfo, type CanvasComponentSyncOptions, type CanvasComponentsController, type CanvasComponentsControllerOptions, type CanvasConnectionLineType, CanvasEdge, type CanvasHeightOptions, type CanvasInstanceData, type CanvasInstanceInfo, type CanvasInstancePropertyInfo, CanvasLayoutOptions, CanvasNode, CanvasNodeStyle, CanvasNodeUpdate, type CanvasScene, type CanvasScenesOptions, type CanvasScenesState, CanvasScenesStore, type CanvasTokenBindingInfo, type CanvasTokenOptions, type CanvasTokenProperty, type CanvasViewport, Clock, type CombineShapeNodesOptions, type CombineShapeNodesRefusal, type CombineShapeNodesResult, type ConnectorSnap, type ConnectorSnapOptions, type ConnectorSnapTarget, type CreateCanvasComponentOptions, type CreateCanvasInstanceOptions, type CssAnimationExport, type CssExportOptions, type CssPropertyAnimation, type CubicSegment, DEFAULT_NODE_HEIGHT, DEFAULT_NODE_WIDTH, DEFAULT_PLACEMENT_GAP, type DashedPath, DirectionalDisplacementOptions, DistributeAxis, DistributeMode, DistributeNodesOptions, type DividePathsResult, type EllipseShape, type EvaluateAnimationOptions, FanOutTrajectoryOptions, type FitCubicsOptions, type FitPathDataOptions, type FitViewportOptions, type FlattenOptions, type GuideIndex, type GuideLine, INSTANCE_DATA_KEY, IncrementalLayoutOptions, type KeyframeDragState, type KeyframePatch, type KeyframeRangeOptions, type KeyframeRef, type KeyframeSnap, MAX_KEYFRAME_REFS, MatchSizeOptions, type MeasureGuide, type MeasureSelectionOptions, type MeasureSelectionResult, type MoveKeyframesResult, type MultiNodeTransitionOptions, type MultiPolygon, type NodeAnimation, NodeRectOptions, NodeTransition, type OffsetPathOptions, type OffsetShapeNodesOptions, type OutlineShapeStrokesOptions, type OutlineStrokeOptions, type PathBooleanOperation, type PathBooleanResult, type PathCommand, type PathOperand, type PathOperandInput, PathOpsError, type PathOpsOptions, type PathOpsReport, type PathPiece, type PathPointAtLength, type PathShape, PlaceBesideOptions, Point, type PolygonBooleanOperation, type PolygonBooleanOptions, type PolygonFillRule, type PolygonInput, type PolygonOperand, type PolygonPiece, type PolygonRing, type PolygonToPathOptions, type PolygonWithHoles, Position, type PositionChangeLike, RESIZE_HANDLES, type RecordAnimationOptions, Rect, type RectShape, ReflowDisplacementOptions, type RegularPolygonShape, type ResizeHandle, SHAPE_DATA_KEY, SHAPE_KINDS, SHAPE_NODE_TYPE, SHAPE_OPERATIONS, type SampleAnimationOptions, type ScaleKeyframesOptions, type SerializedCanvasScenes, type SetCanvasVariantPropertiesOptions, type SetKeyframeOptions, type ShapeDescription, type ShapeKind, type ShapeNodePolygonOptions, type ShapeOperation, type ShapePaint, type ShapePathEditOperation, type ShapePathEditRefusal, type ShapePathEditResult, type ShapeRenderData, type ShapeSize, Side, SizeDimension, type SnapGuidesOptions, type SnapNodeDragOptions, type SnapNodeDragResult, type SnapNodeResizeOptions, type SnapNodeResizeResult, type SnapResizeOptions, type SnapResizeResult, type SnapResult, type StarShape, StreamingLayoutManager, type StreamingLayoutManagerOptions, type StrokeCap, type StrokeJoin, TOKEN_BINDINGS_DATA_KEY, TOKEN_MODES_DATA_KEY, type TimelineKeyframe, type TimelineRow, type TimelineRowsOptions, TrajectoryFunction, type WebAnimationSpec, XYPosition, ZOrderOperation, addCanvasVariant, addKeyframesAtTime, animateNode, applyAnimation, applyAnimationOverrides, applyConstraints, applyShapeCombination, applyShapeReplacement, arcToCubics, bezierPathArea, bezierPathBounds, bezierPathLength, bezierPathPointAtLength, bezierPathSignedArea, bezierPathToSvg, bindCanvasComponentProperty, bindCanvasToken, blendLayout, boundsOf, calculateDagreReflowDisplacement, calculateDirectionalDisplacement, canCombineShapeNodes, canOffsetShapeNodes, canOutlineShapeNodeStrokes, canvasHeight, centerNodes, centre, clampAnimationValue, clampLayoutSize, closeContour, collectDescendantIds, combineCanvasComponentsAsVariants, combineShapeNodes, computeNodesBoundingBox, computeSnapGuides, connectedOnly, contourSignedArea, contoursToPath, copyKeyframes, countPathSegments, createBezierTrajectory, createCanvasAnimationController, createCanvasArrangeController, createCanvasAutoLayoutController, createCanvasComponent, createCanvasComponentsController, createCanvasInstance, createCanvasScenesStore, createFanOutTrajectory, createGuideIndex, createNodeGuideIndex, cubicPointAt, cubicsToPathData, dashContours, defaultEasing, deleteKeyframes, detachCanvasInstance, detachTokenBindings, diffOverrideGroups, distanceToBezierPath, dividePaths, dividePolygons, ensureLayout, estimateCanvasHeight, estimateNodeSize, evaluateAnimation, excludePaths, exportCssAnimation, findConnectorSnap, findVariant, fitCubicRun, fitCubics, fitFreehandPath, fitPathData, fitViewportToNodes, fitViewportToRect, flattenSvgPath, flowSide, formatAnimationTime, formatNumber, formatVariantName, getAnimatableProperty, getAnimatedProperties, getAnimatedValue, getAnimationDuration, getAnimationTrack, getAutoLayout, getAutoLayoutGrid, getAutoLayoutInsertTarget, getBindableTokenProperties, getCanvasComponentDragId, getCanvasTokenProperty, getCenteredNodePosition, getChildLayout, getComponentData, getComponentInstances, getComponentPropertyDefs, getComponentPropertyRefs, getComponentSourceId, getCssPropertyAnimations, getDefaultVariant, getEffectiveTokenModes, getFlowChildren, getInstanceData, getInstanceProperties, getInstanceStatus, getKeyframeTimes, getLayerName, getLayoutParent, getLayoutSizing, getLayoutedNodes, getNextVariantValues, getNodeAnimation, getNodeOverrides, getNodeShape, getNodeTokenBindings, getNodeTokenModes, getOwningComponent, getOwningInstance, getResizingNodeRect, getRootInstance, getShapeRenderData, getShapeSvg, getTimelineRows, getTimelineTicks, getTokenPropertyScope, getTokensForProperty, getVariantConflicts, getVariantOptions, getVariantSet, getVariantValues, handlePoint, hasVisibleStroke, inferResizeHandle, inspectCanvasInstance, inspectNodeTokens, intersectPaths, intersectPolygons, isAutoLayoutFrame, isCanvasComponent, isCanvasComponentSet, isCanvasInstance, isCssExportExact, isEventFromTextInput, isInsideInstance, isKeyframeSelected, isMeasureModifierHeld, isNodeAnimated, isShapeDescription, isShapeNode, isStraightCubic, isValidCanvasEdge, isValidCanvasNode, isValidCanvasScene, isValidUrl, layoutAll, layoutBounds, layoutFrame, layoutUp, layoutUpMany, linearPositionTrajectory, linearTrajectory, listCanvasComponents, makeSizingCoherent, measureBetween, measureLabel, measureSelection, measureToLine, mergeNodeUpdates, moveKeyframes, moveLayoutChild, multiPolygonArea, multiPolygonBounds, nearestHandlePositions, normalizeBezierPath, offsetPath, offsetShapeNodes, oppositePosition, outlineShapeNodeStrokes, outlineStroke, overlaps, parseCanvasClipboardData, parseCanvasScenes, parseKeyframeClipboard, parseNodeStyleDeclarations, parseSvgPath, parseVariantName, pasteKeyframes, pathBoolean, pathToContours, placeBeside, playWebAnimations, pointInBezierPath, pointInMultiPolygon, pointInRings, polygonArea, polygonBoolean, polygonToSvgPath, positionToSide, pruneCanvasTokenModes, pushCanvasInstanceOverrides, readAnimatableValue, readNodeStyleProperty, readOverrideGroup, recordAnimationChanges, relayoutUpdates, remapPastedNodes, removeCanvasVariant, removeTrack, renameCanvasVariantProperty, renameCanvasVariantValue, repositionNodesTo, resetCanvasInstanceOverrides, resizeHandleAxes, resolveCanvasTokens, resolvePadding, restoreCanvasMainComponent, revertShapeCombination, ringSignedArea, runMultiNodeTransition, sampleAnimationFrames, scaleKeyframes, segmentBounds, segmentCurvature, segmentDerivative, segmentExtrema, segmentLength, segmentNearest, segmentParamAtLength, segmentPoint, segmentTangent, serializeCanvasNodes, setCanvasComponentProperty, setCanvasInstanceProperties, setCanvasTokenMode, setCanvasVariantProperties, setKeyframe, setKeyframeEasing, setMotionPath, setTrackEnabled, shapeNodeToBezierPath, shapeNodeToPolygon, shapeToBezierPath, shapeToPolygon, sideToPosition, simplifyRing, snapKeyframeDelta, snapNodeDrag, snapNodeResize, snapResize, snapTimeToFrame, snapToGrid, splitSegment, strokeOutlineRings, subSegment, subtractPaths, subtractPolygons, swapCanvasInstance, syncAllCanvasInstances, syncCanvasComponents, syncCanvasInstance, timeToX, toBezierPath, toWebAnimations, transformBezierPath, trimSegments, unionPolygons, unitePaths, updateKeyframe, windingNumber, withNodeAnimation, withStyleOpacity, wouldCreateComponentCycle, writeNodeStyleProperty, writeOverrideGroup, xToTime, xorPolygons };
|
|
3391
|
+
/**
|
|
3392
|
+
* Freehand drawing utilities: stroke smoothing, cubic Bézier conversion,
|
|
3393
|
+
* ShapeNode generation, and spatial eraser hit-testing within the xyflow framework.
|
|
3394
|
+
*/
|
|
3395
|
+
|
|
3396
|
+
type FreehandTool = 'select' | 'pen' | 'highlighter' | 'eraser';
|
|
3397
|
+
|
|
3398
|
+
interface FreehandStrokeStyle {
|
|
3399
|
+
/** Stroke color (any CSS color string) or gradient definition. */
|
|
3400
|
+
color: string | CanvasGradientDef;
|
|
3401
|
+
/** Stroke width in flow canvas units. */
|
|
3402
|
+
width: number;
|
|
3403
|
+
/** Stroke opacity (0 to 1). */
|
|
3404
|
+
opacity: number;
|
|
3405
|
+
/** SVG stroke-linecap: 'round', 'butt', or 'square'. */
|
|
3406
|
+
cap?: 'round' | 'butt' | 'square';
|
|
3407
|
+
/** SVG stroke-linejoin: 'round', 'bevel', or 'miter'. */
|
|
3408
|
+
join?: 'round' | 'bevel' | 'miter';
|
|
3409
|
+
/** Optional gradient definition for the stroke. */
|
|
3410
|
+
gradient?: CanvasGradientDef;
|
|
3411
|
+
}
|
|
3412
|
+
interface FreehandDrawOptions {
|
|
3413
|
+
/** Cubic curve fitting tolerance (default: 1.0). Lower is tighter to points. */
|
|
3414
|
+
tolerance?: number;
|
|
3415
|
+
/** Corner angle threshold in degrees for sharp corners (default: 40). */
|
|
3416
|
+
cornerAngleDeg?: number;
|
|
3417
|
+
/** Real-time point streamlining / smoothing factor in [0, 1] (default: 0.35). 0 disables smoothing. */
|
|
3418
|
+
streamline?: number;
|
|
3419
|
+
}
|
|
3420
|
+
interface FreehandStroke {
|
|
3421
|
+
id: string;
|
|
3422
|
+
tool: FreehandTool;
|
|
3423
|
+
points: Point[];
|
|
3424
|
+
style: FreehandStrokeStyle;
|
|
3425
|
+
startTime?: number;
|
|
3426
|
+
}
|
|
3427
|
+
/**
|
|
3428
|
+
* Returns default stroke styles tailored for specific drawing tools.
|
|
3429
|
+
*/
|
|
3430
|
+
declare function createDefaultStrokeStyle(tool: FreehandTool): FreehandStrokeStyle;
|
|
3431
|
+
/**
|
|
3432
|
+
* Smooths jittery pointer samples using an exponential moving average.
|
|
3433
|
+
* The first and last points are anchored to guarantee stroke start and end precision.
|
|
3434
|
+
*/
|
|
3435
|
+
declare function streamlinePoints(points: readonly Point[], factor?: number): Point[];
|
|
3436
|
+
/**
|
|
3437
|
+
* Computes the tight axis-aligned bounding box of a sequence of points,
|
|
3438
|
+
* optionally expanded by a margin (such as strokeWidth / 2).
|
|
3439
|
+
*/
|
|
3440
|
+
declare function strokeBoundingBox(points: readonly Point[], margin?: number): Rect;
|
|
3441
|
+
/**
|
|
3442
|
+
* Converts a sequence of points into an SVG path `d` string.
|
|
3443
|
+
* Gracefully handles single points (dots) and two-point line segments.
|
|
3444
|
+
*/
|
|
3445
|
+
declare function strokePointsToPathData(points: readonly Point[], options?: Omit<FitPathDataOptions, 'closed'>): string;
|
|
3446
|
+
interface StrokeToShapeNodeOptions {
|
|
3447
|
+
id?: string;
|
|
3448
|
+
tolerance?: number;
|
|
3449
|
+
cornerAngleDeg?: number;
|
|
3450
|
+
}
|
|
3451
|
+
/**
|
|
3452
|
+
* Converts a completed freehand stroke into a native xyflow `ShapeNode`.
|
|
3453
|
+
* The geometry is normalized to node-local space with `viewBox`, ensuring crisp
|
|
3454
|
+
* scaling, non-scaling strokes, and full compatibility with existing shape ops.
|
|
3455
|
+
*/
|
|
3456
|
+
declare function strokeToShapeNode(stroke: FreehandStroke, options?: StrokeToShapeNodeOptions): CanvasNode;
|
|
3457
|
+
/**
|
|
3458
|
+
* Finds all stroke shape nodes intersecting a given point within a hit radius.
|
|
3459
|
+
* Ideal for object eraser interactions.
|
|
3460
|
+
*/
|
|
3461
|
+
declare function findStrokesAtPoint(point: Point, nodes: readonly CanvasNode[], radius?: number): CanvasNode[];
|
|
3462
|
+
|
|
3463
|
+
/**
|
|
3464
|
+
* Headless controller managing freehand drawing lifecycle, tool selection,
|
|
3465
|
+
* real-time pointer capture, ShapeNode creation, and undoable history actions.
|
|
3466
|
+
*/
|
|
3467
|
+
|
|
3468
|
+
interface CanvasDrawControllerOptions<TNode extends CanvasNode = CanvasNode> {
|
|
3469
|
+
getNodes: () => TNode[];
|
|
3470
|
+
setNodes: (nodes: TNode[]) => void;
|
|
3471
|
+
history?: ArrangeHistoryTarget;
|
|
3472
|
+
tool?: FreehandTool;
|
|
3473
|
+
style?: Partial<FreehandStrokeStyle>;
|
|
3474
|
+
drawOptions?: FreehandDrawOptions;
|
|
3475
|
+
generateNodeId?: () => string;
|
|
3476
|
+
onToolChange?: (tool: FreehandTool) => void;
|
|
3477
|
+
onStyleChange?: (style: FreehandStrokeStyle) => void;
|
|
3478
|
+
onActiveStrokeChange?: (stroke: FreehandStroke | null) => void;
|
|
3479
|
+
onStrokeComplete?: (node: TNode) => void;
|
|
3480
|
+
onNodesErase?: (erasedNodes: TNode[]) => void;
|
|
3481
|
+
}
|
|
3482
|
+
declare function createCanvasDrawController<TNode extends CanvasNode = CanvasNode>(options: CanvasDrawControllerOptions<TNode>): {
|
|
3483
|
+
readonly tool: FreehandTool;
|
|
3484
|
+
setTool: (tool: FreehandTool) => void;
|
|
3485
|
+
readonly style: FreehandStrokeStyle;
|
|
3486
|
+
setStyle: (style: Partial<FreehandStrokeStyle>) => void;
|
|
3487
|
+
readonly activeStroke: FreehandStroke | null;
|
|
3488
|
+
readonly isDrawing: boolean;
|
|
3489
|
+
startStroke: (point: Point) => void;
|
|
3490
|
+
continueStroke: (point: Point) => void;
|
|
3491
|
+
endStroke: () => TNode | null;
|
|
3492
|
+
cancelStroke: () => void;
|
|
3493
|
+
eraseAt: (point: Point, radius?: number) => TNode[];
|
|
3494
|
+
};
|
|
3495
|
+
type CanvasDrawController = ReturnType<typeof createCanvasDrawController>;
|
|
3496
|
+
|
|
3497
|
+
export { ANIMATABLE_PROPERTIES, ANIMATION_DATA_KEY, AUTO_LAYOUT_DATA_KEY, type AddCanvasVariantOptions, type AffineMatrix, AlignEdge, AlignNodesOptions, type AnimatableProperty, type AnimateNodeOptions, type AnimationDocument, AnimationEasing, AnimationEditError, type AnimationEditErrorCode, type AnimationFrame, type AnimationHistoryTarget, type AnimationKeyframeClipboard, AnimationLoopMode, type AnimationMotionPath, type AnimationOverrides, AnimationPlayer, AnimationPlayerState, type AnimationPropertyOptions, type AnimationStop, AnimationTrack, AnimationValue, AnimationValueType, type ArrangeHistoryTarget, type AutoLayout, type AutoLayoutAlignContent, type AutoLayoutAlignCross, type AutoLayoutAlignMain, type AutoLayoutCellAlign, type AutoLayoutChild, type AutoLayoutConstraints, type AutoLayoutGrid, type AutoLayoutGridArea, type AutoLayoutGridCell, type AutoLayoutGridGeometry, type AutoLayoutGridTrack, type AutoLayoutHorizontalConstraint, type AutoLayoutInsertTarget, type AutoLayoutMeasure, type AutoLayoutMode, type AutoLayoutOptions, type AutoLayoutPadding, type AutoLayoutSize, type AutoLayoutSizing, type AutoLayoutSizingPair, type AutoLayoutVerticalConstraint, type BezierCommand, type BezierContour, type BezierPath, type BezierPathInput, type BezierPathToSvgOptions, type BezierSegment, CANVAS_COMPONENT_DRAG_TYPE, CANVAS_GRADIENT_PRESETS, CANVAS_TOKEN_PROPERTIES, CHILD_LAYOUT_DATA_KEY, COMPONENT_DATA_KEY, COMPONENT_OVERRIDES_DATA_KEY, COMPONENT_PROPERTY_REFS_DATA_KEY, COMPONENT_SET_DATA_KEY, COMPONENT_SOURCE_DATA_KEY, CONNECTION_LINE_TYPES, CSS_ANIMATION_PROPERTIES, type CanvasAnimationController, type CanvasAnimationControllerOptions, type CanvasAnimationState, CanvasArrangeAction, type CanvasArrangeController, type CanvasArrangeControllerOptions, type CanvasAutoLayoutController, type CanvasAutoLayoutControllerOptions, CanvasClipboardPayload, type CanvasComponentData, type CanvasComponentErrorCode, type CanvasComponentInfo, type CanvasComponentPropertyDef, type CanvasComponentPropertyField, type CanvasComponentPropertyType, type CanvasComponentPropertyValue, type CanvasComponentResult, type CanvasComponentSetData, type CanvasComponentSetInfo, type CanvasComponentSyncOptions, type CanvasComponentsController, type CanvasComponentsControllerOptions, type CanvasConnectionLineType, type CanvasDrawController, type CanvasDrawControllerOptions, CanvasEdge, type CanvasGradientDef, type CanvasHeightOptions, type CanvasInstanceData, type CanvasInstanceInfo, type CanvasInstancePropertyInfo, CanvasLayoutOptions, type CanvasLinearGradient, CanvasNode, CanvasNodeStyle, CanvasNodeUpdate, type CanvasRadialGradient, type CanvasScene, type CanvasScenesOptions, type CanvasScenesState, CanvasScenesStore, type CanvasTokenBindingInfo, type CanvasTokenOptions, type CanvasTokenProperty, type CanvasViewport, Clock, type CombineShapeNodesOptions, type CombineShapeNodesRefusal, type CombineShapeNodesResult, type ConnectorSnap, type ConnectorSnapOptions, type ConnectorSnapTarget, type CreateCanvasComponentOptions, type CreateCanvasInstanceOptions, type CssAnimationExport, type CssExportOptions, type CssPropertyAnimation, type CubicSegment, DEFAULT_NODE_HEIGHT, DEFAULT_NODE_WIDTH, DEFAULT_PLACEMENT_GAP, type DashedPath, DirectionalDisplacementOptions, DistributeAxis, DistributeMode, DistributeNodesOptions, type DividePathsResult, type EllipseShape, type EvaluateAnimationOptions, FanOutTrajectoryOptions, type FitCubicsOptions, type FitPathDataOptions, type FitViewportOptions, type FlattenOptions, type FreehandDrawOptions, type FreehandStroke, type FreehandStrokeStyle, type FreehandTool, type GetShapeRenderDataOptions, type GradientStop, type GuideIndex, type GuideLine, INSTANCE_DATA_KEY, IncrementalLayoutOptions, type KeyframeDragState, type KeyframePatch, type KeyframeRangeOptions, type KeyframeRef, type KeyframeSnap, MAX_KEYFRAME_REFS, MatchSizeOptions, type MeasureGuide, type MeasureSelectionOptions, type MeasureSelectionResult, type MoveKeyframesResult, type MultiNodeTransitionOptions, type MultiPolygon, type NodeAnimation, NodeRectOptions, NodeTransition, type OffsetPathOptions, type OffsetShapeNodesOptions, type OutlineShapeStrokesOptions, type OutlineStrokeOptions, type PathBooleanOperation, type PathBooleanResult, type PathCommand, type PathOperand, type PathOperandInput, PathOpsError, type PathOpsOptions, type PathOpsReport, type PathPiece, type PathPointAtLength, type PathShape, PlaceBesideOptions, Point, type PolygonBooleanOperation, type PolygonBooleanOptions, type PolygonFillRule, type PolygonInput, type PolygonOperand, type PolygonPiece, type PolygonRing, type PolygonToPathOptions, type PolygonWithHoles, Position, type PositionChangeLike, RESIZE_HANDLES, type RecordAnimationOptions, Rect, type RectShape, ReflowDisplacementOptions, type RegularPolygonShape, type ResizeHandle, SHAPE_DATA_KEY, SHAPE_KINDS, SHAPE_NODE_TYPE, SHAPE_OPERATIONS, type SampleAnimationOptions, type ScaleKeyframesOptions, type SerializedCanvasScenes, type SetCanvasVariantPropertiesOptions, type SetKeyframeOptions, type ShapeDescription, type ShapeKind, type ShapeNodePolygonOptions, type ShapeOperation, type ShapePaint, type ShapePathEditOperation, type ShapePathEditRefusal, type ShapePathEditResult, type ShapeRenderData, type ShapeSize, Side, SizeDimension, type SnapGuidesOptions, type SnapNodeDragOptions, type SnapNodeDragResult, type SnapNodeResizeOptions, type SnapNodeResizeResult, type SnapResizeOptions, type SnapResizeResult, type SnapResult, type StarShape, StreamingLayoutManager, type StreamingLayoutManagerOptions, type StrokeCap, type StrokeJoin, type StrokeToShapeNodeOptions, type SvgGradientDef, type SvgGradientStop, TOKEN_BINDINGS_DATA_KEY, TOKEN_MODES_DATA_KEY, type TimelineKeyframe, type TimelineRow, type TimelineRowsOptions, TrajectoryFunction, type WebAnimationSpec, XYPosition, ZOrderOperation, addCanvasVariant, addKeyframesAtTime, angleToSvgLinearCoords, animateNode, applyAnimation, applyAnimationOverrides, applyConstraints, applyShapeCombination, applyShapeReplacement, arcToCubics, bezierPathArea, bezierPathBounds, bezierPathLength, bezierPathPointAtLength, bezierPathSignedArea, bezierPathToSvg, bindCanvasComponentProperty, bindCanvasToken, blendLayout, boundsOf, calculateDagreReflowDisplacement, calculateDirectionalDisplacement, canCombineShapeNodes, canOffsetShapeNodes, canOutlineShapeNodeStrokes, canvasHeight, centerNodes, centre, clampAnimationValue, clampLayoutSize, closeContour, collectDescendantIds, combineCanvasComponentsAsVariants, combineShapeNodes, computeNodesBoundingBox, computeSnapGuides, connectedOnly, contourSignedArea, contoursToPath, copyKeyframes, countPathSegments, createBezierTrajectory, createCanvasAnimationController, createCanvasArrangeController, createCanvasAutoLayoutController, createCanvasComponent, createCanvasComponentsController, createCanvasDrawController, createCanvasInstance, createCanvasScenesStore, createDefaultStrokeStyle, createFanOutTrajectory, createGuideIndex, createNodeGuideIndex, cubicPointAt, cubicsToPathData, dashContours, defaultEasing, deleteKeyframes, detachCanvasInstance, detachTokenBindings, diffOverrideGroups, distanceToBezierPath, dividePaths, dividePolygons, ensureLayout, estimateCanvasHeight, estimateNodeSize, evaluateAnimation, excludePaths, exportCssAnimation, findConnectorSnap, findStrokesAtPoint, findVariant, fitCubicRun, fitCubics, fitFreehandPath, fitPathData, fitViewportToNodes, fitViewportToRect, flattenSvgPath, flowSide, formatAnimationTime, formatNumber, formatVariantName, getAnimatableProperty, getAnimatedProperties, getAnimatedValue, getAnimationDuration, getAnimationTrack, getAutoLayout, getAutoLayoutGrid, getAutoLayoutInsertTarget, getBindableTokenProperties, getCanvasComponentDragId, getCanvasTokenProperty, getCenteredNodePosition, getChildLayout, getComponentData, getComponentInstances, getComponentPropertyDefs, getComponentPropertyRefs, getComponentSourceId, getCssPropertyAnimations, getDefaultVariant, getEffectiveTokenModes, getFlowChildren, getInstanceData, getInstanceProperties, getInstanceStatus, getKeyframeTimes, getLayerName, getLayoutParent, getLayoutSizing, getLayoutedNodes, getNextVariantValues, getNodeAnimation, getNodeOverrides, getNodeShape, getNodeTokenBindings, getNodeTokenModes, getOwningComponent, getOwningInstance, getResizingNodeRect, getRootInstance, getShapeRenderData, getShapeSvg, getTimelineRows, getTimelineTicks, getTokenPropertyScope, getTokensForProperty, getVariantConflicts, getVariantOptions, getVariantSet, getVariantValues, gradientToSvgDef, handlePoint, hasVisibleStroke, inferResizeHandle, inspectCanvasInstance, inspectNodeTokens, intersectPaths, intersectPolygons, isAutoLayoutFrame, isCanvasComponent, isCanvasComponentSet, isCanvasGradient, isCanvasInstance, isCssExportExact, isEventFromTextInput, isInsideInstance, isKeyframeSelected, isMeasureModifierHeld, isNodeAnimated, isShapeDescription, isShapeNode, isStraightCubic, isValidCanvasEdge, isValidCanvasNode, isValidCanvasScene, isValidUrl, layoutAll, layoutBounds, layoutFrame, layoutUp, layoutUpMany, linearPositionTrajectory, linearTrajectory, listCanvasComponents, makeSizingCoherent, measureBetween, measureLabel, measureSelection, measureToLine, mergeNodeUpdates, moveKeyframes, moveLayoutChild, multiPolygonArea, multiPolygonBounds, nearestHandlePositions, normalizeBezierPath, offsetPath, offsetShapeNodes, oppositePosition, outlineShapeNodeStrokes, outlineStroke, overlaps, parseCanvasClipboardData, parseCanvasScenes, parseCssGradient, parseKeyframeClipboard, parseNodeStyleDeclarations, parseSvgPath, parseVariantName, pasteKeyframes, pathBoolean, pathToContours, placeBeside, playWebAnimations, pointInBezierPath, pointInMultiPolygon, pointInRings, polygonArea, polygonBoolean, polygonToSvgPath, positionToSide, pruneCanvasTokenModes, pushCanvasInstanceOverrides, readAnimatableValue, readNodeStyleProperty, readOverrideGroup, recordAnimationChanges, relayoutUpdates, remapPastedNodes, removeCanvasVariant, removeTrack, renameCanvasVariantProperty, renameCanvasVariantValue, repositionNodesTo, resetCanvasInstanceOverrides, resizeHandleAxes, resolveCanvasGradient, resolveCanvasTokens, resolvePadding, restoreCanvasMainComponent, revertShapeCombination, ringSignedArea, runMultiNodeTransition, sampleAnimationFrames, scaleKeyframes, segmentBounds, segmentCurvature, segmentDerivative, segmentExtrema, segmentLength, segmentNearest, segmentParamAtLength, segmentPoint, segmentTangent, serializeCanvasNodes, setCanvasComponentProperty, setCanvasInstanceProperties, setCanvasTokenMode, setCanvasVariantProperties, setKeyframe, setKeyframeEasing, setMotionPath, setTrackEnabled, shapeNodeToBezierPath, shapeNodeToPolygon, shapeToBezierPath, shapeToPolygon, sideToPosition, simplifyRing, snapKeyframeDelta, snapNodeDrag, snapNodeResize, snapResize, snapTimeToFrame, snapToGrid, splitSegment, streamlinePoints, strokeBoundingBox, strokeOutlineRings, strokePointsToPathData, strokeToShapeNode, subSegment, subtractPaths, subtractPolygons, swapCanvasInstance, syncAllCanvasInstances, syncCanvasComponents, syncCanvasInstance, timeToX, toBezierPath, toWebAnimations, transformBezierPath, trimSegments, unionPolygons, unitePaths, updateKeyframe, windingNumber, withNodeAnimation, withStyleOpacity, wouldCreateComponentCycle, writeNodeStyleProperty, writeOverrideGroup, xToTime, xorPolygons };
|