This commit is contained in:
griffi-gh 2024-03-23 15:09:05 +01:00
parent 15d92a2c74
commit 897a574931
2 changed files with 18 additions and 12 deletions

View file

@ -1,4 +1,4 @@
use crate::rect::FillColor; use crate::rect::{Corners, FillColor};
pub mod point; pub mod point;
pub mod layer; pub mod layer;
@ -20,10 +20,10 @@ pub struct Frame {
layers: Vec<FrameLayer> layers: Vec<FrameLayer>
} }
impl<T: Into<FillColor>> From<T> for Frame { impl<T: Into<RectLayer>> From<T> for Frame {
fn from(color: T) -> Self { fn from(layer: T) -> Self {
let mut frame = Self::default(); let mut frame = Self::default();
frame.add(RectLayer::from_color(color)); frame.add(layer.into());
frame frame
} }
} }

View file

@ -20,11 +20,17 @@ pub enum FrameLayer {
#[derive(Clone, Copy)] #[derive(Clone, Copy)]
pub struct RectLayer { pub struct RectLayer {
color: FillColor, pub color: FillColor,
image: Option<ImageHandle>, pub image: Option<ImageHandle>,
top_left: FramePoint2d, pub top_left: FramePoint2d,
bottom_right: FramePoint2d, pub bottom_right: FramePoint2d,
corner_radius: Corners<f32>, pub corner_radius: Corners<f32>,
}
impl<T: Into<FillColor>> From<T> for RectLayer {
fn from(color: T) -> Self {
Self::from_color(color)
}
} }
impl RectLayer { impl RectLayer {
@ -65,9 +71,9 @@ impl Default for RectLayer {
Self { Self {
color: FillColor::default(), color: FillColor::default(),
image: None, image: None,
top_left: FramePoint2d::default(), top_left: FramePoint2d::TOP_LEFT,
bottom_right: FramePoint2d::default(), bottom_right: FramePoint2d::BOTTOM_RIGHT,
corner_radius: Corners::default(), corner_radius: Corners::all(0.),
} }
} }
} }