Skip to main content

HitShape

Enum HitShape 

Source
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.

Fields

§first: u32
§len: u32
§width: f32
§

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.

Fields

§first: u32
§len: u32
§

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.

Fields

§first: u32
§len: u32
§stroke: f32

Trait Implementations§

Source§

impl Clone for HitShape

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for HitShape

Source§

impl Debug for HitShape

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for HitShape

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for HitShape

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.