use bevy_ui::{BorderRadius, Val};
#[derive(Debug, Clone, Copy, Default, PartialEq)]
pub enum RoundedCorners {
None,
#[default]
All,
TopLeft,
TopRight,
BottomRight,
BottomLeft,
Top,
Right,
Bottom,
Left,
}
impl RoundedCorners {
pub fn to_border_radius(&self, radius: f32) -> BorderRadius {
let radius = Val::Px(radius);
let zero = Val::ZERO;
match self {
RoundedCorners::None => BorderRadius::all(zero),
RoundedCorners::All => BorderRadius::all(radius),
RoundedCorners::TopLeft => BorderRadius {
top_left: radius,
top_right: zero,
bottom_right: zero,
bottom_left: zero,
},
RoundedCorners::TopRight => BorderRadius {
top_left: zero,
top_right: radius,
bottom_right: zero,
bottom_left: zero,
},
RoundedCorners::BottomRight => BorderRadius {
top_left: zero,
top_right: zero,
bottom_right: radius,
bottom_left: zero,
},
RoundedCorners::BottomLeft => BorderRadius {
top_left: zero,
top_right: zero,
bottom_right: zero,
bottom_left: radius,
},
RoundedCorners::Top => BorderRadius {
top_left: radius,
top_right: radius,
bottom_right: zero,
bottom_left: zero,
},
RoundedCorners::Right => BorderRadius {
top_left: zero,
top_right: radius,
bottom_right: radius,
bottom_left: zero,
},
RoundedCorners::Bottom => BorderRadius {
top_left: zero,
top_right: zero,
bottom_right: radius,
bottom_left: radius,
},
RoundedCorners::Left => BorderRadius {
top_left: radius,
top_right: zero,
bottom_right: zero,
bottom_left: radius,
},
}
}
}