Struct nannou::geom::rect::Rect
[−]
[src]
pub struct Rect<S = f64> { pub x: Range<S>, pub y: Range<S>, }
Defines a Rectangle's bounds across the x and y axes.
Fields
x: Range<S>
The start and end positions of the Rectangle on the x axis.
y: Range<S>
The start and end positions of the Rectangle on the y axis.
Methods
impl<S> Rect<S> where
S: BaseNum,
[src]
S: BaseNum,
pub fn from_xy_wh(p: Point2<S>, wh: Vector2<S>) -> Self
[src]
Construct a Rect from a given Point
and Dimensions
.
pub fn from_wh(wh: Vector2<S>) -> Self
[src]
Construct a Rect at origin with the given dimensions.
pub fn from_corners(a: Point2<S>, b: Point2<S>) -> Self
[src]
Construct a Rect from the coordinates of two points.
pub fn absolute(self) -> Self
[src]
Converts self
to an absolute Rect
so that the magnitude of each range is always
positive.
pub fn overlap(self, other: Self) -> Option<Self>
[src]
The Rect representing the area in which two Rects overlap.
pub fn max(self, other: Self) -> Self where
S: Float,
[src]
S: Float,
The Rect that encompass the two given sets of Rect.
pub fn x(&self) -> S
[src]
The position in the middle of the x bounds.
pub fn y(&self) -> S
[src]
The position in the middle of the y bounds.
pub fn xy(&self) -> Point2<S>
[src]
The xy position in the middle of the bounds.
pub fn x_y(&self) -> (S, S)
[src]
The centered x and y coordinates as a tuple.
pub fn bottom(&self) -> S
[src]
The Rect's lowest y value.
pub fn top(&self) -> S
[src]
The Rect's highest y value.
pub fn left(&self) -> S
[src]
The Rect's lowest x value.
pub fn right(&self) -> S
[src]
The Rect's highest x value.
pub fn top_left(&self) -> Point2<S>
[src]
The top left corner Point.
pub fn bottom_left(&self) -> Point2<S>
[src]
The bottom left corner Point.
pub fn top_right(&self) -> Point2<S>
[src]
The top right corner Point.
pub fn bottom_right(&self) -> Point2<S>
[src]
The bottom right corner Point.
pub fn l_r_b_t(&self) -> (S, S, S, S)
[src]
The edges of the Rect in a tuple (top, bottom, left, right).
pub fn shift_x(self, x: S) -> Self
[src]
Shift the Rect along the x axis.
pub fn shift_y(self, y: S) -> Self
[src]
Shift the Rect along the y axis.
pub fn shift(self, v: Vector2<S>) -> Self
[src]
Shift the Rect by the given vector.
pub fn contains(&self, p: Point2<S>) -> bool
[src]
Does the given point touch the Rectangle.
pub fn stretch_to_point(self, p: Point2<S>) -> Self
[src]
Stretches the closest edge(s) to the given point if the point lies outside of the Rect area.
pub fn left_of(self, other: Self) -> Self
[src]
Align self
's right edge with the left edge of the other
Rect.
pub fn right_of(self, other: Self) -> Self
[src]
Align self
's left edge with the right dge of the other
Rect.
pub fn below(self, other: Self) -> Self
[src]
Align self
's top edge with the bottom edge of the other
Rect.
pub fn above(self, other: Self) -> Self
[src]
Align self
's bottom edge with the top edge of the other
Rect.
pub fn align_x_of(self, align: Align, other: Self) -> Self
[src]
Align self
to other
along the x axis in accordance with the given Align
variant.
pub fn align_y_of(self, align: Align, other: Self) -> Self
[src]
Align self
to other
along the y axis in accordance with the given Align
variant.
pub fn align_left_of(self, other: Self) -> Self
[src]
Align self
's left edge with the left edge of the other
Rect.
pub fn align_middle_x_of(self, other: Self) -> Self
[src]
Align the middle of self
with the middle of the other
Rect along the x axis.
pub fn align_right_of(self, other: Self) -> Self
[src]
Align self
's right edge with the right edge of the other
Rect.
pub fn align_bottom_of(self, other: Self) -> Self
[src]
Align self
's bottom edge with the bottom edge of the other
Rect.
pub fn align_middle_y_of(self, other: Self) -> Self
[src]
Align the middle of self
with the middle of the other
Rect along the y axis.
pub fn align_top_of(self, other: Self) -> Self
[src]
Align self
's top edge with the top edge of the other
Rect.
pub fn top_left_of(self, other: Self) -> Self
[src]
Place self
along the top left edges of the other
Rect.
pub fn top_right_of(self, other: Self) -> Self
[src]
Place self
along the top right edges of the other
Rect.
pub fn bottom_left_of(self, other: Self) -> Self
[src]
Place self
along the bottom left edges of the other
Rect.
pub fn bottom_right_of(self, other: Self) -> Self
[src]
Place self
along the bottom right edges of the other
Rect.
pub fn mid_top_of(self, other: Self) -> Self
[src]
Place self
in the middle of the top edge of the other
Rect.
pub fn mid_bottom_of(self, other: Self) -> Self
[src]
Place self
in the middle of the bottom edge of the other
Rect.
pub fn mid_left_of(self, other: Self) -> Self
[src]
Place self
in the middle of the left edge of the other
Rect.
pub fn mid_right_of(self, other: Self) -> Self
[src]
Place self
in the middle of the right edge of the other
Rect.
pub fn middle_of(self, other: Self) -> Self
[src]
Place self
directly in the middle of the other
Rect.
pub fn closest_corner(&self, p: Point2<S>) -> Corner
[src]
Return the Corner of self
that is closest to the given Point.
pub fn corners(&self) -> Quad<Point2<S>>
[src]
Thee four corners of the Rect
.
ⓘImportant traits for Corners<S>pub fn corners_iter(&self) -> Corners<S>
[src]
An iterator yielding the four corners of the Rect
.
pub fn triangles(&self) -> (Tri<Point2<S>>, Tri<Point2<S>>)
[src]
Return two Tri
s that represent the Rect
.
pub fn triangles_iter(self) -> Triangles<S>
[src]
An iterator yielding the Rect
's two Tri
's.
pub fn subdivision_ranges(&self) -> SubdivisionRanges<S>
[src]
The four ranges used for the Rect
's four subdivisions.
pub fn subdivisions(&self) -> [Self; 4]
[src]
Divide the Rect
in half along the x and y axes and return the four subdivisions.
Subdivisions are yielded in the following order:
- Bottom left
- Bottom right
- Top left
- Top right
ⓘImportant traits for Subdivisions<S>pub fn subdivisions_iter(&self) -> Subdivisions<S>
[src]
The same as subdivisions
but each subdivision is yielded via the returned Iterator
.
pub fn corner_at_index(&self, index: u8) -> Option<Point2<S>>
[src]
Produce the corner at the given index.
impl<S> Rect<S> where
S: BaseNum + Neg<Output = S>,
[src]
S: BaseNum + Neg<Output = S>,
pub fn w(&self) -> S
[src]
The width of the Rect.
pub fn h(&self) -> S
[src]
The height of the Rect.
pub fn wh(&self) -> Vector2<S>
[src]
The total dimensions of the Rect.
pub fn w_h(&self) -> (S, S)
[src]
The width and height of the Rect as a tuple.
pub fn xy_wh(&self) -> (Point2<S>, Vector2<S>)
[src]
Convert the Rect to a Point
and Dimensions
.
pub fn x_y_w_h(&self) -> (S, S, S, S)
[src]
The Rect's centered coordinates and dimensions in a tuple.
pub fn len(&self) -> S
[src]
The length of the longest side of the rectangle.
pub fn l_t_w_h(&self) -> (S, S, S, S)
[src]
The left and top edges of the Rect along with the width and height.
pub fn l_b_w_h(&self) -> (S, S, S, S)
[src]
The left and bottom edges of the Rect along with the width and height.
pub fn pad_left(self, pad: S) -> Self
[src]
The Rect with some padding applied to the left edge.
pub fn pad_right(self, pad: S) -> Self
[src]
The Rect with some padding applied to the right edge.
pub fn pad_bottom(self, pad: S) -> Self
[src]
The rect with some padding applied to the bottom edge.
pub fn pad_top(self, pad: S) -> Self
[src]
The Rect with some padding applied to the top edge.
pub fn pad(self, pad: S) -> Self
[src]
The Rect with some padding amount applied to each edge.
pub fn padding(self, padding: Padding<S>) -> Self
[src]
The Rect with some padding applied.
pub fn relative_to_x(self, x: S) -> Self
[src]
Returns a Rect
with a position relative to the given position on the x axis.
pub fn relative_to_y(self, y: S) -> Self
[src]
Returns a Rect
with a position relative to the given position on the y axis.
pub fn relative_to(self, p: Point2<S>) -> Self
[src]
Returns a Rect
with a position relative to the given position.
Trait Implementations
impl<S> From<Rect<S>> for Rect<S> where
S: BaseFloat,
[src]
S: BaseFloat,
impl<S: Copy> Copy for Rect<S>
[src]
impl<S: Clone> Clone for Rect<S>
[src]
fn clone(&self) -> Rect<S>
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<S: Debug> Debug for Rect<S>
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl<S: PartialEq> PartialEq for Rect<S>
[src]
fn eq(&self, __arg_0: &Rect<S>) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Rect<S>) -> bool
[src]
This method tests for !=
.
impl<S: PartialOrd> PartialOrd for Rect<S>
[src]
fn partial_cmp(&self, __arg_0: &Rect<S>) -> Option<Ordering>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, __arg_0: &Rect<S>) -> bool
[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, __arg_0: &Rect<S>) -> bool
[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, __arg_0: &Rect<S>) -> bool
[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, __arg_0: &Rect<S>) -> bool
[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more