[][src]Struct imageproc::rect::Rect

pub struct Rect { /* fields omitted */ }

A rectangular region of non-zero width and height.

Examples

use imageproc::rect::Rect;
use imageproc::rect::Region;

// Construct a rectangle with top-left corner at (4, 5), width 6 and height 7.
let rect = Rect::at(4, 5).of_size(6, 7);

// Contains top-left point:
assert_eq!(rect.left(), 4);
assert_eq!(rect.top(), 5);
assert!(rect.contains(rect.left(), rect.top()));

// Contains bottom-right point, at (left + width - 1, top + height - 1):
assert_eq!(rect.right(), 9);
assert_eq!(rect.bottom(), 11);
assert!(rect.contains(rect.right(), rect.bottom()));

Implementations

impl Rect[src]

pub fn at(x: i32, y: i32) -> RectPosition[src]

Reduces possibility of confusing coordinates and dimensions when specifying rects.

See the struct-level documentation for examples.

pub fn top(&self) -> i32[src]

Smallest y-coordinate reached by rect.

See the struct-level documentation for examples.

pub fn left(&self) -> i32[src]

Smallest x-coordinate reached by rect.

See the struct-level documentation for examples.

pub fn bottom(&self) -> i32[src]

Greatest y-coordinate reached by rect.

See the struct-level documentation for examples.

pub fn right(&self) -> i32[src]

Greatest x-coordinate reached by rect.

See the struct-level documentation for examples.

pub fn width(&self) -> u32[src]

Width of rect.

pub fn height(&self) -> u32[src]

Height of rect.

pub fn intersect(&self, other: Rect) -> Option<Rect>[src]

Returns the intersection of self and other, or none if they are are disjoint.

Examples

use imageproc::rect::Rect;
use imageproc::rect::Region;

// Intersecting a rectangle with itself
let r = Rect::at(4, 5).of_size(6, 7);
assert_eq!(r.intersect(r), Some(r));

// Intersecting overlapping but non-equal rectangles
let r = Rect::at(0, 0).of_size(5, 5);
let s = Rect::at(1, 4).of_size(10, 12);
let i = Rect::at(1, 4).of_size(4, 1);
assert_eq!(r.intersect(s), Some(i));

// Intersecting disjoint rectangles
let r = Rect::at(0, 0).of_size(5, 5);
let s = Rect::at(10, 10).of_size(100, 12);
assert_eq!(r.intersect(s), None);

Trait Implementations

impl Clone for Rect[src]

impl Copy for Rect[src]

impl Debug for Rect[src]

impl Eq for Rect[src]

impl PartialEq<Rect> for Rect[src]

impl Region<f32> for Rect[src]

impl Region<i32> for Rect[src]

impl StructuralEq for Rect[src]

impl StructuralPartialEq for Rect[src]

Auto Trait Implementations

impl RefUnwindSafe for Rect

impl Send for Rect

impl Sync for Rect

impl Unpin for Rect

impl UnwindSafe for Rect

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<Src, Scheme> ApproxFrom<Src, Scheme> for Src where
    Scheme: ApproxScheme
[src]

type Err = NoError

The error type produced by a failed conversion.

impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Src where
    Dst: ApproxFrom<Src, Scheme>,
    Scheme: ApproxScheme
[src]

type Err = <Dst as ApproxFrom<Src, Scheme>>::Err

The error type produced by a failed conversion.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T, Dst> ConvAsUtil<Dst> for T[src]

impl<T> ConvUtil for T[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> SetParameter for T

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<Src> TryFrom<Src> for Src[src]

type Err = NoError

The error type produced by a failed conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<Src, Dst> TryInto<Dst> for Src where
    Dst: TryFrom<Src>, 
[src]

type Err = <Dst as TryFrom<Src>>::Err

The error type produced by a failed conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

impl<Src> ValueFrom<Src> for Src[src]

type Err = NoError

The error type produced by a failed conversion.

impl<Src, Dst> ValueInto<Dst> for Src where
    Dst: ValueFrom<Src>, 
[src]

type Err = <Dst as ValueFrom<Src>>::Err

The error type produced by a failed conversion.