Expand description
Alignment guides shown while dragging. A dragged element’s features (edges, centers, pin stubs, or a single corner) are matched against the same features of every other shape; each like-kind coincidence draws a thin line spanning the aligned pair, drawn over the diagram so a center guide (which runs through the opaque shapes it aligns) stays visible.
Grid-quantized shapes (blocks, areas) coincide at discrete grid steps, so
their guides are stable. Free-positioned images/icons don’t, so
snap_drag_offset makes their drag magnetic — snapping a center onto a
nearby feature so the guide lands instead of merely flashing past.
Structs§
Enums§
Constants§
- EPS 🔒
- Coordinates within this many world units count as aligned when drawing a guide (only absorbs float error — grid shapes coincide exactly).
- SNAP_
RADIUS - How near (world units) a freely-dragged image/icon feature must be to a static
feature for
snap_drag_offsetto pull it into exact alignment.
Functions§
- build_
statics 🔒 - The resting alignment features of every shape (plus areas) except those
is_excluded— the static set a drag or resize matches its moving features against. - draw_
guides - Draw the computed guide segments. Call this after the scene so a center guide — which runs through the opaque shapes it aligns — stays visible.
- match_
guides 🔒 - pin_
drag_ guides - Guides for a pin drag: each previewed pin — the same
PinMovethe commit will carry — matches against every other pin stub exceptexclude. - push_
pin_ 🔒rows - Each pin’s stub row: a horizontal guide at the stub’s y, shifted by
offset. Only the row is offered — a pin sits at a fixed offset from the edge it attaches to, so its x is not a meaningful alignment feature (the edge is); its y lets pins on different blocks line up. Works for block pins and the port pin. - push_
point_ 🔒candidates - A single point contributes one vertical and one horizontal guide candidate.
- push_
rect_ 🔒candidates - push_
rect_ 🔒edges - A rect’s four edge candidates (the left/right verticals, top/bottom horizontals) — no centers.
- resize_
guides - Alignment guides for a resize: the shape’s features at its previewed
resizedrect, matched against every other shape’s resting features. A resize doesn’t translate the shape, so it can’t reuseshape_drag_guides’soffsetpath. - resized_
candidates 🔒 - The features a shape at
rectcontributes while being resized: rect shapes (blocks, areas) offer edges + centers; images/icons offer edges (the ones the resize magnetism snaps — seesnap_resize_corner); ports offer their tip/back columns. Text boxes aren’t resizable. - shape_
candidates 🔒 - The features a shape contributes. Blocks: edges, centers, and pin rows.
Ports: the pin row plus two verticals at the pentagon’s tip and flat back.
Areas: edges and centers. Text boxes: only the top-left corner (their box
is normally hidden). Images/icons: only the center, so they align
center-to-center (an icon to its containing block’s center).
offsetpreviews a drag (zero for a resting shape). - shape_
drag_ guides - Guides for a shape (or group) drag: the dragged shapes — previewed at
offset— contribute their features; every other shape (including areas) contributes the same at its resting position. - snap_
drag_ offset - Magnetic alignment for a freely-positioned image/icon drag: adjust
raw_offsetso a dragged feature snaps exactly onto a nearby static feature of the same kind/axis (withinSNAP_RADIUS), per axis independently — so a drag can snap horizontally, vertically, or both. Returnsraw_offsetunchanged where nothing is near. The static set is every other shape (plus areas), matchingshape_drag_guides, so a snap always coincides with a drawn guide. - snap_
resize_ corner - Snap a resize’s dragged
cornerto a nearby static edge — its x to the nearest static vertical edge, its y to the nearest static horizontal edge, each withinSNAP_RADIUSand independently — so a free image/icon edge lines up as a move would.excludeis the shape being resized (its own edges aren’t targets). Returns the corrected corner.