mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-17 15:28:04 +08:00
Add ToolData and rectangle tool (#64)
This commit is contained in:
committed by
Keavon Chambers
parent
fafea371ab
commit
599d478a5c
@@ -1,11 +1,12 @@
|
||||
pub mod operation;
|
||||
|
||||
pub use kurbo::{Circle, Point};
|
||||
pub use kurbo::{Circle, Point, Rect};
|
||||
pub use operation::Operation;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum SvgElement {
|
||||
Circle(Circle),
|
||||
Rect(Rect),
|
||||
}
|
||||
|
||||
impl SvgElement {
|
||||
@@ -14,6 +15,9 @@ impl SvgElement {
|
||||
Self::Circle(c) => {
|
||||
format!(r#"<circle cx="{}" cy="{}" r="{}" style="fill: #fff;" />"#, c.center.x, c.center.y, c.radius)
|
||||
}
|
||||
Self::Rect(r) => {
|
||||
format!(r#"<rect x="{}" y="{}" width="{}" height="{}" style="fill: #fff;" />"#, r.min_x(), r.min_y(), r.width(), r.height())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,6 +40,11 @@ impl Document {
|
||||
radius: r,
|
||||
}));
|
||||
|
||||
update_frontend(self.render());
|
||||
}
|
||||
Operation::AddRect { x0, y0, x1, y1 } => {
|
||||
self.svg.push(SvgElement::Rect(Rect::from_points(Point::new(x0, y0), Point::new(x1, y1))));
|
||||
|
||||
update_frontend(self.render());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
pub enum Operation {
|
||||
AddCircle { cx: f64, cy: f64, r: f64 },
|
||||
AddRect { x0: f64, y0: f64, x1: f64, y1: f64 },
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user