[−]Struct piet_common::kurbo::Rect
A rectangle.
Fields
x0: f64The minimum x coordinate (left edge).
y0: f64The minimum y coordinate (top edge in y-down spaces).
x1: f64The maximum x coordinate (right edge).
y1: f64The maximum y coordinate (bottom edge in y-down spaces).
Methods
impl Rect
pub fn new(x0: f64, y0: f64, x1: f64, y1: f64) -> Rect
A new rectangle from minimum and maximum coordinates.
pub fn from_points(p0: Point, p1: Point) -> Rect
A new rectangle from two points.
The result will have non-negative width and height.
pub fn from_origin_size(origin: Point, size: Size) -> Rect
A new rectangle from origin and size.
The result will have non-negative width and height.
pub fn with_origin(self, origin: Point) -> Rect
Create a new Rect with the same size as self and a new origin.
pub fn with_size(self, size: Size) -> Rect
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 vector.
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 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.
Trait Implementations
impl Add<Vec2> for Rect
impl Sub<Vec2> for Rect
impl Debug for Rect
impl Default for Rect
impl Shape for Rect
type BezPathIter = RectPathIter
The iterator resulting from to_bez_path.
fn to_bez_path(&self, _tolerance: f64) -> RectPathIter
fn area(&self) -> f64
fn perimeter(&self, _accuracy: f64) -> f64
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 bounding_box(&self) -> Rect
fn as_rect(&self) -> Option<Rect>
fn into_bez_path(self, tolerance: f64) -> BezPath
fn as_line(&self) -> Option<Line>
If the shape is a line, 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(&self) -> Rect
fn clone_from(&mut self, source: &Self)1.0.0[src]
Performs copy-assignment from source. Read more
impl Copy for Rect
impl From<((f64, f64), (f64, f64))> for Rect
impl From<(Point, Point)> for Rect
impl From<(Point, Size)> for Rect
Auto Trait Implementations
Blanket Implementations
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T[src]
fn clone_into(&self, target: &mut T)[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> From<T> for T[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> RoundFrom<T> for T[src]
fn round_from(x: T) -> T[src]
impl<T, U> RoundInto<U> for T where
U: RoundFrom<T>, [src]
U: RoundFrom<T>,