[−][src]Struct ggez::graphics::Rect
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]
pub fn new(x: f32, y: f32, w: f32, h: f32) -> Self
[src]
Create a new Rect
.
pub fn fraction(x: f32, y: f32, w: f32, h: f32, reference: &Rect) -> Rect
[src]
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]
Create a new rect from i32
coordinates.
pub fn zero() -> Self
[src]
Create a new Rect
with all values zero.
pub fn one() -> Self
[src]
Creates a new Rect
at 0,0
with width and height 1.
pub fn point(&self) -> Point2<f32>
[src]
Gets the Rect
's x and y coordinates as a Point2
.
pub fn left(&self) -> f32
[src]
Returns the left edge of the Rect
pub fn right(&self) -> f32
[src]
Returns the right edge of the Rect
pub fn top(&self) -> f32
[src]
Returns the top edge of the Rect
pub fn bottom(&self) -> f32
[src]
Returns the bottom edge of the Rect
pub fn contains<P>(&self, point: P) -> bool where
P: Into<Point2<f32>>,
[src]
P: Into<Point2<f32>>,
Checks whether the Rect
contains a Point
pub fn overlaps(&self, other: &Rect) -> bool
[src]
Checks whether the Rect
overlaps another Rect
pub fn translate<V>(&mut self, offset: V) where
V: Into<Vector2<f32>>,
[src]
V: Into<Vector2<f32>>,
Translates the Rect
by an offset of (x, y)
pub fn move_to<P>(&mut self, destination: P) where
P: Into<Point2<f32>>,
[src]
P: Into<Point2<f32>>,
Moves the Rect
's origin to (x, y)
pub fn scale(&mut self, sx: f32, sy: f32)
[src]
Scales the Rect
by a factor of (sx, sy),
growing towards the bottom-left
pub fn rotate(&mut self, rotation: f32)
[src]
Calculated the new Rect around the rotated one.
pub fn combine_with(self, other: Rect) -> Rect
[src]
Returns a new Rect
that includes all points of these two Rect
s.
Trait Implementations
impl Copy for Rect
[src]
impl PartialEq<Rect> for Rect
[src]
impl Clone for Rect
[src]
fn clone(&self) -> Rect
[src]
default fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Default for Rect
[src]
impl From<[f32; 4]> for Rect
[src]
impl From<Rect> for [f32; 4]
[src]
impl Debug for Rect
[src]
impl RelativeEq<Rect> for Rect
[src]
fn default_max_relative() -> Self::Epsilon
[src]
fn relative_eq(
&self,
other: &Self,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
[src]
&self,
other: &Self,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
default fn relative_ne(
&self,
other: &Rhs,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
[src]
&self,
other: &Rhs,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
The inverse of ApproxEq::relative_eq
.
impl AbsDiffEq<Rect> for Rect
[src]
type Epsilon = f32
Used for specifying relative comparisons.
fn default_epsilon() -> Self::Epsilon
[src]
fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool
[src]
default fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
[src]
The inverse of ApproxEq::abs_diff_eq
.
Auto Trait Implementations
Blanket Implementations
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Scalar for T where
T: Copy + PartialEq<T> + Any + Debug,
[src]
T: Copy + PartialEq<T> + Any + Debug,
impl<T> Same for T
type Output = T
Should always be Self
impl<SS, SP> SupersetOf for SP where
SS: SubsetOf<SP>,
SS: SubsetOf<SP>,
fn to_subset(&self) -> Option<SS>
fn is_in_subset(&self) -> bool
unsafe fn to_subset_unchecked(&self) -> SS
fn from_subset(element: &SS) -> SP
impl<T> Erased for T
impl<T> SetParameter for T
default fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
T: Parameter<Self>,
T: Parameter<Self>,
Sets value
as a parameter of self
.