mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-21 02:28:12 +08:00
Another round of polishing (#101)
* Implement basic refactorings * Simplify some match statements * Rename `ix` to `index` If we're not going with a single letter name, then a full word makes more sense. * Rename `as_hex` to `to_hex` `as_` implies lossless reinterpretation while the function does a conversion that loses information * Replace `for_each` with for loops for loops are a lot easier to read and maintain. * factor out x and y coords in Line::render this is arguably more ergonomic * Remove redundant `format!(format_args!())`
This commit is contained in:
committed by
Keavon Chambers
parent
c9fea54ec5
commit
47458115b8
@@ -36,16 +36,26 @@ pub enum LayerDataTypes {
|
||||
Shape(Shape),
|
||||
}
|
||||
|
||||
macro_rules! call_render {
|
||||
($self:ident.render($svg:ident) { $($variant:ident),* }) => {
|
||||
match $self {
|
||||
$(Self::$variant(x) => x.render($svg)),*
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
impl LayerDataTypes {
|
||||
pub fn render(&mut self, svg: &mut String) {
|
||||
match self {
|
||||
Self::Folder(f) => f.render(svg),
|
||||
Self::Circle(c) => c.render(svg),
|
||||
Self::Ellipse(e) => e.render(svg),
|
||||
Self::Rect(r) => r.render(svg),
|
||||
Self::Line(l) => l.render(svg),
|
||||
Self::PolyLine(pl) => pl.render(svg),
|
||||
Self::Shape(s) => s.render(svg),
|
||||
call_render! {
|
||||
self.render(svg) {
|
||||
Folder,
|
||||
Circle,
|
||||
Ellipse,
|
||||
Rect,
|
||||
Line,
|
||||
PolyLine,
|
||||
Shape
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user