From: Ian Jackson Date: Sat, 20 Feb 2021 00:51:20 +0000 (+0000) Subject: Abolish separate path handling X-Git-Tag: otter-0.4.0~413 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=f5fbe9b2ba8a8b5fa044a9e23c2a094bc0f1d2c7;p=otter.git Abolish separate path handling NFC Signed-off-by: Ian Jackson --- diff --git a/src/pieces.rs b/src/pieces.rs index 465a5f40..3c860afd 100644 --- a/src/pieces.rs +++ b/src/pieces.rs @@ -14,7 +14,6 @@ type ColourMap = IndexVec; // todo: this serialisation is rather large pub struct SimpleShape { pub desc: Html, - pub path: Html, colours: ColourMap, #[serde(default)] pub edges: ColourMap, #[serde(default="default_edge_width")] pub edge_width: f64, @@ -149,8 +148,7 @@ impl SimpleShape { fn count_faces(&self) -> usize { max(self.colours.len(), self.edges.len()) } #[throws(SpecError)] - fn new(desc: Html, path: Html, - outline: OutlineRepr, + fn new(desc: Html, outline: OutlineRepr, def_itemname: &'_ str, common: &SimpleCommon) -> SimpleShape @@ -170,7 +168,7 @@ impl SimpleShape { } let shape = SimpleShape { - desc, path, itemname, outline, + desc, itemname, outline, colours: cmap(&common.faces)?, edges: cmap(&common.edges)?, edge_width: common.edge_width.unwrap_or(DEFAULT_EDGE_WIDTH), @@ -203,12 +201,14 @@ impl SimpleShape { write!(f, "{}", otherwise) } }; + let path = self.outline_path(pri, 1.0)?; + if self.colours.len() == 0 { write!(f, r##""##, INVISIBLE_EDGE_SENSITIVE, - &self.path.0)?; + &path.0)?; } write!(f, r##""##, &self.path.0)?; + write!(f, r##" d="{}"/>"##, &path.0)?; } } @@ -236,7 +236,6 @@ impl SimplePieceSpec for piece_specs::Disc { let outline = shapelib::Circle { diam: self.diam as f64 }; (SimpleShape::new( Html::lit("disc"), - svg_circle_path(self.diam as f64)?, outline.into(), "simple-disc", &self.common, @@ -268,7 +267,6 @@ impl SimplePieceSpec for piece_specs::Square { let outline = shapelib::Rectangle { xy: self.xy()?.map(|v| v as f64) }; (SimpleShape::new( Html::lit("square"), - svg_rectangle_path(self.xy()?.promote())?, outline.into(), "simple-square", &self.common,