pub enum HitShape {
Rect,
Rounded([f32; 4]),
Segments {
first: u32,
len: u32,
width: f32,
},
Polygon {
first: u32,
len: u32,
},
}Expand description
The shape inside a region’s rect that a point has to be in to hit it
(docs/adr/0026-hit-testing-by-shape.md). 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 ADR
priced the twenty bytes at +7% on a 10k-region frame and measured
nothing, 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.
Trait Implementations§
impl Copy for HitShape
impl StructuralPartialEq for HitShape
Auto Trait Implementations§
impl Freeze for HitShape
impl RefUnwindSafe for HitShape
impl Send for HitShape
impl Sync for HitShape
impl Unpin for HitShape
impl UnsafeUnpin for HitShape
impl UnwindSafe for HitShape
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.