[−][src]Struct math2d::Rectf
Represents a rectangle defined by the coordinates of the upper-left corner (left, top) and the coordinates of the lower-right corner (right, bottom).
Fields
left: f32The x-coordinate of the left edge of the rectangle.
top: f32The y-coordinate of the top edge of the rectangle.
right: f32The x-coordinate of the right edge of the rectangle.
bottom: f32The y-coordinate of the bottom edge of the rectangle.
Methods
impl Rectf[src]
pub const INFINITE: Rectf[src]
A rect that holds the entire real space
pub fn new(left: f32, top: f32, right: f32, bottom: f32) -> Rectf[src]
Constructs the rectangle from components.
pub fn from_points(p1: impl Into<Point2f>, p2: impl Into<Point2f>) -> Rectf[src]
Constructs a rectangle that will encompass all of the axis-aligned space between the two provided points.
pub fn from_center_size(
center: impl Into<Point2f>,
size: impl Into<Sizef>
) -> Rectf[src]
center: impl Into<Point2f>,
size: impl Into<Sizef>
) -> Rectf
Constructs a rectangle given its desired center point and desired width and height.
pub fn from_center_half_extent(
center: impl Into<Point2f>,
half_extents: impl Into<Vector2f>
) -> Rectf[src]
center: impl Into<Point2f>,
half_extents: impl Into<Vector2f>
) -> Rectf
Constructs a rectangle given its desired center and the desired distance from the center to the corners.
pub fn to_i32(&self) -> Recti[src]
Converts this rectangle's components to signed integers. Truncates values, perform manual rounding if you would like a different behavior.
pub fn to_u32(&self) -> Rectu[src]
Converts the components of the rectangle to unsigned integers. Beware this conversion if the components could be negative, you will experience unsigned casting underflow.
pub fn rounded(&self) -> Rectf[src]
Rounds the components to the nearest integers, rounding half-way values away from zero.
pub fn size(&self) -> Sizef[src]
Gets the width and height of this rectangle.
pub fn center(&self) -> Point2f[src]
Gets the center point of this rectangle.
pub fn half_extent(&self) -> Vector2f[src]
Gets the half-extent of the rectangle i.e. the vector from the center to the most-positive corner.
pub fn corner(&self, corner: RectCorner) -> Point2f[src]
Get the point of the specified corner.
pub fn contains_point(&self, point: impl Into<Point2f>) -> bool[src]
Determines if the specified point is located inside the rectangle.
pub fn overlaps(&self, other: &Rectf) -> bool[src]
Determines if two rects overlap at all
pub fn normalized(self) -> Self[src]
Normalizes the rectangle to enforce the invariants
left < right and top < bottom.
pub fn translated_by(self, translation: impl Into<Vector2f>) -> Self[src]
Translates the rectangle by the given vector.
pub fn expanded_by(self, thickness: impl Into<Thicknessf>) -> Self[src]
Expands the rectangle by the given margin.
pub fn shrunken_by(self, thickness: impl Into<Thicknessf>) -> Self[src]
Shrinks the rectangle by the given margin.
pub fn combined_with(&self, other: impl Into<Rectf>) -> Self[src]
Constructs a rectangle that contains both rectangles. Normalizes both arguments before performing the operation.
Trait Implementations
impl Copy for Rectf[src]
impl PartialEq<Rectf> for Rectf[src]
impl Default for Rectf[src]
impl From<(Point2f, Point2f)> for Rectf[src]
impl From<(Point2f, Sizef)> for Rectf[src]
impl From<(Point2f, Vector2f)> for Rectf[src]
impl From<[f32; 4]> for Rectf[src]
impl Clone for Rectf[src]
fn clone(&self) -> Rectf[src]
fn clone_from(&mut self, source: &Self)1.0.0[src]
Performs copy-assignment from source. Read more
impl Debug for Rectf[src]
impl Add<Vector2f> for Rectf[src]
type Output = Rectf
The resulting type after applying the + operator.
fn add(self, rhs: Vector2f) -> Rectf[src]
impl Sub<Vector2f> for Rectf[src]
type Output = Rectf
The resulting type after applying the - operator.
fn sub(self, rhs: Vector2f) -> Rectf[src]
impl Serialize for Rectf[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer, [src]
__S: Serializer,
impl<'de> Deserialize<'de> for Rectf[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>, [src]
__D: Deserializer<'de>,
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
impl<T> From for T[src]
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> 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> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> DeserializeOwned for T where
T: Deserialize<'de>, [src]
T: Deserialize<'de>,