From 899774a7e1824feeeb3f52f434b76b347d4afc06 Mon Sep 17 00:00:00 2001 From: griffi-gh Date: Sat, 23 Mar 2024 23:32:21 +0100 Subject: [PATCH] document corner radius --- hui/src/draw/corner_radius.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/hui/src/draw/corner_radius.rs b/hui/src/draw/corner_radius.rs index 32ac329..4448712 100644 --- a/hui/src/draw/corner_radius.rs +++ b/hui/src/draw/corner_radius.rs @@ -3,6 +3,7 @@ use crate::rect::Corners; //TODO uneven corners (separate width/height for each corner) +/// Calculate the number of points based on the maximum corner radius fn point_count(corners: Corners) -> NonZeroU16 { //Increase for higher quality const VTX_PER_CORER_RADIUS_PIXEL: f32 = 0.5; @@ -11,19 +12,31 @@ fn point_count(corners: Corners) -> NonZeroU16 { ).unwrap() } +/// Low-level options for rendering rounded corners #[derive(Clone, Copy, Debug, PartialEq)] pub struct RoundedCorners { + /// Corner radius of each corner pub radius: Corners, + + /// Number of points to use for each corner + /// + /// This value affects all corners, regardless of their individual radius pub point_count: NonZeroU16, } impl From> for RoundedCorners { + /// Create a new `RoundedCorners` from [`Corners`](crate::rect::Corners) + /// + /// Point count will be calculated automatically based on the maximum radius fn from(radius: Corners) -> Self { Self::from_radius(radius) } } impl RoundedCorners { + /// Create a new `RoundedCorners` from [`Corners`](crate::rect::Corners) + /// + /// Point count will be calculated automatically based on the maximum radius pub fn from_radius(radius: Corners) -> Self { Self { radius,