mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-20 03:18:06 +08:00
@@ -1,6 +1,6 @@
|
||||
pub mod operation;
|
||||
|
||||
pub use kurbo::{Circle, Point, Rect};
|
||||
pub use kurbo::{Circle, Line, Point, Rect};
|
||||
pub use operation::Operation;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
@@ -8,6 +8,7 @@ pub enum LayerType {
|
||||
Folder(Folder),
|
||||
Circle(Circle),
|
||||
Rect(Rect),
|
||||
Line(Line),
|
||||
}
|
||||
|
||||
impl LayerType {
|
||||
@@ -20,6 +21,9 @@ impl LayerType {
|
||||
Self::Rect(r) => {
|
||||
format!(r#"<rect x="{}" y="{}" width="{}" height="{}" style="fill: #fff;" />"#, r.min_x(), r.min_y(), r.width(), r.height())
|
||||
}
|
||||
Self::Line(l) => {
|
||||
format!(r#"<line x1="{}" y1="{}" x2="{}" y2="{}" style="stroke: #fff;" />"#, l.p0.x, l.p0.y, l.p1.x, l.p1.y)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -211,6 +215,11 @@ impl Document {
|
||||
|
||||
update_frontend(self.render());
|
||||
}
|
||||
Operation::AddLine { path, insert_index, x0, y0, x1, y1 } => {
|
||||
self.add_layer(&path, Layer::new(LayerType::Line(Line::new(Point::new(x0, y0), Point::new(x1, y1)))), insert_index)?;
|
||||
|
||||
update_frontend(self.render());
|
||||
}
|
||||
Operation::DeleteLayer { path } => {
|
||||
self.delete(&path)?;
|
||||
|
||||
|
||||
@@ -16,6 +16,14 @@ pub enum Operation {
|
||||
x1: f64,
|
||||
y1: f64,
|
||||
},
|
||||
AddLine {
|
||||
path: Vec<LayerId>,
|
||||
insert_index: isize,
|
||||
x0: f64,
|
||||
y0: f64,
|
||||
x1: f64,
|
||||
y1: f64,
|
||||
},
|
||||
DeleteLayer {
|
||||
path: Vec<LayerId>,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user