Skip to content

[Feature] Editable vertex in shapes and polygon recognition #214

Description

@marcocebrian

Summary

Make shapes first-class, editable geometry, not just bounding-box primitives.

  1. Every recognized or drawn polygon/shape should expose editable vertices (drag, add, delete).
  2. Freehand strokes should support polygon / shape recognition (triangle, rectangle, diamond, ellipse, n-gon, closed irregular polygon).
  3. Auto-detected closed shapes must be fillable, including semi-transparent color (alpha independent of stroke).

This should work on the same canvas as notes and tables, so a table, a labeled polygon, and a filled region can live on one page.

Proposed behavior

1. Editable vertices

When a closed or open path/shape is selected:

  • Show vertex handles at every point.
  • Drag a vertex to move it.
  • Click on an edge (or double-click) to insert a vertex.
  • Delete / Alt-click / backspace a selected vertex to remove it (min 3 points for a filled polygon).
  • Optional: mid-edge “add point” handles, like vector editors.
  • Snapping: vertex-to-vertex, vertex-to-grid, vertex-to-table cell edges / guides if tables exist on the canvas.
  • Undo/redo each vertex mutation as one history step.

2. Polygon / shape recognition

On stroke end (or via an explicit “Recognize” action / toggle):

Detect, in order of preference:

  • line
  • rectangle / rounded rect / square
  • ellipse / circle
  • triangle, diamond, regular n-gon (5–8)
  • closed irregular polygon (simplified polyline, Ramer–Douglas–Peucker or similar)
  • arrow (optional)

UX:

  • Hold a modifier (e.g. Shift) or use a “Snap to shape” toggle so recognition is opt-in, not forced.
  • After snap, keep the recognized geometry as a path with vertices, not a locked primitive — user can immediately pull a corner.
  • Confidence threshold: if the stroke is not close enough, leave ink as-is.
  • Recognize both freehand ink and multi-segment polylines.

3. Fill + transparency on auto-detected shapes

Any closed recognized path must support:

  • Fill color (palette + custom hex)
  • Fill opacity 0–100%, separate from stroke opacity if possible
  • Stroke color / width unchanged when fill changes
  • Fill rule: even-odd for self-intersecting polygons
  • Tables / text under the shape remain readable at ~15–40% fill (this is the main use case)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions