Fix #482: Smart Guides land resize handles on anchors and snap the transform tools' drags

Bounding-box resizes with the Selection and Free Transform tools already lined
their edges up with the other objects (#355, after v0.4.0), but a handle never
landed on another object's anchor point, nothing was labelled, and the Rotate,
Scale, Shear and Reflect tools didn't snap their drags at all.

- Targets::snap_scale: the dragged corner (free, or along its diagonal with
  Shift) or side lands on the nearest anchor or centre within the snapping
  tolerance, labelled "anchor"/"center"; alignment snaps keep their line and
  now say "align", as an artboard's resize handle does. Alt (from the centre)
  and rotated boxes work the same way.
- The transform tools start a drag from the anchor or centre they grabbed (the
  point a click would set) and snap the pointer as drawing tools do (Smart
  Guides, the grid, pixels or Snap to Point), so a corner dragged onto another
  object's anchor scales exactly onto it.
- Factor the nearest anchor/centre lookup (Targets::nearest_point) and the
  transform tools' drag teardown (end_drag).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
bflatastic
2026-10-08 20:21:31 +07:00
co-authored by Claude Opus 5.5
parent 70b1bbf679
commit f7c88af1de
4 changed files with 166 additions and 40 deletions
+10
View File
@@ -1202,6 +1202,16 @@ point lands:
a dragged selection, a bounding-box handle, a ruler guide or an artboard. With Smart Guides off, Snap to Point uses
`snapToPointTolerance` instead.
With Smart Guides on, a bounding-box handle dragged with the Selection or Free Transform tool (`mods.shift`
proportional, `mods.alt` from the centre) lands on another object's anchor or centre (labelled "anchor" or
"center"), else its corners and side line up with the edges and centres of the other objects and the artboards (a
line and "align"). The Rotate, Scale, Shear and Reflect tools start a drag from the anchor or centre they grab and
snap the pointer as drawing tools do, so dragging a corner onto another object's anchor scales exactly onto it:
```json
{"name":"pointer_gesture","arguments":{"tool":"scale","events":[{"kind":"down","x":100,"y":100},{"kind":"up","x":100,"y":100},{"kind":"down","x":199,"y":198},{"kind":"drag","x":302,"y":262},{"kind":"up","x":302,"y":262}]}}
```
Not read yet: Construction Guides and their Angles, and Spacing Guides (the tools draw neither).
## Type preferences