[−][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 const ZERO: Rect
[src]
The empty rectangle at the origin.
pub const 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: impl Into<Point>, p1: impl Into<Point>) -> Rect
[src]
A new rectangle from two points.
The result will have non-negative width and height.
pub fn from_origin_size(origin: impl Into<Point>, size: impl Into<Size>) -> Rect
[src]
A new rectangle from origin and size.
The result will have non-negative width and height.
pub fn with_origin(self, origin: impl Into<Point>) -> Rect
[src]
Create a new Rect
with the same size as self
and a new origin.
pub fn with_size(self, size: impl Into<Size>) -> Rect
[src]
Create a new Rect
with the same origin as self
and a new size.
pub fn inset(self, insets: impl Into<Insets>) -> Rect
[src]
Create a new Rect
by applying the Insets
.
This will not preserve negative width and height.
Examples
use kurbo::Rect; let inset_rect = Rect::new(0., 0., 10., 10.,).inset(2.); assert_eq!(inset_rect.width(), 14.0); assert_eq!(inset_rect.x0, -2.0); assert_eq!(inset_rect.x1, 12.0);
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 min_x(&self) -> f64
[src]
Returns the minimum value for the x-coordinate of the rectangle.
pub fn max_x(&self) -> f64
[src]
Returns the maximum value for the x-coordinate of the rectangle.
pub fn min_y(&self) -> f64
[src]
Returns the minimum value for the y-coordinate of the rectangle.
pub fn max_y(&self) -> f64
[src]
Returns the maximum value for the y-coordinate of the rectangle.
pub fn origin(&self) -> Point
[src]
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
[src]
The size of the rectangle.
pub fn area(&self) -> f64
[src]
The area of the rectangle.
pub fn center(&self) -> Point
[src]
The center point of the rectangle.
pub fn contains(&self, point: Point) -> bool
[src]
Returns true
if point
lies within self
.
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: Point) -> 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.
pub fn round(self) -> Rect
[src]
A new Rect
, with each coordinate value rounded to the nearest integer.
pub fn to_rounded_rect(self, radius: f64) -> RoundedRect
[src]
Creates a new RoundedRect
from this Rect
and the provided
corner radius.
Trait Implementations
impl Add<Insets> for Rect
[src]
type Output = Rect
The resulting type after applying the +
operator.
fn add(self, other: Insets) -> Rect
[src]
impl Add<Rect> for Insets
[src]
type Output = Rect
The resulting type after applying the +
operator.
fn add(self, other: Rect) -> 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 Clone for Rect
[src]
fn clone(&self) -> Rect
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for Rect
[src]
impl Debug for Rect
[src]
impl Default for Rect
[src]
impl From<(Point, Point)> for Rect
[src]
impl From<(Point, Size)> for Rect
[src]
impl Mul<Rect> for TranslateScale
[src]
type Output = Rect
The resulting type after applying the *
operator.
fn mul(self, other: Rect) -> Rect
[src]
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: Point) -> 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]
fn as_rounded_rect(&self) -> Option<RoundedRect>
[src]
fn as_circle(&self) -> Option<Circle>
[src]
fn as_path_slice(&self) -> Option<&[PathEl]>
[src]
impl Sub<Insets> for Rect
[src]
type Output = Rect
The resulting type after applying the -
operator.
fn sub(self, other: Insets) -> Rect
[src]
impl Sub<Rect> for Insets
[src]
type Output = Rect
The resulting type after applying the -
operator.
fn sub(self, other: Rect) -> Rect
[src]
impl Sub<Rect> for Rect
[src]
type Output = Insets
The resulting type after applying the -
operator.
fn sub(self, other: Rect) -> Insets
[src]
impl Sub<Vec2> for Rect
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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>,