diff options
Diffstat (limited to 'native/src/renderer.rs')
-rw-r--r-- | native/src/renderer.rs | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/native/src/renderer.rs b/native/src/renderer.rs index ef64ac36..39c1b4c7 100644 --- a/native/src/renderer.rs +++ b/native/src/renderer.rs @@ -50,7 +50,7 @@ pub struct Quad { pub bounds: Rectangle, /// The border radius of the [`Quad`]. - pub border_radius: f32, + pub border_radius: QuadBorderRadius, /// The border width of the [`Quad`]. pub border_width: f32, @@ -59,6 +59,30 @@ pub struct Quad { pub border_color: Color, } +/// The border radi for the corners of a [`Quad`] in the order: +/// top-left, top-right, bottom-right, bottom-left. +#[derive(Debug, Clone, Copy, PartialEq)] +pub struct QuadBorderRadius([f32; 4]); + +impl QuadBorderRadius { + /// Convert the corners of the Quad into an array [top_left, top_right, bottom_left, bottom_right]. + pub fn to_array(self) -> [f32; 4] { + self.0 + } +} + +impl From<f32> for QuadBorderRadius { + fn from(w: f32) -> Self { + Self([w; 4]) + } +} + +impl From<[f32; 4]> for QuadBorderRadius { + fn from(radi: [f32; 4]) -> Self { + Self(radi) + } +} + /// The styling attributes of a [`Renderer`]. #[derive(Debug, Clone, Copy, PartialEq)] pub struct Style { |