This commit is contained in:
griffi-gh 2024-03-23 15:09:05 +01:00
parent bbc1d9f1ff
commit 7bfd12749b
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 layer;
@ -20,10 +20,10 @@ pub struct Frame {
layers: Vec<FrameLayer>
}
impl<T: Into<FillColor>> From<T> for Frame {
fn from(color: T) -> Self {
impl<T: Into<RectLayer>> From<T> for Frame {
fn from(layer: T) -> Self {
let mut frame = Self::default();
frame.add(RectLayer::from_color(color));
frame.add(layer.into());
frame
}
}

View file

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