pub enum HitShape {
Rect,
Rounded([f32; 4]),
Segments {
first: u32,
len: u32,
width: f32,
},
Polygon {
first: u32,
len: u32,
},
Path {
first: u32,
len: u32,
rule: FillRule,
stroke: f32,
},
}Expand description
The shape inside a region’s rect that a point has to be in to hit it. The rect is always tested first, so a shape is evaluated only for the few regions under the pointer. Inline on the region rather than behind an index: the twenty bytes measured nothing on a 10k-region frame, so the simpler shape won. Points for a stroke or a fill live in the interaction’s own list, relative to the region’s top-left in logical px, copied at emission because the frame’s stores do not outlive the frame and a press does.
Variants§
Rect
The whole rect — every box, and what every region was before.
Rounded([f32; 4])
A box with rounded corners: a point in a corner’s square but past
its arc misses. Radii clockwise from the top-left, logical px,
as the node’s radius row.
Segments
A round-capped stroke through len points from first, width
wide: a point within half the width of any piece hits. A hairline
is hard to hit, so the grab is at least MIN_STROKE_GRAB wide.
Polygon
A filled outline through len points from first: a point inside
by the even-odd rule hits — the same rule the stock polygon paints
by, so the hit is the fill exactly, a self-intersecting outline’s
unfilled overlaps included.
Path
A path’s flattened outline: len points from first, closed
contours each followed by crate::path::CONTOUR_BREAK, hit by the
fill rule it paints with (crate::path::in_path) — and, where a
stroke is painted over the fill, by the stroke too: stroke is
its width, 0 for none, and a point within half of it of any piece
hits, so the half of a thick stroke outside the fill is not dead.