Skip to content

feat(vector): add Vector Model, Pen Tool, Direct Selection, and path operations - #115

Open
kaivyy wants to merge 9 commits into
robbietilton:mainfrom
kaivyy:feature/vector-pen-sync
Open

kaivyy wants to merge 9 commits into
robbietilton:mainfrom
kaivyy:feature/vector-pen-sync

Conversation

@kaivyy

@kaivyy kaivyy commented Sep 24, 2026

Copy link
Copy Markdown

Summary

Adds native vector path foundation, Pen Tool path creation, Direct Selection path editing, and vector path operations (Make Selection, Fill Path, Stroke Path) to Compositor.

Features & Capabilities

  • Vector Model Foundation:

    • VectorModel, VectorSubpath, VectorPoint, VectorFill, VectorStroke data models with Codable persistence.
    • Path geometry bridge to CGPath supporting line segments, cubic Bézier curves, open/closed subpaths, and hit testing.
    • High-fidelity stroke and fill rasterization via VectorRenderer.
  • Pen Tool (P):

    • Interactive path creation with point clicks and Bézier handle drags.
    • Continuation from existing open vector path endpoints.
    • Closing path detection with interactive click-and-drag Bézier handle shaping at the closing anchor.
    • Escape / Enter to commit or finish pen drafts; Undo/Redo support during active drafting.
    • Transparent raster layer backing: path anchors and curves remain visible without unintended fills.
  • Direct Selection Tool (A):

    • Subpath and anchor hit testing in document coordinates.
    • Multiple anchor selection (Shift-click, drag selection).
    • Bézier handle manipulation (smooth symmetric dragging, split handles with Option).
    • Selected anchor deletion with geometry preservation of remaining subpath components.
    • Full Undo/Redo integration for anchor moves, handle adjustments, and anchor deletions.
  • Path Operations & Context Menu:

    • Right-click canvas context menu for active vector layers and pen drafts:
      • Make Selection: Converts the vector path to an active document selection marquee.
      • Fill Path: Fills the closed vector region with the current foreground color into the layer's raster asset.
      • Stroke Path: Strokes the vector path with the current stroke width, line cap, line join, and foreground color directly into the layer's raster asset with CoreGraphics stroke fidelity and selection mask clipping.

Architectural Impact

  • Extends Layer with optional vector: VectorModel? property, persisted non-destructively alongside raster assets in .compositor packages.
  • Integrates TransformOverlay for rendering interactive vector paths, anchor points, Bézier handles, and live preview segments.
  • Contextual routing in EditorCanvas for tool switching, secondary-click menus, and keyboard shortcuts (Delete, Escape, Return).
  • All path modifications are wrapped in discrete EditorSession history transactions preserving non-destructive document undo/redo.

Dependencies

Test Coverage

  • CompositorTests/PenToolTests.swift: 61/61 tests pass.
  • CompositorTests/DirectSelectionTests.swift: 33/33 tests pass.
  • CompositorTests/VectorPathTests.swift: All subpath and geometry tests pass.
  • CompositorTests/HistoryTests.swift: All history transaction tests pass.
  • CompositorTests/LayerTests.swift: All layer and context menu tests pass.
  • CompositorTests/ProjectTests.swift: Round-trip persistence tests pass.

Known Pre-existing Issue: SliderSnapTests fails due to a pre-existing upstream slider knob coordinate expectation unrelated to vector tools.

Manual Verification

  • Pen Tool point placement, drag curvature, closing click-drag, and endpoint continuation verified.
  • Direct Selection anchor selection, handle manipulation, and anchor deletion verified.
  • Make Selection, Fill Path, and Stroke Path verified visually and functionally.
  • Undo/redo verified across all editing phases.
  • Build and execution verified on macOS.

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.

2 participants