Struct kurbo::RoundedRect
source · pub struct RoundedRect { /* private fields */ }
Expand description
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§
source§impl RoundedRect
impl RoundedRect
sourcepub 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.
sourcepub 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.
sourcepub 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 Point
s.
The result will have non-negative width, height and radius.
sourcepub 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.
sourcepub fn radii(&self) -> RoundedRectRadii
pub fn radii(&self) -> RoundedRectRadii
Radii of the rounded corners.
Trait Implementations§
source§impl Add<Vec2> for RoundedRect
impl Add<Vec2> for RoundedRect
§type Output = RoundedRect
type Output = RoundedRect
+
operator.source§impl Clone for RoundedRect
impl Clone for RoundedRect
source§fn clone(&self) -> RoundedRect
fn clone(&self) -> RoundedRect
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for RoundedRect
impl Debug for RoundedRect
source§impl Default for RoundedRect
impl Default for RoundedRect
source§fn default() -> RoundedRect
fn default() -> RoundedRect
source§impl<'de> Deserialize<'de> for RoundedRect
impl<'de> Deserialize<'de> for RoundedRect
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
source§impl JsonSchema for RoundedRect
impl JsonSchema for RoundedRect
source§fn schema_name() -> String
fn schema_name() -> String
source§fn json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &mut SchemaGenerator) -> Schema
source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref
keyword. Read moresource§impl Mul<RoundedRect> for TranslateScale
impl Mul<RoundedRect> for TranslateScale
§type Output = RoundedRect
type Output = RoundedRect
*
operator.source§fn mul(self, other: RoundedRect) -> RoundedRect
fn mul(self, other: RoundedRect) -> RoundedRect
*
operation. Read moresource§impl PartialEq<RoundedRect> for RoundedRect
impl PartialEq<RoundedRect> for RoundedRect
source§fn eq(&self, other: &RoundedRect) -> bool
fn eq(&self, other: &RoundedRect) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl Serialize for RoundedRect
impl Serialize for RoundedRect
source§impl Shape for RoundedRect
impl Shape for RoundedRect
§type PathElementsIter<'iter> = RoundedRectPathIter
type PathElementsIter<'iter> = RoundedRectPathIter
path_elements
method.source§fn path_elements(&self, tolerance: f64) -> RoundedRectPathIter
fn path_elements(&self, tolerance: f64) -> RoundedRectPathIter
source§fn bounding_box(&self) -> Rect
fn bounding_box(&self) -> Rect
source§fn as_rounded_rect(&self) -> Option<RoundedRect>
fn as_rounded_rect(&self) -> Option<RoundedRect>
source§fn path_segments(&self, tolerance: f64) -> Segments<Self::PathElementsIter<'_>> ⓘ
fn path_segments(&self, tolerance: f64) -> Segments<Self::PathElementsIter<'_>> ⓘ
source§impl Sub<Vec2> for RoundedRect
impl Sub<Vec2> for RoundedRect
§type Output = RoundedRect
type Output = RoundedRect
-
operator.