[−][src]Trait vector2math::Rectangle
Trait for manipulating axis-aligned rectangles
Associated Types
Loading content...Required methods
fn new(top_left: Self::Vector, size: Self::Vector) -> Self
Create a new rectangle from a top-left corner position and a size
fn top_left(self) -> Self::Vector
Get the top-left corner position
fn size(self) -> Self::Vector
Get the size
Provided methods
fn square(top_left: Self::Vector, side_length: Self::Scalar) -> Self
Create a new square from a top-left corner position and a side length
fn centered(center: Self::Vector, size: Self::Vector) -> Self
Create a new rectangle from a center position and a size
fn map<R>(self) -> R where
R: Rectangle,
R::Scalar: From<Self::Scalar>,
R: Rectangle,
R::Scalar: From<Self::Scalar>,
Map this rectangle to a rectangle of another type
fn map_with<R, F>(self, f: F) -> R where
R: Rectangle,
F: FnMut(Self::Scalar) -> <<R as Rectangle>::Vector as Vector2>::Scalar,
R: Rectangle,
F: FnMut(Self::Scalar) -> <<R as Rectangle>::Vector as Vector2>::Scalar,
Map this ractangle to a ractangle of another type using a function
fn top_right(self) -> Self::Vector
Get the top-right corner position
fn bottom_left(self) -> Self::Vector
Get the bottom-left corner position
fn bottom_right(self) -> Self::Vector
Get the bottom-right corner position
fn top(self) -> Self::Scalar
Get the top y
fn bottom(self) -> Self::Scalar
Get the bottom y
fn left(self) -> Self::Scalar
Get the left x
fn right(self) -> Self::Scalar
Get the right x
fn width(self) -> Self::Scalar
Get the width
fn height(self) -> Self::Scalar
Get the height
fn center(self) -> Self::Vector
Get the position of the center
fn with_top_left(self, top_left: Self::Vector) -> Self
Transform the rectangle into one with a different top-left corner position
fn with_size(self, size: Self::Vector) -> Self
Transform the rectangle into one with a different size
fn perimeter(self) -> Self::Scalar
Get the perimeter
fn area(self) -> Self::Scalar
Get the area
fn translated(self, offset: Self::Vector) -> Self
Get the rectangle that is this one translated by some vector
fn scaled(self, scale: Self::Scalar) -> Self
Get the rectangle that is this one with a scalar-scaled size
fn scaled2(self, scale: Self::Vector) -> Self
Get the rectangle that is this one with a vector-scaled size
Implementors
impl<P> Rectangle for P where
P: Pair + Copy,
P::Item: Vector2,
[src]
impl<P> Rectangle for P where
P: Pair + Copy,
P::Item: Vector2,
type Scalar = <P::Item as Vector2>::Scalar
type Vector = P::Item
fn new(top_left: Self::Vector, size: Self::Vector) -> Self | [src] |
fn top_left(self) -> Self::Vector | [src] |
fn size(self) -> Self::Vector | [src] |
fn square(top_left: Self::Vector, side_length: Self::Scalar) -> Self | [src] |
fn centered(center: Self::Vector, size: Self::Vector) -> Self | [src] |
fn map<R>(self) -> R where | [src] |
fn map_with<R, F>(self, f: F) -> R where | [src] |
fn top_right(self) -> Self::Vector | [src] |
fn bottom_left(self) -> Self::Vector | [src] |
fn bottom_right(self) -> Self::Vector | [src] |
fn top(self) -> Self::Scalar | [src] |
fn bottom(self) -> Self::Scalar | [src] |
fn left(self) -> Self::Scalar | [src] |
fn right(self) -> Self::Scalar | [src] |
fn width(self) -> Self::Scalar | [src] |
fn height(self) -> Self::Scalar | [src] |
fn center(self) -> Self::Vector | [src] |
fn with_top_left(self, top_left: Self::Vector) -> Self | [src] |
fn with_size(self, size: Self::Vector) -> Self | [src] |
fn perimeter(self) -> Self::Scalar | [src] |
fn area(self) -> Self::Scalar | [src] |
fn translated(self, offset: Self::Vector) -> Self | [src] |
fn scaled(self, scale: Self::Scalar) -> Self | [src] |
fn scaled2(self, scale: Self::Vector) -> Self | [src] |