[][src]Struct 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[src]

pub fn new(x0: f64, y0: f64, x1: f64, y1: f64) -> Rect[src]

A new rectangle from minimum and maximum coordinates.

pub fn from_points(p0: Vec2, p1: Vec2) -> Rect[src]

A new rectangle from two points.

The result will have non-negative width and height.

pub fn from_origin_size(origin: Vec2, size: Vec2) -> Rect[src]

A new rectangle from origin and size.

The result will have non-negative width and height.

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

The width of the rectangle.

Note: nothing forbids negative width.

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

The height of the rectangle.

Note: nothing forbids negative height.

pub fn origin(&self) -> Vec2[src]

The origin of the vector.

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

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

The size of the rectangle, as a vector.

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

The area of the rectangle.

pub fn center(&self) -> Vec2[src]

The center point of the rectangle.

pub fn abs(&self) -> Rect[src]

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[src]

The smallest rectangle enclosing two rectangles.

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

pub fn union_pt(&self, pt: Vec2) -> Rect[src]

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[src]

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[src]

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.

Trait Implementations

impl Shape for Rect[src]

type BezPathIter = RectPathIter

The iterator resulting from to_bez_path.

fn winding(&self, pt: Vec2) -> i32[src]

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[src]

fn as_line(&self) -> Option<Line>[src]

If the shape is a line, make it available.

fn as_circle(&self) -> Option<Circle>[src]

If the shape is a circle, make it available.

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

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

impl Clone for Rect[src]

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

Performs copy-assignment from source. Read more

impl Copy for Rect[src]

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

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

impl Default for Rect[src]

impl Debug for Rect[src]

impl Sub<Vec2> for Rect[src]

type Output = Rect

The resulting type after applying the - operator.

impl Add<Vec2> for Rect[src]

type Output = Rect

The resulting type after applying the + operator.

Auto Trait Implementations

impl Send for Rect

impl Sync for Rect

Blanket Implementations

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

type Owned = T

The resulting type after obtaining ownership.

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

impl<T> From<T> for 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]