From: Ian Jackson Date: Sun, 12 Jul 2020 10:51:58 +0000 (+0100) Subject: paths inside SimpleShape X-Git-Tag: otter-0.2.0~1367 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=fa917c295c7da3d94421d33ced3302ad58c56ced;p=otter.git paths inside SimpleShape nfc we will want this so we can do last-moved highlighting --- diff --git a/src/pieces.rs b/src/pieces.rs index ee455883..6009baff 100644 --- a/src/pieces.rs +++ b/src/pieces.rs @@ -8,7 +8,7 @@ define_index_type! { #[derive(Debug)] struct SimpleShape { desc : String, - shape : String, + path : String, approx_dia : Coord, colours : IndexVec, } @@ -32,7 +32,7 @@ impl Piece for SimpleShape { } fn svg_x_ids(&self) -> VisiblePieceIdSvgIds { &["base"] } fn svg_x_defs(&self, pri : &PieceRenderInstructions) -> String { - format!(r#"{}"#, pri.id_x("base"), self.shape) + format!(r#""#, pri.id_x("base"), self.path) } fn describe_html(&self, face : Option) -> String { if let Some(face) = face { @@ -49,14 +49,15 @@ pub fn xxx_make_pieces() -> Vec<(Pos, Box)> { Box::new(SimpleShape { desc : "circle".to_owned(), approx_dia : 20, - shape : r#""#.to_owned(), + path : "M 10 0 a 10 10 0 1 0 -20 0\ + a 10 10 0 1 0 20 0".to_owned(), colours : index_vec![ "red".to_string(), "grey".to_string() ], })), ([ 90, 60 ], Box::new(SimpleShape { desc : "square".to_owned(), approx_dia : 20, - shape : r#""#.to_owned(), + path : "M -10 -10 h 20 v 20 h -20 v -20".to_owned(), colours : index_vec![ "blue".to_string(), "grey".to_string() ], })), ]