1use rootvg_core::color::PackedSrgb;
6
7#[derive(Debug, Clone, Copy, PartialEq, Default)]
9pub struct Border {
10 pub color: PackedSrgb,
12
13 pub width: f32,
15
16 pub radius: Radius,
18}
19
20#[repr(C)]
22#[derive(Debug, Clone, Copy, PartialEq, Default)]
23pub struct Radius {
24 pub top_left: f32,
25 pub top_right: f32,
26 pub bottom_right: f32,
27 pub bottom_left: f32,
28}
29
30impl Radius {
31 pub const fn zero() -> Self {
32 Self {
33 top_left: 0.0,
34 top_right: 0.0,
35 bottom_right: 0.0,
36 bottom_left: 0.0,
37 }
38 }
39}
40
41impl From<f32> for Radius {
42 fn from(w: f32) -> Self {
43 Self {
44 top_left: w,
45 top_right: w,
46 bottom_right: w,
47 bottom_left: w,
48 }
49 }
50}
51
52impl From<u8> for Radius {
53 fn from(w: u8) -> Self {
54 Self {
55 top_left: f32::from(w),
56 top_right: f32::from(w),
57 bottom_right: f32::from(w),
58 bottom_left: f32::from(w),
59 }
60 }
61}
62
63impl From<[f32; 4]> for Radius {
64 fn from(radi: [f32; 4]) -> Self {
65 Self {
66 top_left: radi[0],
67 top_right: radi[1],
68 bottom_right: radi[2],
69 bottom_left: radi[3],
70 }
71 }
72}
73
74impl From<Radius> for [f32; 4] {
75 fn from(radi: Radius) -> Self {
76 [
77 radi.top_left,
78 radi.top_right,
79 radi.bottom_right,
80 radi.bottom_left,
81 ]
82 }
83}