Trait Region

Source
pub trait Region {
    // Required methods
    fn left(&self) -> i32;
    fn top(&self) -> i32;
    fn width(&self) -> u32;
    fn height(&self) -> u32;

    // Provided methods
    fn right(&self) -> i32 { ... }
    fn bottom(&self) -> i32 { ... }
    fn is_square(&self) -> bool { ... }
    fn contains(&self, x: i32, y: i32) -> bool { ... }
    fn center(&self) -> Point2<i32> { ... }
    fn top_left(&self) -> Point2<i32> { ... }
    fn square(&self) -> u32 { ... }
}
Expand description

A trait defining a rectangular region with methods to access its properties.

Required Methods§

Source

fn left(&self) -> i32

Returns the left coordinate of the region.

Source

fn top(&self) -> i32

Returns the top coordinate of the region.

Source

fn width(&self) -> u32

Returns the width of the region.

Source

fn height(&self) -> u32

Returns the height of the region.

Provided Methods§

Source

fn right(&self) -> i32

Returns the right coordinate of the region.

Source

fn bottom(&self) -> i32

Returns the bottom coordinate of the region.

Source

fn is_square(&self) -> bool

Checks if the region is square.

Source

fn contains(&self, x: i32, y: i32) -> bool

Checks if the region contains a point with coordinates (x, y).

Source

fn center(&self) -> Point2<i32>

Returns the center point of the region.

Source

fn top_left(&self) -> Point2<i32>

Returns the top-left corner of the region as a point.

Source

fn square(&self) -> u32

Returns the square area of the region.

Implementors§