Trait rect::Rect [] [src]

pub trait Rect: Sized {
    type Scalar: Float;
    fn from_x_y_w_h(Self::Scalar, Self::Scalar, Self::Scalar, Self::Scalar) -> Self;
    fn x(&self) -> Self::Scalar;
    fn y(&self) -> Self::Scalar;
    fn w(&self) -> Self::Scalar;
    fn h(&self) -> Self::Scalar;
    fn set_x(&mut self, val: Self::Scalar);
    fn set_y(&mut self, val: Self::Scalar);
    fn set_w(&mut self, val: Self::Scalar);
    fn set_h(&mut self, val: Self::Scalar);

    fn from_u32(rect: [u32; 4]) -> Self { ... }
    fn from_i32(rect: [i32; 4]) -> Self { ... }
    fn xy(&self) -> (Self::Scalar, Self::Scalar) { ... }
    fn wh(&self) -> (Self::Scalar, Self::Scalar) { ... }
    fn xw(&self) -> (Self::Scalar, Self::Scalar) { ... }
    fn yh(&self) -> (Self::Scalar, Self::Scalar) { ... }
    fn x1x2(&self) -> (Self::Scalar, Self::Scalar) { ... }
    fn y1y2(&self) -> (Self::Scalar, Self::Scalar) { ... }
    fn p1p2(&self) -> ([Self::Scalar; 2], [Self::Scalar; 2]) { ... }
    fn xywh(&self) -> (Self::Scalar, Self::Scalar, Self::Scalar, Self::Scalar) { ... }
    fn center(&self) -> [Self::Scalar; 2] { ... }
    fn is_empty(&self) -> bool { ... }
    fn margin(&self, val: Self::Scalar) -> Self { ... }
    fn split_left(&self, val: Self::Scalar, factor: Self::Scalar) -> (Self, Self) { ... }
    fn split_right(&self, val: Self::Scalar, factor: Self::Scalar) -> (Self, Self) { ... }
    fn split_top(&self, val: Self::Scalar, factor: Self::Scalar) -> (Self, Self) { ... }
    fn split_bottom(&self, val: Self::Scalar, factor: Self::Scalar) -> (Self, Self) { ... }
}

Helper methods for computing simple rectangle layout.

Associated Types

type Scalar: Float

The internal scalar type.

Required Methods

fn from_x_y_w_h(Self::Scalar, Self::Scalar, Self::Scalar, Self::Scalar) -> Self

Creates new rectangle from x, y, w, h.

fn x(&self) -> Self::Scalar

Gets x.

fn y(&self) -> Self::Scalar

Gets y.

fn w(&self) -> Self::Scalar

Gets w.

fn h(&self) -> Self::Scalar

Gets h.

fn set_x(&mut self, val: Self::Scalar)

Sets x.

fn set_y(&mut self, val: Self::Scalar)

Sets y.

fn set_w(&mut self, val: Self::Scalar)

Sets w.

fn set_h(&mut self, val: Self::Scalar)

Sets h.

Provided Methods

fn from_u32(rect: [u32; 4]) -> Self

Converts from u32 rectangle.

fn from_i32(rect: [i32; 4]) -> Self

Converts from i32 rectangle.

fn xy(&self) -> (Self::Scalar, Self::Scalar)

Returns x and y.

fn wh(&self) -> (Self::Scalar, Self::Scalar)

Returns w and h.

fn xw(&self) -> (Self::Scalar, Self::Scalar)

Return x and w.

fn yh(&self) -> (Self::Scalar, Self::Scalar)

Returns y and h.

fn x1x2(&self) -> (Self::Scalar, Self::Scalar)

Returns left and right.

fn y1y2(&self) -> (Self::Scalar, Self::Scalar)

Returns top and bottom.

fn p1p2(&self) -> ([Self::Scalar; 2], [Self::Scalar; 2])

Returns upper left and lower right corner.

fn xywh(&self) -> (Self::Scalar, Self::Scalar, Self::Scalar, Self::Scalar)

Returns x, y, w, h.

fn center(&self) -> [Self::Scalar; 2]

Returns the center of the rectangle.

fn is_empty(&self) -> bool

Returns true if the rectangle is empty.

fn margin(&self, val: Self::Scalar) -> Self

Computes a margin rectangle. If the margin is too large, an empty rectangle in the middle is returned.

fn split_left(&self, val: Self::Scalar, factor: Self::Scalar) -> (Self, Self)

Splits from the left side of rectangle up to a factor.

fn split_right(&self, val: Self::Scalar, factor: Self::Scalar) -> (Self, Self)

Splits from the right side of rectangle.

fn split_top(&self, val: Self::Scalar, factor: Self::Scalar) -> (Self, Self)

Splits from the top side of rectangle.

fn split_bottom(&self, val: Self::Scalar, factor: Self::Scalar) -> (Self, Self)

Splits from the bottom side of the rectangle.

Implementors