path_editor 0.1.0-alpha.1
path_editor: ^0.1.0-alpha.1 copied to clipboard
A Flutter widget for visually editing vector paths, with a configurable Figma style pen tool.
0.1.0-alpha.1 #
A rewrite of the editing model and the public API, adding a full pen tool. See the migration table in the README for the 0.0.x equivalents.
Added #
- Pen tool: click to place corner points, click and drag to pull out Bézier handles, click a segment to insert a point, click the first point to close the path.
- Node centric model:
PathNodeowns the two handles around it, so handles can be linked (mirrored,aligned), broken (disconnected) or absent (corner), and nodes convert between those at any time. - Multiple selection, with shift-click toggling and dragging the whole selection.
- Two ways to remove a point:
NodeRemoval.preserveShaperefits the surrounding curve so the shape survives,NodeRemoval.cutbreaks the path. Cuts that would leave more than one open subpath are refused. - Snapping to nodes, segment midpoints and alignment axes, with visual guides, an angle constraint and a modifier to suppress it.
PathEditorThemeDataand thePathEditorThemeinherited widget, with light and dark presets,copyWithandlerp.- A bend interaction: holding
PathEditorModifiers.bendPoint(command on macOS, control elsewhere) drags the curvature out of an existing point instead of moving it, converting a corner point into a smooth one, the way the bend tool works in design tools like Figma. PathEditorBehavior.allowMultipleSubpaths, which stops the pen tool from starting a second disconnected subpath for editors that must produce a single continuous path.PathEditorCursorsfor every contextual state,PathEditorModifiersfor every modifier key,PathEditorShortcutsbuilt on Flutter'sShortcuts/Actions,PathEditorSnappingandPathEditorBehavior.PathEditorViewportwith pan and zoom; hit radii and editing chrome keep a constant size on screen at any zoom level.- Editing callbacks, including
onSegmentCreatedfor opening a stroke panel as the first segment appears. - Transactions (
controller.transaction), so a whole gesture is one undo step, and undo restores the selection it was made with. - Keyboard support: delete, cut, close, finish, select all, nudge, undo, redo and tool switching.
Changed #
- Breaking:
PathEditorControlleris now aChangeNotifierowning the path, the selection and the active tool, built withPathEditorController.fromSvg,.fromPathor.empty. It exposespathListenable,selectionListenableandtoolListenable. - Breaking:
PathPointIndex,PathSegmentIndexandControlPointIndexare replaced byNodeRef,SegmentRefandHandleRef, which address subpaths correctly. - Breaking: the flat styling parameters of
PathEditorare replaced by the configuration objects listed above, andrenderOffsetbyviewport. - Breaking: the default stroke width is now
1(was2) and the active segment highlight is#4E80F9(wasColors.blue). - Inserting a point on a curved segment now splits the curve with de Casteljau's algorithm instead of inserting a straight line, so the shape is unchanged.
- Bounding boxes are computed from exact curve extrema rather than by sampling,
so
BoundsCheckAccuracyis gone. - The editor paints through a single layered painter inside a repaint boundary,
and rebuilds through granular listenables instead of
setStateon every pointer move.
Removed #
- Breaking:
PathHolder,beginUpdate/endUpdate,insertPoint,updatePointPosition,updateControlPointPosition,controlPointsAt,calculateBoundingBox,calculateBoundingBoxOfPathandBoundsCheckAccuracy.
0.0.3 #
- Add bounds calculation
- Add undo redo system
0.0.2 #
- Updates to pubspec
- Live demo with wasm support
0.0.1 #
- Initial version