Skip to content

feat: add shift key constraint for drawing straight lines#6

Merged
moritzsalla merged 2 commits into
mainfrom
feat/shift-key-straight-lines
Sep 8, 2025
Merged

feat: add shift key constraint for drawing straight lines#6
moritzsalla merged 2 commits into
mainfrom
feat/shift-key-straight-lines

Conversation

@moritzsalla
Copy link
Copy Markdown
Owner

Summary

  • Hold Shift while drawing to constrain points to horizontal, vertical, or 45° diagonal lines
  • Smart direction detection automatically chooses the best straight line based on mouse movement
  • Real-time visual feedback shows the constrained position in hover preview
  • Seamlessly integrates with existing drawing, undo/redo, and transform systems

Technical Implementation

  • Line constraint algorithm: Analyzes mouse movement to determine optimal straight line direction
  • Real-time visual feedback: Hover point snaps to constrained position when Shift is held
  • Last point tracking: Uses useRef to remember the most recent point for constraint calculations
  • Event integration: Works with both click and drag drawing modes

Test Plan

  • Build passes without TypeScript errors
  • Feature works in draw mode with Shift key
  • Hover preview shows constrained position
  • Integration with existing undo/redo system
  • Compatibility with zoom/pan transforms

@vercel
Copy link
Copy Markdown

vercel Bot commented Sep 8, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
polytess Ready Ready Preview Comment Sep 8, 2025 10:28pm

- Hold Shift while drawing to constrain points to horizontal, vertical, or 45° diagonal lines
- Smart direction detection automatically chooses best straight line based on mouse movement
- Real-time visual feedback shows constrained position in hover preview
- Integrates seamlessly with existing drawing, undo/redo, and transform systems
- Tracks last drawn point for accurate line constraint calculations
- Show dashed line preview from last point to mouse cursor when shift is held
- Remove angle constraints - allow exact straight lines like Photoshop
- Add real-time shift key state tracking for smooth visual feedback
- Line preview only appears when shift is actively pressed
@moritzsalla moritzsalla merged commit 12f9e66 into main Sep 8, 2025
3 checks passed
@moritzsalla moritzsalla deleted the feat/shift-key-straight-lines branch September 8, 2025 22:31
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.

1 participant