Struct ggez::graphics::Rect [−][src]
A simple 2D rectangle.
The origin of the rectangle is at the top-left, with x increasing to the right and y increasing down.
Fields
x: f32
X coordinate of the left edge of the rect.
y: f32
Y coordinate of the top edge of the rect.
w: f32
Total width of the rect
h: f32
Total height of the rect.
Methods
impl Rect
[src]
impl Rect
pub fn new(x: f32, y: f32, w: f32, h: f32) -> Self
[src]
pub fn new(x: f32, y: f32, w: f32, h: f32) -> Self
Create a new rect.
pub fn fraction(x: f32, y: f32, w: f32, h: f32, reference: &Rect) -> Rect
[src]
pub fn fraction(x: f32, y: f32, w: f32, h: f32, reference: &Rect) -> Rect
Creates a new rect a la Love2D's love.graphics.newQuad, as a fraction of the reference rect's size.
pub fn new_i32(x: i32, y: i32, w: i32, h: i32) -> Self
[src]
pub fn new_i32(x: i32, y: i32, w: i32, h: i32) -> Self
Create a new rect from i32 coordinates.
pub fn zero() -> Self
[src]
pub fn zero() -> Self
Create a new Rect
with all values zero.
pub fn one() -> Self
[src]
pub fn one() -> Self
Creates a new Rect
at 0,0 with width and height 1.
pub fn point(&self) -> Point2
[src]
pub fn point(&self) -> Point2
Gets the Rect
's x and y coordinates as a Point2
.
pub fn left(&self) -> f32
[src]
pub fn left(&self) -> f32
Returns the left edge of the Rect
pub fn right(&self) -> f32
[src]
pub fn right(&self) -> f32
Returns the right edge of the Rect
pub fn top(&self) -> f32
[src]
pub fn top(&self) -> f32
Returns the top edge of the Rect
pub fn bottom(&self) -> f32
[src]
pub fn bottom(&self) -> f32
Returns the bottom edge of the Rect
pub fn contains(&self, point: Point2) -> bool
[src]
pub fn contains(&self, point: Point2) -> bool
Checks whether the Rect
contains a Point
pub fn overlaps(&self, other: &Rect) -> bool
[src]
pub fn overlaps(&self, other: &Rect) -> bool
Checks whether the Rect
overlaps another Rect
pub fn translate(&mut self, offset: Vector2)
[src]
pub fn translate(&mut self, offset: Vector2)
Translates the Rect
by an offset of (x, y)
pub fn move_to(&mut self, destination: Point2)
[src]
pub fn move_to(&mut self, destination: Point2)
Moves the Rect
's origin to (x, y)
pub fn scale(&mut self, sx: f32, sy: f32)
[src]
pub fn scale(&mut self, sx: f32, sy: f32)
Scales the Rect
by a factor of (sx, sy),
growing towards the bottom-left
Trait Implementations
impl Copy for Rect
[src]
impl Copy for Rect
impl Clone for Rect
[src]
impl Clone for Rect
fn clone(&self) -> Rect
[src]
fn clone(&self) -> Rect
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl PartialEq for Rect
[src]
impl PartialEq for Rect
fn eq(&self, other: &Rect) -> bool
[src]
fn eq(&self, other: &Rect) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rect) -> bool
[src]
fn ne(&self, other: &Rect) -> bool
This method tests for !=
.
impl Debug for Rect
[src]
impl Debug for Rect
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Default for Rect
[src]
impl Default for Rect
impl From<[f32; 4]> for Rect
[src]
impl From<[f32; 4]> for Rect
impl From<Rect> for [f32; 4]
[src]
impl From<Rect> for [f32; 4]