summaryrefslogtreecommitdiffstats
path: root/native/src/renderer.rs
diff options
context:
space:
mode:
authorLibravatar Robert Krahn <robert.krahn@gmail.com>2022-11-03 00:35:01 +0100
committerLibravatar Robert Krahn <robert.krahn@gmail.com>2022-11-03 22:48:26 +0100
commitc0596179bd8582e4f4b5289cdeee8de4fa3de464 (patch)
treeb1ed80cf49aa846ba7a93cc97128c3ec6eadd123 /native/src/renderer.rs
parentd222b5c8b0befab665c20ba0112b28199df0ae44 (diff)
downloadiced-c0596179bd8582e4f4b5289cdeee8de4fa3de464.tar.gz
iced-c0596179bd8582e4f4b5289cdeee8de4fa3de464.tar.bz2
iced-c0596179bd8582e4f4b5289cdeee8de4fa3de464.zip
non uniform border radius for quads
Diffstat (limited to '')
-rw-r--r--native/src/renderer.rs26
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 {