mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 22:28:10 +08:00
* 🎨 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'
55 lines
881 B
Rust
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 }
|
|
}
|
|
}
|