Skip to content

Fix #798: the Curvature tool edits any selected path - #891

Merged
bflatastic merged 1 commit into
mainfrom
fix/798-curvature-any-path
Oct 10, 2026
Merged

bflatastic merged 1 commit into
mainfrom
fix/798-curvature-any-path

Conversation

@bflatastic

Copy link
Copy Markdown
Member

Fixes #798.

The Curvature tool only edited the path it was drawing. It now works on any selected path, whatever drew it, and changes nothing outside the edit:

  • Select and drag a point: a click makes it the current point (direct-selected, filled, with its handles). A drag moves it, with snapping, and only its two segments change: a smooth point turns along the line through its neighbours, the neighbours keep their handle directions (lengths scaled to the chord), a corner keeps its handles. Segments further away are bit-identical.
  • Toggle and delete: Alt-click or double-click toggles smooth/corner (path.convertAnchor); Delete/Backspace removes the current point (path.removeAnchor). The tool now claims Delete while it has a point to remove: before, Delete removed the whole path even while drawing.
  • Add a point: a click on a segment adds a smooth point with an exact split, so the shape doesn't change; dragging at once moves it in the same undo step.
  • Continue and close: while the current point is an end of an open path, clicks extend it (the old segments keep their shape; Alt places a corner); a click on the other end closes it. Esc/Enter drops the current point. New paths are drawn as before.
  • Cursors for close, continue, add, convert and move; a rubber band while continuing.

New command: path.curvatureEdit {id, subpath?, op: "move"|"insert"|"extend"|"close", anchor?, segment?, t?, end?, from?, x?, y?}, one undo step, every parameter checked, so agents can make the same edits (docs/mcp.md › Editing a path with the Curvature tool). editable_paths moved from the Pen to draw2 so both tools share it.

Tested:

  • cargo xtask ci (all 7 steps), on its own and stacked with PNG export: anti-aliased edges of semi-transparent art come out at alpha 254 over an opaque background, so the file is written as RGBA #787.
  • 11 tool and geometry tests in curvature.rs (moved points leave other segments bit-identical; continuing and closing keep old segments; inserting keeps the shape), an engine test that each edit on a Pen path is one undo step, and junk-parameter cases in command_sweep.rs.
  • Live: a 5-point Pen path, dragged anchor 2 with the Curvature tool: anchors 0, 3 and 4 unchanged, anchor 1's out handle in the same direction; one "Curvature" history step. Continuing from the end, adding a point on a segment, Delete and double-click each made one step.

🤖 Generated with Claude Code

The Curvature tool only edited the path it was drawing. It now edits any
selected path, whatever drew it, keeping its shape except where edited:
a click on a point makes it the current (direct-selected) point and a
drag moves it, re-curving only its two segments (the neighbours keep
their handle directions); Alt-click or double-click toggles it smooth or
corner and Delete removes it; a click on a segment adds a smooth point
without changing the shape, and a drag moves it in the same undo step.
With an end of an open path current, clicks go on from it (the old
segments keep their shape) and a click on the other end closes it.

The edits go through a new path.curvatureEdit command (move, insert,
extend, close), path.convertAnchor and path.removeAnchor, one undo step
each. The tool now claims Delete/Backspace while it has a point to
remove, so the key no longer deletes the whole path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to continue drawing on the same path as curvature tool, or click the curve points to edit afterwards

1 participant