Skip to main content

Module bounds

Module bounds 

Source
Expand description

Coarse, Painter-free world-space bounds for broad-phase spatial queries.

Bounded::bounds returns a box enclosing an object’s whole painted and hittable footprint — including stub and label overhang — computed from pure geometry plus a character-count text-width estimate. It never lays out a galley, so it is cheap enough to compute for every object each time the SpatialIndex is rebuilt. The shared index (viewport culling + hit-testing) queries these bounds; the exact fine-phase tests then decide the actual hit, so bounds only has to not under-cover — a slightly generous box costs a few extra candidates, an under-sized one would drop a real hit.

Constants§

CHAR_ADVANCE 🔒
Conservative upper bound on a proportional glyph’s advance as a fraction of the font size — lets a label’s width be estimated from its character count without a galley. Biased high so the estimate never under-covers a real label.
QUERY_MARGIN
How far a shape’s footprint can extend past its gui_rect from fixed-size decorations: a pin stub reaches one GRID_SIZE out, and the widest point-snap margin (ROUTE_HIT_MARGIN, ~0.9 grid) plus the tag rise sit within two cells. Query rects are expanded by this before testing, and every indexed bound already includes it.

Traits§

Bounded
A world-space bounding box enclosing an object’s whole painted/hittable footprint, for broad-phase spatial queries. See the module docs.

Functions§

estimate_text_width 🔒
route_bounds
Bounded for a route: its painted footprint needs the solved geometry, which lives beside the document, so it can’t be a method on either half alone.
shape_bounds_at
Bounded::bounds for a shape sitting at a hypothetical rect — where a drag or resize is previewing it — so a previewed footprint is measured by the same rule as a settled one.