Struct math2d::RoundedRect
source · Expand description
Represents a rectangle with rounded corners described by ellipses that touch the internal edges of the rectangle at the tangent points.
Fields§
§rect: Rectf
The overall rectangle containing this rounded rectangle
radius_x: f32
The x-radius of the ellipse nested in each corner.
radius_y: f32
The y-radius of the ellipse nested in each corner.
Implementations§
source§impl RoundedRect
impl RoundedRect
sourcepub fn new(rect: impl Into<Rectf>, rx: f32, ry: f32) -> RoundedRect
pub fn new(rect: impl Into<Rectf>, rx: f32, ry: f32) -> RoundedRect
Constructs the rounded rectangle from its components
sourcepub fn corner_ellipse(&self, corner: RectCorner) -> Ellipse
pub fn corner_ellipse(&self, corner: RectCorner) -> Ellipse
Gets the ellipse that resides in the given corner of the rectangle
sourcepub fn contains_point(&self, point: impl Into<Point2f>) -> bool
pub fn contains_point(&self, point: impl Into<Point2f>) -> bool
Checks if the given point resides within the rounded rectangle, taking care to exclude the parts of the corners that are excluded from the ellipses.
sourcepub fn contains_point_crude(&self, point: impl Into<Point2f>) -> bool
pub fn contains_point_crude(&self, point: impl Into<Point2f>) -> bool
Checks if the point resides within the rectangle without checking the
corner cases of being inside the square rectangle but not inside the
rounded corners. This function may be decently faster than
contains_point
.
Trait Implementations§
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 more