Struct rich_sdl2_rust::geo::Rect

source ·
pub struct Rect {
    pub up_left: Point,
    pub size: Size,
}
Expand description

A rectangle holding up left point and size.

Fields§

§up_left: Point

A up left point of the rectangle.

§size: Size

A size of the rectangle.

Implementations§

source§

impl Rect

source

pub fn from_center(center: Point, size: Size) -> Self

Constructs a rect from the center.

source

pub fn from_bottom_right(bottom_right: Point, size: Size) -> Self

Constructs a rect from the bottom right.

source

pub fn from_xs_ys(xs: [i32; 2], ys: [i32; 2]) -> Self

Constructs a rect from x and y coordinates.

source

pub fn bottom_right(self) -> Point

Returns the bottom right point of the rectangle.

source

pub fn top_right(self) -> Point

Returns the top right point of the rectangle.

source

pub fn bottom_left(self) -> Point

Returns the bottom left point of the rectangle.

source

pub fn center(self) -> Point

Returns the center point of the rectangle.

source

pub fn left(self) -> i32

Returns the left x of the rect.

source

pub fn right(self) -> i32

Returns the right x of the rect.

source

pub fn top(self) -> i32

Returns the top y of the rect.

source

pub fn bottom(self) -> i32

Returns the bottom y of the rect.

source

pub fn enclosed( points: impl IntoIterator<Item = Point>, clip: Option<Rect> ) -> Option<Self>

Returns the enclosed rectangle of the points, with the clip region.

source

pub fn has_intersection(self, other: Self) -> bool

Returns whether two rectangles intersected.

source

pub fn intersect(self, other: Self) -> Option<Self>

Returns the intersection rectangle of two rectangles.

source

pub fn is_empty(&self) -> bool

Returns whether the rectangle is empty.

source

pub fn union(self, other: Self) -> Self

Returns the union of two rectangles.

source

pub fn with_top(self, y: i32) -> Self

Creates a new rect from the rect with overwriting the new top y position.

source

pub fn with_right(self, x: i32) -> Self

Creates a new rect from the rect with overwriting the new right x position.

source

pub fn with_bottom(self, y: i32) -> Self

Creates a new rect from the rect with overwriting the new bottom y position.

source

pub fn with_left(self, x: i32) -> Self

Creates a new rect from the rect with overwriting the new left x position.

source

pub fn extend_top(self, increase: u32) -> Self

Creates a new rect that increased the top from the rect.

source

pub fn extend_right(self, increase: u32) -> Self

Creates a new rect that increased the right from the rect.

source

pub fn extend_bottom(self, increase: u32) -> Self

Creates a new rect that increased the bottom from the rect.

source

pub fn extend_left(self, increase: u32) -> Self

Creates a new rect that increased the left from the rect.

Trait Implementations§

source§

impl Clone for Rect

source§

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
source§

impl Debug for Rect

source§

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

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

impl From<Rect> for SDL_Rect

source§

fn from(_: Rect) -> Self

Converts to this type from the input type.
source§

impl From<SDL_Rect> for Rect

source§

fn from(_: SDL_Rect) -> Self

Converts to this type from the input type.
source§

impl Ord for Rect

source§

fn cmp(&self, other: &Rect) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for Rect

source§

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

impl PartialOrd for Rect

source§

fn partial_cmp(&self, other: &Rect) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Copy for Rect

source§

impl Eq for Rect

source§

impl StructuralPartialEq for Rect

Auto Trait Implementations§

§

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.

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.