Struct geom::rect::Rect [] [src]

pub struct Rect<T> { /* fields omitted */ }

A generic rectangle structure.

Methods

impl<T> Rect<T> where
    T: Add<T, Output = T> + Sub<T, Output = T> + Mul<T, Output = T> + Ord + One + Default + Copy + Clone
[src]

Returns a new rectangle with the supplied position and dimensions.

Returns a new rectangle with the given top-left and bottom-right points.

Returns the width of the rectangle.

Returns the height of the rectangle.

Returns a copy of the top-left point of the rectangle.

Returns the y coordinate of the top side of the rectangle.

Returns the x coordinate of the left side of the rectangle.

Returns a copy of the bottom-right point of the rectangle.

Returns the y coordinate of the bottom side of the rectangle.

Returns the x coordinate of the right side of the rectangle.

Returns the area of the rectangle.

Returns true if the given point lies within the bounds of the rectangle, and false otherwise.

If self and other intersect, then the intersection of the two rectangles is returned as a new rectangle, otherwise None is returned.

Splits the rectangle at the given column col. The right side of the left part of the resulting split will be at col - 1, and the left side of the right part will be at col. The current rectangle will be modified in-place to be the left part, and the right part will be returned as a new rectangle.

Examples

use geom::Rect;

let mut r = Rect::new(0, 0, 10, 10);
let s = r.split_column_mut(5);

assert_eq!(r.top(), 0);
assert_eq!(r.left(), 0);
assert_eq!(r.bottom(), 9);
assert_eq!(r.right(), 4);

assert_eq!(s.top(), 0);
assert_eq!(s.left(), 5);
assert_eq!(s.bottom(), 9);
assert_eq!(s.right(), 9);

Splits the rectangle at the given row row. The bottom side of the top part of the resulting split will be at row - 1, and the top side of the bottom part will be at row. The current rectangle will be modified in-place to be the top part, and the bottom part will be returned as a new rectangle.

Examples

use geom::Rect;

let mut r = Rect::new(0, 0, 10, 10);
let s = r.split_row_mut(5);

assert_eq!(r.top(), 0);
assert_eq!(r.left(), 0);
assert_eq!(r.bottom(), 4);
assert_eq!(r.right(), 9);

assert_eq!(s.top(), 5);
assert_eq!(s.left(), 0);
assert_eq!(s.bottom(), 9);
assert_eq!(s.right(), 9);

Returns a Vec containing a one-width rectangle for each column of the rectangle.

Returns a Vec containing a one-height rectangle for each row of the rectangle.

impl<T> Rect<T> where
    T: Add<T, Output = T> + Sub<T, Output = T> + Mul<T, Output = T> + Ord + One + Default + Copy + Clone
[src]

Returns an iterator over each point in the rectangle, going from left-to-right and top-to-bottom.

Trait Implementations

impl<T: PartialEq> PartialEq for Rect<T>
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl<T: Eq> Eq for Rect<T>
[src]

impl<T: Copy> Copy for Rect<T>
[src]

impl<T: Clone> Clone for Rect<T>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<T: Debug> Debug for Rect<T>
[src]

Formats the value using the given formatter.

impl<T: Hash> Hash for Rect<T>
[src]

Feeds this value into the given [Hasher]. Read more

Feeds a slice of this type into the given [Hasher]. Read more

impl<T> IntoIterator for Rect<T> where
    T: Add<T, Output = T> + Sub<T, Output = T> + Mul<T, Output = T> + Ord + One + Default + Copy + Clone
[src]

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more