Skip to main content

snap_drag_offset

Function snap_drag_offset 

Source
pub fn snap_drag_offset(
    data: &Drawing<'_>,
    dragged: &[ShapeId],
    raw_offset: Vec2,
) -> Vec2
Expand description

Magnetic alignment for a freely-positioned image/icon drag: adjust raw_offset so a dragged feature snaps exactly onto a nearby static feature of the same kind/axis (within SNAP_RADIUS), per axis independently — so a drag can snap horizontally, vertically, or both. Returns raw_offset unchanged where nothing is near. The static set is every other shape (plus areas), matching shape_drag_guides, so a snap always coincides with a drawn guide.