[−][src]Struct kurbo::Rect
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.
Trait Implementations
impl Shape for Rect
[src]
type BezPathIter = RectPathIter
The iterator resulting from to_bez_path
.
fn to_bez_path(&self, _tolerance: f64) -> RectPathIter
[src]
fn area(&self) -> f64
[src]
fn perimeter(&self, _accuracy: f64) -> f64
[src]
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 bounding_box(&self) -> Rect
[src]
fn as_rect(&self) -> Option<Rect>
[src]
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 From<((f64, f64), (f64, f64))> for Rect
[src]
impl From<Rect> for ((f64, f64), (f64, f64))
[src]
impl Copy for Rect
[src]
impl Clone for Rect
[src]
fn clone(&self) -> Rect
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Default for Rect
[src]
impl Add<Vec2> for Rect
[src]
type Output = Rect
The resulting type after applying the +
operator.
fn add(self, v: Vec2) -> Rect
[src]
impl Sub<Vec2> for Rect
[src]
type Output = Rect
The resulting type after applying the -
operator.
fn sub(self, v: Vec2) -> Rect
[src]
impl Debug for Rect
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
try_from
)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> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,