Skip to content

Feat(canvas): Add Lasso Tool with Freehand and Polygon modes#8908

Open
DustyShoe wants to merge 5 commits intoinvoke-ai:mainfrom
DustyShoe:Feat(Canvas)/Add-Lasso-tool-with-Freehand-and-Polygon-modes
Open

Feat(canvas): Add Lasso Tool with Freehand and Polygon modes#8908
DustyShoe wants to merge 5 commits intoinvoke-ai:mainfrom
DustyShoe:Feat(Canvas)/Add-Lasso-tool-with-Freehand-and-Polygon-modes

Conversation

@DustyShoe
Copy link
Collaborator

@DustyShoe DustyShoe commented Feb 24, 2026

Summary

  • Added a new Lasso canvas tool with two modes: Freehand and Polygon.
  • Added lasso tool button to the left toolbar (under Text) and mode switcher in the top options bar.
  • Added lasso object type/state plumbing end-to-end:
    • new object state/type in canvas store
    • renderer support in object renderer/buffer renderer
    • addLasso API action + reducer path
  • Implemented freehand behavior:
    • starts on primary pointer down
    • records contour continuously (including outside canvas bounds)
    • closes contour and commits on pointer up
  • Implemented polygon behavior:
    • works on click (no Shift required to place points)
    • closes by clicking near the start point
    • start point is visible; hover over it enlarges indicator for close feedback
    • Shift enables angle snapping (45°) and start-point alignment behavior
  • Preserved canvas UX rules:
    • middle click remains pan
    • right click remains context menu (not used by polygon lasso)
  • Implemented Space-pan integration for active freehand session:
    • session is not canceled
    • contour remains visible while panning
    • cursor/canvas-relative behavior preserved when resuming drawing
  • Subtract mode changed from Alt to modifier-based lasso compositing:
    • now uses Ctrl/Cmd (Meta) for destination-out (mac-safe)
  • Added lasso availability guards:
    • disabled when there is no visible raster content
    • disabled when inpaint masks are globally hidden
    • if selected inpaint mask is disabled, commit goes to a newly created mask
  • Fixed inpaint mask hidden-state edge cases:
    • reset hidden flag when mask collection becomes empty
    • corrected “all non-raster hidden” effective-state logic for empty categories
  • Improved bbox correctness for erase/subtract shapes:
    • pixel-bbox path now accounts for pressure eraser and subtractive lasso objects
  • Added hotkey L and related locale entries.
  • Per agreement, no extra tooltip/hint UI was added in this PR.

QA Instructions

  • Select lasso via toolbar and via L hotkey.
  • Verify mode toggle (Freehand / Polygon) in top options bar.
  • Freehand: draw and release -> contour closes and commits.
  • Freehand: draw fast + outside canvas bounds -> stroke continues and commits.
  • Freehand + Space: while pointer is still down, press/hold Space -> pan works immediately, contour stays visible, release Space -> continue drawing.
  • Polygon: click to place points without Shift.
  • Polygon: click start point to close contour.
  • Polygon: start-point indicator is visible and enlarges on hover.
  • Polygon + Shift: 45° snap works while placing segment.
  • Middle click still pans canvas; right click still opens context menu.
  • Subtract compositing works with Ctrl (Win/Linux) and Cmd (macOS).
  • If no inpaint mask exists, first lasso commit creates a new inpaint mask.
  • If selected mask is disabled, lasso commit creates/uses a new enabled mask.
  • Lasso is blocked when all inpaint masks are globally hidden.
  • Lasso is blocked when no visible raster layers with objects exist.
  • Delete all mask layers after masks were hidden -> hidden state resets (tool no longer stuck disabled by stale flag).

Merge Plan

Simple merge.

Checklist

  • The PR has a short but descriptive title, suitable for a changelog
  • Tests added / updated (if applicable)
  • ❗Changes to a redux slice have a corresponding migration
  • Documentation added / updated (if applicable)
  • Updated What's New copy (if doing a release after this PR)

@github-actions github-actions bot added the frontend PRs that change frontend files label Feb 24, 2026
@lstein lstein assigned lstein and dunkeroni and unassigned lstein Feb 27, 2026
@lstein lstein added the v6.13.x label Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend PRs that change frontend files v6.13.x

Projects

Status: 6.13.x

Development

Successfully merging this pull request may close these issues.

3 participants