[][src]Struct smeagol::BoundingBox

pub struct BoundingBox { /* fields omitted */ }

A rectangular region of a Life grid.

Methods

impl BoundingBox[src]

pub fn new(upper_left: Position, lower_right: Position) -> Self[src]

Creates a new bounding box with the given upper-left corner position and lower-right corner position.

Examples

// create a bounding box around a single position
let pos = smeagol::Position::new(0, 0);
let bounding_box = smeagol::BoundingBox::new(pos, pos);

pub fn upper_left(&self) -> Position[src]

Returns the upper left corner position of the bounding box.

pub fn lower_right(&self) -> Position[src]

Returns the lower right corner position of the bounding box.

pub fn combine(&self, other: BoundingBox) -> Self[src]

Combines two bounding boxes, returning a bounding box that surrounds both boxes.

Examples

let p0 = smeagol::Position::new(0, 0);
let p1 = smeagol::Position::new(1, 1);

let bbox0 = smeagol::BoundingBox::new(p0, p0);
let bbox1 = smeagol::BoundingBox::new(p1, p1);

assert_eq!(bbox0.combine(bbox1), smeagol::BoundingBox::new(p0, p1));

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

Intersects two bounding boxes, returning a bounding box that both boxes contain.

pub fn offset(&self, x_offset: i64, y_offset: i64) -> Self[src]

Offsets the bounding box by the given amounts in the x and y directions.

Examples

let p0 = smeagol::Position::new(0, 0);
let p1 = smeagol::Position::new(2, 2);
let bbox = smeagol::BoundingBox::new(p0, p1);
let offset_bbox = bbox.offset(3, 4);

pub fn pad(&self, amount: i64) -> Self[src]

Pads the outside of the bounding box by the given amount.

Panics

Panics if amount < 0.

Examples

let p0 = smeagol::Position::new(0, 0);
let p1 = smeagol::Position::new(2, 2);
let bbox = smeagol::BoundingBox::new(p0, p1);
let padded_bbox = bbox.pad(5);

Trait Implementations

impl PartialEq<BoundingBox> for BoundingBox[src]

impl Ord for BoundingBox[src]

fn max(self, other: Self) -> Self
1.21.0
[src]

Compares and returns the maximum of two values. Read more

fn min(self, other: Self) -> Self
1.21.0
[src]

Compares and returns the minimum of two values. Read more

impl Clone for BoundingBox[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Eq for BoundingBox[src]

impl Copy for BoundingBox[src]

impl PartialOrd<BoundingBox> for BoundingBox[src]

impl Hash for BoundingBox[src]

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0
[src]

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

impl Debug for BoundingBox[src]

Auto Trait Implementations

impl Send for BoundingBox

impl Sync for BoundingBox

Blanket Implementations

impl<T> From for T[src]

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

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

type Owned = T

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

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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

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

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

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

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> FromCast for T[src]

impl<T, U> Cast for T where
    U: FromCast<T>, 
[src]