Struct kurbo::RoundedRect [−][src]
A rectangle with equally rounded corners.
By construction the rounded rectangle will have non-negative dimensions and radii clamped to half size of the rect.
The easiest way to create a RoundedRect
is often to create a Rect
,
and then call to_rounded_rect
.
use kurbo::{RoundedRect, RoundedRectRadii}; // Create a rounded rectangle with a single radius for all corners: RoundedRect::new(0.0, 0.0, 10.0, 10.0, 5.0); // Or, specify different radii for each corner, clockwise from the top-left: RoundedRect::new(0.0, 0.0, 10.0, 10.0, (1.0, 2.0, 3.0, 4.0));
Implementations
impl RoundedRect
[src]
pub fn new(
x0: f64,
y0: f64,
x1: f64,
y1: f64,
radii: impl Into<RoundedRectRadii>
) -> RoundedRect
[src]
x0: f64,
y0: f64,
x1: f64,
y1: f64,
radii: impl Into<RoundedRectRadii>
) -> RoundedRect
A new rectangle from minimum and maximum coordinates.
The result will have non-negative width, height and radii.
pub fn from_rect(rect: Rect, radii: impl Into<RoundedRectRadii>) -> RoundedRect
[src]
A new rounded rectangle from a rectangle and corner radii.
The result will have non-negative width, height and radii.
See also Rect::to_rounded_rect
, which offers the same utility.
pub fn from_points(
p0: impl Into<Point>,
p1: impl Into<Point>,
radii: impl Into<RoundedRectRadii>
) -> RoundedRect
[src]
p0: impl Into<Point>,
p1: impl Into<Point>,
radii: impl Into<RoundedRectRadii>
) -> RoundedRect
A new rectangle from two Point
s.
The result will have non-negative width, height and radius.
pub fn from_origin_size(
origin: impl Into<Point>,
size: impl Into<Size>,
radii: impl Into<RoundedRectRadii>
) -> RoundedRect
[src]
origin: impl Into<Point>,
size: impl Into<Size>,
radii: impl Into<RoundedRectRadii>
) -> RoundedRect
A new rectangle from origin and size.
The result will have non-negative width, height and radius.
pub fn width(&self) -> f64
[src]
The width of the rectangle.
pub fn height(&self) -> f64
[src]
The height of the rectangle.
pub fn radii(&self) -> RoundedRectRadii
[src]
Radii of the rounded corners.
pub fn rect(&self) -> Rect
[src]
The (non-rounded) rectangle.
pub fn origin(&self) -> Point
[src]
The origin of the rectangle.
This is the top left corner in a y-down space.
pub fn center(&self) -> Point
[src]
The center point of the rectangle.
pub fn is_finite(&self) -> bool
[src]
Is this rounded rectangle finite?
pub fn is_nan(&self) -> bool
[src]
Is this rounded rectangle NaN?
Trait Implementations
impl Add<Vec2> for RoundedRect
[src]
type Output = RoundedRect
The resulting type after applying the +
operator.
fn add(self, v: Vec2) -> RoundedRect
[src]
impl Clone for RoundedRect
[src]
fn clone(&self) -> RoundedRect
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for RoundedRect
[src]
impl Debug for RoundedRect
[src]
impl Default for RoundedRect
[src]
fn default() -> RoundedRect
[src]
impl<'de> Deserialize<'de> for RoundedRect
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl Mul<RoundedRect> for TranslateScale
[src]
type Output = RoundedRect
The resulting type after applying the *
operator.
fn mul(self, other: RoundedRect) -> RoundedRect
[src]
impl PartialEq<RoundedRect> for RoundedRect
[src]
fn eq(&self, other: &RoundedRect) -> bool
[src]
fn ne(&self, other: &RoundedRect) -> bool
[src]
impl Serialize for RoundedRect
[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl Shape for RoundedRect
[src]
type PathElementsIter = RoundedRectPathIter
The iterator returned by the path_elements
method. Read more
fn path_elements(&self, tolerance: f64) -> RoundedRectPathIter
[src]
fn area(&self) -> f64
[src]
fn perimeter(&self, _accuracy: f64) -> f64
[src]
fn winding(&self, pt: Point) -> i32
[src]
fn bounding_box(&self) -> Rect
[src]
fn as_rounded_rect(&self) -> Option<RoundedRect>
[src]
fn to_path(&self, tolerance: f64) -> BezPath
[src]
fn into_path(self, tolerance: f64) -> BezPath
[src]
fn path_segments(&self, tolerance: f64) -> Segments<Self::PathElementsIter>ⓘ
[src]
fn contains(&self, pt: Point) -> bool
[src]
fn as_line(&self) -> Option<Line>
[src]
fn as_rect(&self) -> Option<Rect>
[src]
fn as_circle(&self) -> Option<Circle>
[src]
fn as_path_slice(&self) -> Option<&[PathEl]>
[src]
impl StructuralPartialEq for RoundedRect
[src]
impl Sub<Vec2> for RoundedRect
[src]
type Output = RoundedRect
The resulting type after applying the -
operator.
fn sub(self, v: Vec2) -> RoundedRect
[src]
Auto Trait Implementations
impl RefUnwindSafe for RoundedRect
impl Send for RoundedRect
impl Sync for RoundedRect
impl Unpin for RoundedRect
impl UnwindSafe for RoundedRect
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,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut 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.
pub 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>,