Implement Pen Tool (#79)

This commit is contained in:
Edwin Cheng
2021-04-23 00:12:24 +08:00
committed by Keavon Chambers
parent b556dd6bfd
commit e40727e914
9 changed files with 143 additions and 8 deletions
+8
View File
@@ -1,3 +1,5 @@
use layers::PolyLine;
use crate::{
layers::{self, Folder, Layer, LayerData, LayerDataTypes, Line, Rect, Shape},
DocumentError, LayerId, Operation,
@@ -178,6 +180,12 @@ impl Document {
update_frontend(self.render(&mut vec![]));
}
Operation::AddPen { path, insert_index, points, style } => {
let points: Vec<kurbo::Point> = points.into_iter().map(|it| it.into()).collect();
let polyline = PolyLine::new(points, style);
self.add_layer(&path, Layer::new(LayerDataTypes::PolyLine(polyline)), insert_index)?;
update_frontend(self.render(&mut vec![]));
}
Operation::AddShape {
path,
insert_index,