mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-20 11:28:30 +08:00
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'
This commit is contained in:
committed by
Keavon Chambers
parent
2849b99b59
commit
46c9ef02ca
@@ -0,0 +1,54 @@
|
||||
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 }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user