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_rectfrom fixed-size decorations: a pin stub reaches oneGRID_SIZEout, 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 Boundedfor 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::boundsfor a shape sitting at a hypotheticalrect— where a drag or resize is previewing it — so a previewed footprint is measured by the same rule as a settled one.