[][src]Trait vector2math::Rectangle

pub trait Rectangle: Copy {
    type Scalar: Scalar;
    type Vector: Vector2<Scalar = Self::Scalar>;
    fn new(top_left: Self::Vector, size: Self::Vector) -> Self;
fn top_left(self) -> Self::Vector;
fn size(self) -> Self::Vector; fn square(top_left: Self::Vector, side_length: Self::Scalar) -> Self { ... }
fn centered(center: Self::Vector, size: Self::Vector) -> Self { ... }
fn map<R>(self) -> R
    where
        R: Rectangle,
        R::Scalar: From<Self::Scalar>
, { ... }
fn map_with<R, F>(self, f: F) -> R
    where
        R: Rectangle,
        F: FnMut(Self::Scalar) -> <<R as Rectangle>::Vector as Vector2>::Scalar
, { ... }
fn top_right(self) -> Self::Vector { ... }
fn bottom_left(self) -> Self::Vector { ... }
fn bottom_right(self) -> Self::Vector { ... }
fn top(self) -> Self::Scalar { ... }
fn bottom(self) -> Self::Scalar { ... }
fn left(self) -> Self::Scalar { ... }
fn right(self) -> Self::Scalar { ... }
fn width(self) -> Self::Scalar { ... }
fn height(self) -> Self::Scalar { ... }
fn center(self) -> Self::Vector { ... }
fn with_top_left(self, top_left: Self::Vector) -> Self { ... }
fn with_size(self, size: Self::Vector) -> Self { ... }
fn perimeter(self) -> Self::Scalar { ... }
fn area(self) -> Self::Scalar { ... }
fn translated(self, offset: Self::Vector) -> Self { ... }
fn scaled(self, scale: Self::Scalar) -> Self { ... }
fn scaled2(self, scale: Self::Vector) -> Self { ... } }

Trait for manipulating axis-aligned rectangles

Associated Types

type Scalar: Scalar

The scalar type

type Vector: Vector2<Scalar = Self::Scalar>

The vector type

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

Loading content...

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>, 

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

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

Loading content...

Implementors

impl<P> Rectangle for P where
    P: Pair + Copy,
    P::Item: Vector2
[src]

type Scalar = <P::Item as Vector2>::Scalar

type Vector = P::Item

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
    R: Rectangle,
    R::Scalar: From<Self::Scalar>, 
[src]

fn map_with<R, F>(self, f: F) -> R where
    R: Rectangle,
    F: FnMut(Self::Scalar) -> <<R as Rectangle>::Vector as Vector2>::Scalar
[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]

Loading content...