Struct RoundedRect
pub struct RoundedRect { /* private fields */ }Expand description
A rectangle with rounded corners.
By construction the rounded rectangle will have non-negative dimensions and radii clamped to half size of the rect. The rounded rectangle can have different radii for each corner.
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
impl RoundedRect
pub fn new(
x0: f64,
y0: f64,
x1: f64,
y1: f64,
radii: impl Into<RoundedRectRadii>,
) -> RoundedRect
pub fn new( 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
pub fn from_rect(rect: Rect, radii: impl Into<RoundedRectRadii>) -> RoundedRect
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
pub fn from_points( p0: impl Into<Point>, p1: impl Into<Point>, radii: impl Into<RoundedRectRadii>, ) -> RoundedRect
A new rectangle from two Points.
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
pub fn from_origin_size( 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 const fn radii(&self) -> RoundedRectRadii
pub const fn radii(&self) -> RoundedRectRadii
Radii of the rounded corners.
Trait Implementations§
§impl Add<Vec2> for RoundedRect
impl Add<Vec2> for RoundedRect
§type Output = RoundedRect
type Output = RoundedRect
+ operator.§fn add(self, v: Vec2) -> RoundedRect
fn add(self, v: Vec2) -> RoundedRect
+ operation. Read more§impl Clone for RoundedRect
impl Clone for RoundedRect
§fn clone(&self) -> RoundedRect
fn clone(&self) -> RoundedRect
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for RoundedRect
impl Debug for RoundedRect
§impl Default for RoundedRect
impl Default for RoundedRect
§fn default() -> RoundedRect
fn default() -> RoundedRect
§impl Mul<RoundedRect> for TranslateScale
impl Mul<RoundedRect> for TranslateScale
§type Output = RoundedRect
type Output = RoundedRect
* operator.§fn mul(self, other: RoundedRect) -> RoundedRect
fn mul(self, other: RoundedRect) -> RoundedRect
* operation. Read more§impl PartialEq for RoundedRect
impl PartialEq for RoundedRect
§impl Shape for RoundedRect
impl Shape for RoundedRect
§type PathElementsIter<'iter> = RoundedRectPathIter
type PathElementsIter<'iter> = RoundedRectPathIter
path_elements method.§fn path_elements(&self, tolerance: f64) -> RoundedRectPathIter
fn path_elements(&self, tolerance: f64) -> RoundedRectPathIter
§fn bounding_box(&self) -> Rect
fn bounding_box(&self) -> Rect
§fn as_rounded_rect(&self) -> Option<RoundedRect>
fn as_rounded_rect(&self) -> Option<RoundedRect>
§fn into_path(self, tolerance: f64) -> BezPathwhere
Self: Sized,
fn into_path(self, tolerance: f64) -> BezPathwhere
Self: Sized,
§fn path_segments(&self, tolerance: f64) -> Segments<Self::PathElementsIter<'_>> ⓘ
fn path_segments(&self, tolerance: f64) -> Segments<Self::PathElementsIter<'_>> ⓘ
§fn as_path_slice(&self) -> Option<&[PathEl]>
fn as_path_slice(&self) -> Option<&[PathEl]>
§impl Sub<Vec2> for RoundedRect
impl Sub<Vec2> for RoundedRect
§type Output = RoundedRect
type Output = RoundedRect
- operator.§fn sub(self, v: Vec2) -> RoundedRect
fn sub(self, v: Vec2) -> RoundedRect
- operation. Read moreimpl Copy for RoundedRect
impl StructuralPartialEq for RoundedRect
Auto Trait Implementations§
impl Freeze for RoundedRect
impl RefUnwindSafe for RoundedRect
impl Send for RoundedRect
impl Sync for RoundedRect
impl Unpin for RoundedRect
impl UnsafeUnpin for RoundedRect
impl UnwindSafe for RoundedRect
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more