Files
Graphite/core/document/src/layers/mod.rs
0HyperCube 46c9ef02ca Add colors in Rust (#78)
* 🎨 Add colors in Rust

* 🌿 Use an option for the properties and #[repr(C)]

*  Remove WASM dependency on document.

* 😎 Wrap Fill and stroke in a style struct.

* 📦 Use crate::Color

* Merge Add transactions for temporary modifications to the document

* Run cargo fmt

* Color without a 'U'
2021-04-21 22:25:06 +01:00

55 lines
881 B
Rust

pub mod style;
pub mod circle;
pub use circle::Circle;
pub mod line;
pub use line::Line;
pub mod rect;
pub use rect::Rect;
pub mod shape;
pub use shape::Shape;
pub mod folder;
pub use folder::Folder;
pub trait LayerData {
fn render(&self) -> String;
}
#[derive(Debug, Clone, PartialEq)]
pub enum LayerDataTypes {
Folder(Folder),
Circle(Circle),
Rect(Rect),
Line(Line),
Shape(Shape),
}
impl LayerDataTypes {
pub fn render(&self) -> String {
match self {
Self::Folder(f) => f.render(),
Self::Circle(c) => c.render(),
Self::Rect(r) => r.render(),
Self::Line(l) => l.render(),
Self::Shape(s) => s.render(),
}
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct Layer {
pub visible: bool,
pub name: Option<String>,
pub data: LayerDataTypes,
}
impl Layer {
pub fn new(data: LayerDataTypes) -> Self {
Self { visible: true, name: None, data }
}
}