Type Alias IntRect

Source
pub type IntRect = Rect<i32>;
Expand description

A Rect of i32.

Aliased Type§

struct IntRect {
    pub left: i32,
    pub top: i32,
    pub width: i32,
    pub height: i32,
}

Fields§

§left: i32

Left coordinate of the rectangle.

§top: i32

Top coordinate of the rectangle.

§width: i32

Width of the rectangle.

§height: i32

Height of the rectangle.

Implementations

Source§

impl<T> Rect<T>

Source

pub fn new(left: T, top: T, width: T, height: T) -> Rect<T>

Construct a rectangle from its coordinates.

Source

pub fn from_vecs(pos: Vector2<T>, size: Vector2<T>) -> Rect<T>

Construct a rectangle from its position and size.

Source§

impl<T: PartialOrd + Add<Output = T> + Sub<Output = T> + Copy> Rect<T>

Source

pub fn contains(self, point: Vector2<T>) -> bool

Check if a point is inside the rectangle’s area.

Source

pub fn contains2(self, x: T, y: T) -> bool

Check if a point is inside the rectangle’s area.

Source

pub fn intersects(self, other: &Rect<T>) -> Option<Rect<T>>

Check the intersection between two rectangles.

If the rectangles intersect, returns Some filled with the intersection of the two rectangles. Otherwise, returns None.

Trait Implementations

Source§

impl<T: Clone> Clone for Rect<T>

Source§

fn clone(&self) -> Rect<T>

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<T: Debug> Debug for Rect<T>

Source§

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

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

impl<T: Default> Default for Rect<T>

Source§

fn default() -> Rect<T>

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

impl<T: Ord> Ord for Rect<T>

Source§

fn cmp(&self, other: &Rect<T>) -> 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,

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

impl<T: PartialEq> PartialEq for Rect<T>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

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

impl<T: PartialOrd> PartialOrd for Rect<T>

Source§

fn partial_cmp(&self, other: &Rect<T>) -> 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

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

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

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T: Copy> Copy for Rect<T>

Source§

impl<T: Eq> Eq for Rect<T>

Source§

impl<T> StructuralPartialEq for Rect<T>