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.
Implementations
impl Rect
[src]
pub const 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 const fn new_i32(x: i32, y: i32, w: i32, h: i32) -> Self
[src]
Create a new rect from i32
coordinates.
pub const fn zero() -> Self
[src]
Create a new Rect
with all values zero.
pub const fn one() -> Self
[src]
Creates a new Rect
at 0,0
with width and height 1.
pub const fn point(&self) -> Point2<f32>
[src]
Gets the Rect
's x and y coordinates as a Point2
.
pub fn center(&self) -> Point2<f32>
[src]
Gets the Rect
's center x and y coordinates as a Point2
.
pub const 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 const 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 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]
pub fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
[src]
impl Clone for Rect
[src]
impl Copy for Rect
[src]
impl Debug for Rect
[src]
impl Default for Rect
[src]
impl<'de> Deserialize<'de> for Rect
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl From<[f32; 4]> for Rect
[src]
impl PartialEq<Rect> 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
pub 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
impl Serialize for Rect
[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl StructuralPartialEq for Rect
[src]
Auto Trait Implementations
impl RefUnwindSafe for Rect
[src]
impl Send for Rect
[src]
impl Sync for Rect
[src]
impl Unpin for Rect
[src]
impl UnwindSafe for Rect
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Pointable for T
pub const ALIGN: usize
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
pub unsafe fn drop(ptr: usize)
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> 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.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,