Struct freya_engine::prelude::Rect

#[repr(C)]
pub struct Rect { pub left: f32, pub top: f32, pub right: f32, pub bottom: f32, }

Fields§

§left: f32

The x coordinate of the rectangle’s left edge.

§top: f32

The y coordinate of the rectangle’s top edge.

§right: f32

The x coordinate of the rectangle’s right edge.

§bottom: f32

The y coordinate of the rectangle’s bottom edge.

Implementations§

§

impl Rect

pub fn new(left: f32, top: f32, right: f32, bottom: f32) -> Rect

pub fn new_empty() -> Rect

pub fn from_wh(w: f32, h: f32) -> Rect

pub fn from_iwh(w: i32, h: i32) -> Rect

pub fn from_size(size: impl Into<Size>) -> Rect

pub fn from_ltrb(l: f32, t: f32, b: f32, r: f32) -> Rect

pub fn from_xywh(x: f32, y: f32, w: f32, h: f32) -> Rect

pub fn from_point_and_size(p: impl Into<Point>, sz: impl Into<Size>) -> Rect

pub fn from_isize(isize: impl Into<ISize>) -> Rect

pub fn from_irect(irect: impl AsRef<IRect>) -> Rect

pub fn is_empty(&self) -> bool

pub fn is_sorted(&self) -> bool

pub fn is_finite(&self) -> bool

pub const fn x(&self) -> f32

pub const fn y(&self) -> f32

pub const fn left(&self) -> f32

pub const fn top(&self) -> f32

pub const fn right(&self) -> f32

pub const fn bottom(&self) -> f32

pub fn size(&self) -> Size

pub fn width(&self) -> f32

pub fn height(&self) -> f32

pub fn center_x(&self) -> f32

pub fn center_y(&self) -> f32

pub fn center(&self) -> Point

pub fn to_quad(self) -> [Point; 4]

pub fn set_empty(&mut self)

pub fn set_irect(&mut self, irect: impl AsRef<IRect>)

pub fn set_ltrb(&mut self, left: f32, top: f32, right: f32, bottom: f32)

pub fn set_bounds(&mut self, points: &[Point])

pub fn set_bounds_check(&mut self, points: &[Point]) -> bool

pub fn set_bounds_no_check(&mut self, points: &[Point])

pub fn set_bounds2(&mut self, p0: impl Into<Point>, p1: impl Into<Point>)

pub fn from_bounds(points: &[Point]) -> Option<Rect>

pub fn set_xywh(&mut self, x: f32, y: f32, width: f32, height: f32)

pub fn set_wh(&mut self, w: f32, h: f32)

pub fn set_iwh(&mut self, width: i32, height: i32)

pub fn with_offset(&self, d: impl Into<Point>) -> Rect

pub fn with_inset(&self, d: impl Into<Point>) -> Rect

pub fn with_outset(&self, d: impl Into<Point>) -> Rect

pub fn offset(&mut self, d: impl Into<Point>)

pub fn offset_to(&mut self, new_p: impl Into<Point>)

pub fn with_offset_to(&self, new_p: impl Into<Point>) -> Rect

pub fn inset(&mut self, d: impl Into<Point>)

pub fn outset(&mut self, d: impl Into<Point>)

pub fn intersect(&mut self, r: impl AsRef<Rect>) -> bool

pub fn intersect2(&mut self, a: impl AsRef<Rect>, b: impl AsRef<Rect>) -> bool

pub fn intersects(&self, r: impl AsRef<Rect>) -> bool

pub fn intersects2(a: impl AsRef<Rect>, b: impl AsRef<Rect>) -> bool

pub fn join(&mut self, r: impl AsRef<Rect>)

pub fn join2(a: impl AsRef<Rect>, b: impl AsRef<Rect>) -> Rect

pub fn join_non_empty_arg(&mut self, r: impl AsRef<Rect>)

pub fn join_possibly_empty_rect(&mut self, r: impl AsRef<Rect>)

pub fn round(&self) -> IRect

pub fn round_in(&self) -> IRect

pub fn sort(&mut self)

pub fn sorted(&self) -> Rect

pub fn as_scalars(&self) -> &[f32; 4]

pub fn dump(&self, as_hex: impl Into<Option<bool>>)

pub fn dump_hex(&self)

Trait Implementations§

§

impl AsRef<Rect> for Rect

§

fn as_ref(&self) -> &Rect

Converts this type into a shared reference of the (usually inferred) input type.
§

impl Clone for Rect

§

fn clone(&self) -> Rect

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
§

impl Contains<&IRect> for Rect

§

fn contains(&self, r: &IRect) -> bool

§

impl Contains<&Point> for Rect

§

fn contains(&self, p: &Point) -> bool

§

impl Contains<&Rect> for IRect

§

fn contains(&self, other: &Rect) -> bool

§

impl Contains<&Rect> for Rect

§

fn contains(&self, r: &Rect) -> bool

§

impl Contains<IRect> for Rect

§

fn contains(&self, r: IRect) -> bool

§

impl Contains<Point> for Rect

§

fn contains(&self, p: Point) -> bool

§

impl Contains<Rect> for IRect

§

fn contains(&self, other: Rect) -> bool

§

impl Contains<Rect> for Rect

§

fn contains(&self, r: Rect) -> bool

§

impl Debug for Rect

§

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

Formats the value using the given formatter. Read more
§

impl Default for Rect

§

fn default() -> Rect

Returns the “default value” for a type. Read more
§

impl From<(Point, Size)> for Rect

§

fn from(_: (Point, Size)) -> Rect

Converts to this type from the input type.
§

impl From<IRect> for Rect

§

fn from(irect: IRect) -> Rect

Converts to this type from the input type.
§

impl From<ISize> for Rect

§

fn from(isize: ISize) -> Rect

Converts to this type from the input type.
§

impl PartialEq for Rect

§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl QuickReject<Rect> for Canvas

§

fn quick_reject(&self, rect: &Rect) -> bool

Returns true if Rect rect, transformed by Matrix, can be quickly determined to be outside of clip. May return false even though rect is outside of clip.

Use to check if an area to be drawn is clipped out, to skip subsequent draw calls.

  • rect Rect to compare with clip Returns true if rect, transformed by Matrix, does not intersect clip

example: https://fiddle.skia.org/c/@Canvas_quickReject

§

impl RoundOut<IRect> for Rect

§

fn round_out(&self) -> IRect

§

impl RoundOut<Rect> for Rect

§

fn round_out(&self) -> Rect

§

impl Copy for Rect

§

impl StructuralPartialEq for Rect

Auto Trait Implementations§

§

impl Freeze for Rect

§

impl RefUnwindSafe for Rect

§

impl Send for Rect

§

impl Sync for Rect

§

impl Unpin for Rect

§

impl UnwindSafe for Rect

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

§

impl<N, T> NativeTransmutableWrapper<N> for T
where T: NativeTransmutable<N>,

§

fn wrap(native: N) -> T

§

fn unwrap(self) -> N

§

fn inner(&self) -> &N

§

fn inner_mut(&mut self) -> &mut N

source§

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

§

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>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.