[]Struct piet_common::kurbo::Rect

pub struct Rect {
    pub x0: f64,
    pub y0: f64,
    pub x1: f64,
    pub y1: f64,
}

A rectangle.

Fields

x0: f64

The minimum x coordinate (left edge).

y0: f64

The minimum y coordinate (top edge in y-down spaces).

x1: f64

The maximum x coordinate (right edge).

y1: f64

The maximum y coordinate (bottom edge in y-down spaces).

Methods

impl Rect

pub const ZERO: Rect

The empty rectangle at the origin.

pub const fn new(x0: f64, y0: f64, x1: f64, y1: f64) -> Rect

A new rectangle from minimum and maximum coordinates.

pub fn from_points<impl Into, impl Into>(
    p0: impl Into,
    p1: impl Into
) -> Rect where
    impl Into: Into<Point>, 

A new rectangle from two points.

The result will have non-negative width and height.

pub fn from_origin_size<impl Into, impl Into>(
    origin: impl Into,
    size: impl Into
) -> Rect where
    impl Into: Into<Point>,
    impl Into: Into<Size>, 

A new rectangle from origin and size.

The result will have non-negative width and height.

pub fn with_origin<impl Into>(self, origin: impl Into) -> Rect where
    impl Into: Into<Point>, 

Create a new Rect with the same size as self and a new origin.

pub fn with_size<impl Into>(self, size: impl Into) -> Rect where
    impl Into: Into<Size>, 

Create a new Rect with the same origin as self and a new size.

pub fn width(&self) -> f64

The width of the rectangle.

Note: nothing forbids negative width.

pub fn height(&self) -> f64

The height of the rectangle.

Note: nothing forbids negative height.

pub fn origin(&self) -> Point

The origin of the rectangle.

This is the top left corner in a y-down space and with non-negative width and height.

pub fn size(&self) -> Size

The size of the rectangle, as a vector.

pub fn area(&self) -> f64

The area of the rectangle.

pub fn center(&self) -> Point

The center point of the rectangle.

pub fn contains(&self, point: Point) -> bool

Returns true if point lies within self.

pub fn abs(&self) -> Rect

Take absolute value of width and height.

The resulting rect has the same extents as the original, but is guaranteed to have non-negative width and height.

pub fn union(&self, other: Rect) -> Rect

The smallest rectangle enclosing two rectangles.

Results are valid only if width and height are non-negative.

pub fn union_pt(&self, pt: Point) -> Rect

Compute the union with one point.

This method includes the perimeter of zero-area rectangles. Thus, a succession of union_pt operations on a series of points yields their enclosing rectangle.

Results are valid only if width and height are non-negative.

pub fn intersect(&self, other: Rect) -> Rect

The intersection of two rectangles.

The result is zero-area if either input has negative width or height. The result always has non-negative width and height.

pub fn inflate(&self, width: f64, height: f64) -> Rect

Expand a rectangle by a constant amount in both directions.

The logic simply applies the amount in each direction. If rectangle area or added dimensions are negative, this could give odd results.

pub fn round(self) -> Rect

A new Rect, with each coordinate value rounded to the nearest integer.

Trait Implementations

impl From<(Point, Point)> for Rect

impl From<(Point, Size)> for Rect

impl Copy for Rect

impl Mul<Rect> for TranslateScale

type Output = Rect

The resulting type after applying the * operator.

impl Default for Rect

impl Debug for Rect

impl Shape for Rect

type BezPathIter = RectPathIter

The iterator resulting from to_bez_path.

fn winding(&self, pt: Point) -> i32

Note: this function is carefully designed so that if the plane is tiled with rectangles, the winding number will be nonzero for exactly one of them.

fn into_bez_path(self, tolerance: f64) -> BezPath

Convert into a Bézier path. Read more

fn as_line(&self) -> Option<Line>

If the shape is a line, make it available.

fn as_rounded_rect(&self) -> Option<RoundedRect>

If the shape is a rounded rectangle, make it available.

fn as_circle(&self) -> Option<Circle>

If the shape is a circle, make it available.

fn as_path_slice(&self) -> Option<&[PathEl]>

If the shape is stored as a slice of path elements, make that available. Read more

impl Clone for Rect

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

Performs copy-assignment from source. Read more

impl Add<Vec2> for Rect

type Output = Rect

The resulting type after applying the + operator.

impl Sub<Vec2> for Rect

type Output = Rect

The resulting type after applying the - operator.

Auto Trait Implementations

impl Sync for Rect

impl Send for Rect

impl Unpin for Rect

impl RefUnwindSafe for Rect

impl UnwindSafe for Rect

Blanket Implementations

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

type Owned = T

The resulting type after obtaining ownership.

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

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

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.

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

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

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

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

impl<T, U> RoundInto<U> for T where
    U: RoundFrom<T>, 
[src]