Rect

Struct Rect 

Source
pub struct Rect { /* private fields */ }
Expand description

A rectangle object with a left-bottom origin position and a size.

Implementations§

Source§

impl Rect

Source

pub fn set_origin(&mut self, val: &Vec2)

Sets the position of the origin of the rectangle.

Source

pub fn get_origin(&self) -> Vec2

Gets the position of the origin of the rectangle.

Source

pub fn set_size(&mut self, val: &Size)

Sets the dimensions of the rectangle.

Source

pub fn get_size(&self) -> Size

Gets the dimensions of the rectangle.

Source

pub fn set_x(&mut self, val: f32)

Sets the x-coordinate of the origin of the rectangle.

Source

pub fn get_x(&self) -> f32

Gets the x-coordinate of the origin of the rectangle.

Source

pub fn set_y(&mut self, val: f32)

Sets the y-coordinate of the origin of the rectangle.

Source

pub fn get_y(&self) -> f32

Gets the y-coordinate of the origin of the rectangle.

Source

pub fn set_width(&mut self, val: f32)

Sets the width of the rectangle.

Source

pub fn get_width(&self) -> f32

Gets the width of the rectangle.

Source

pub fn set_height(&mut self, val: f32)

Sets the height of the rectangle.

Source

pub fn get_height(&self) -> f32

Gets the height of the rectangle.

Source

pub fn set_left(&mut self, val: f32)

Sets the left edge in x-axis of the rectangle.

Source

pub fn get_left(&self) -> f32

Gets the left edge in x-axis of the rectangle.

Source

pub fn set_right(&mut self, val: f32)

Sets the right edge in x-axis of the rectangle.

Source

pub fn get_right(&self) -> f32

Gets the right edge in x-axis of the rectangle.

Source

pub fn set_center_x(&mut self, val: f32)

Sets the x-coordinate of the center of the rectangle.

Source

pub fn get_center_x(&self) -> f32

Gets the x-coordinate of the center of the rectangle.

Source

pub fn set_center_y(&mut self, val: f32)

Sets the y-coordinate of the center of the rectangle.

Source

pub fn get_center_y(&self) -> f32

Gets the y-coordinate of the center of the rectangle.

Source

pub fn set_bottom(&mut self, val: f32)

Sets the bottom edge in y-axis of the rectangle.

Source

pub fn get_bottom(&self) -> f32

Gets the bottom edge in y-axis of the rectangle.

Source

pub fn set_top(&mut self, val: f32)

Sets the top edge in y-axis of the rectangle.

Source

pub fn get_top(&self) -> f32

Gets the top edge in y-axis of the rectangle.

Source

pub fn set_lower_bound(&mut self, val: &Vec2)

Sets the lower bound (left-bottom) of the rectangle.

Source

pub fn get_lower_bound(&self) -> Vec2

Gets the lower bound (left-bottom) of the rectangle.

Source

pub fn set_upper_bound(&mut self, val: &Vec2)

Sets the upper bound (right-top) of the rectangle.

Source

pub fn get_upper_bound(&self) -> Vec2

Gets the upper bound (right-top) of the rectangle.

Source

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

Sets the properties of the rectangle.

§Arguments
  • x - The x-coordinate of the origin of the rectangle.
  • y - The y-coordinate of the origin of the rectangle.
  • width - The width of the rectangle.
  • height - The height of the rectangle.
Source

pub fn contains_point(&self, point: &Vec2) -> bool

Checks if a point is inside the rectangle.

§Arguments
  • point - The point to check, represented by a Vec2 object.
§Returns
  • bool - Whether or not the point is inside the rectangle.
Source

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

Checks if the rectangle intersects with another rectangle.

§Arguments
  • rect - The other rectangle to check for intersection with, represented by a Rect object.
§Returns
  • bool - Whether or not the rectangles intersect.
Source

pub fn new(origin: &Vec2, size: &Size) -> Rect

Creates a new rectangle object using a Vec2 object for the origin and a Size object for the size.

§Arguments
  • origin - The origin of the rectangle, represented by a Vec2 object.
  • size - The size of the rectangle, represented by a Size object.
§Returns
  • Rect - A new rectangle object.
Source

pub fn zero() -> Rect

Gets a rectangle object with all properties set to 0.

Trait Implementations§

Source§

impl Drop for Rect

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl PartialEq for Rect

Source§

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

Checks if two rectangles are equal.

§Arguments
  • other - The other rectangle to compare to, represented by a Rect object.
§Returns
  • bool - Whether or not the two rectangles are equal.
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.

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.

Source§

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

Source§

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

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.