[][src]Struct math2d::Rectf

#[repr(C)]
pub struct Rectf { pub left: f32, pub top: f32, pub right: f32, pub bottom: f32, }

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: f32

The x-coordinate of the left edge of the rectangle.

top: f32

The y-coordinate of the top edge of the rectangle.

right: f32

The x-coordinate of the right edge of the rectangle.

bottom: f32

The 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]

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]

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 Clone for Rectf[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl PartialEq<Rectf> for Rectf[src]

impl Copy 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 Default for Rectf[src]

impl Debug for Rectf[src]

impl Add<Vector2f> for Rectf[src]

type Output = Rectf

The resulting type after applying the + operator.

impl Sub<Vector2f> for Rectf[src]

type Output = Rectf

The resulting type after applying the - operator.

impl Serialize for Rectf[src]

impl<'de> Deserialize<'de> for Rectf[src]

Auto Trait Implementations

impl Send for Rectf

impl Sync for Rectf

Blanket Implementations

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]