diff options
-rw-r--r-- | graphics/src/renderer.rs | 2 | ||||
-rw-r--r-- | native/src/renderer.rs | 25 |
2 files changed, 13 insertions, 14 deletions
diff --git a/graphics/src/renderer.rs b/graphics/src/renderer.rs index 46d37cd6..ff0dad2b 100644 --- a/graphics/src/renderer.rs +++ b/graphics/src/renderer.rs @@ -109,7 +109,7 @@ where self.primitives.push(Primitive::Quad { bounds: quad.bounds, background: background.into(), - border_radius: quad.border_radius.to_array(), + border_radius: quad.border_radius.into(), border_width: quad.border_width, border_color: quad.border_color, }); diff --git a/native/src/renderer.rs b/native/src/renderer.rs index 39c1b4c7..5e776be6 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: QuadBorderRadius, + pub border_radius: BorderRadius, /// The border width of the [`Quad`]. pub border_width: f32, @@ -59,30 +59,29 @@ pub struct Quad { pub border_color: Color, } -/// The border radi for the corners of a [`Quad`] in the order: +/// The border radi for the corners of a graphics primitive 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 - } -} +#[derive(Debug, Clone, Copy, PartialEq, Default)] +pub struct BorderRadius([f32; 4]); -impl From<f32> for QuadBorderRadius { +impl From<f32> for BorderRadius { fn from(w: f32) -> Self { Self([w; 4]) } } -impl From<[f32; 4]> for QuadBorderRadius { +impl From<[f32; 4]> for BorderRadius { fn from(radi: [f32; 4]) -> Self { Self(radi) } } +impl From<BorderRadius> for [f32; 4] { + fn from(radi: BorderRadius) -> Self { + radi.0 + } +} + /// The styling attributes of a [`Renderer`]. #[derive(Debug, Clone, Copy, PartialEq)] pub struct Style { |