[][src]Struct orbtk_utils::Rectangle

pub struct Rectangle { /* fields omitted */ }

A Rectangle is normally expressed as a top-left corner and a size

Examples

let rectangle = Rectangle::new((0., 5.),(10., 7.));

assert_eq!(rectangle.x(), 0.);
assert_eq!(rectangle.y(), 5.);
assert_eq!(rectangle.width(), 10.);
assert_eq!(rectangle.height(), 7.);

Implementations

impl Rectangle[src]

pub fn new(position: impl Into<Point>, size: impl Into<Size>) -> Self[src]

Create a new rectangle with the given parameters.

pub fn x(&self) -> f64[src]

Gets x.

pub fn set_x(&mut self, x: impl Into<f64>)[src]

Sets x.

pub fn y(&self) -> f64[src]

Gets y.

pub fn set_y(&mut self, y: impl Into<f64>)[src]

Sets y.

pub fn position(&self) -> Point[src]

Gets position as Point.

pub fn set_position(&mut self, position: impl Into<Point>)[src]

Sets position.

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

Gets the width.

pub fn set_width(&mut self, width: impl Into<f64>)[src]

Sets the width.

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

Gets the height.

pub fn set_height(&mut self, height: impl Into<f64>)[src]

Sets the height.

pub fn size(&self) -> Size[src]

Gets the size with width and height.

pub fn set_size(&mut self, width: impl Into<f64>, height: impl Into<f64>)[src]

Sets the size with width and height.

pub fn contains(&self, point: impl Into<Point>) -> bool[src]

Checks if this rect contains the given point.

pub fn contains_rect(&self, rect: &Rectangle) -> bool[src]

Checks if this rect contains the given rect.

pub fn intersects(&self, rect: &Rectangle) -> bool[src]

Checks if this rect intersects with the given rect.

Trait Implementations

impl Clone for Rectangle[src]

impl Copy for Rectangle[src]

impl Debug for Rectangle[src]

impl Default for Rectangle[src]

impl From<(Point, Size)> for Rectangle[src]

impl From<(f64, f64, f64, f64)> for Rectangle[src]

impl From<(i32, i32, i32, i32)> for Rectangle[src]

impl PartialEq<Rectangle> for Rectangle[src]

impl StructuralPartialEq for Rectangle[src]

Auto Trait Implementations

Blanket Implementations

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

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

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

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

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

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

type Owned = T

The resulting type after obtaining ownership.

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<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.