From: Ian Jackson Date: Sat, 13 Feb 2021 18:52:54 +0000 (+0000) Subject: pieces: Provide stroke_attrs_hook nfc X-Git-Tag: otter-0.4.0~513 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=386ea8cbdbf181f73a229e23222f6b7c89c68807;p=otter.git pieces: Provide stroke_attrs_hook nfc Signed-off-by: Ian Jackson --- diff --git a/src/pieces.rs b/src/pieces.rs index 943d83d7..86edd198 100644 --- a/src/pieces.rs +++ b/src/pieces.rs @@ -129,7 +129,7 @@ impl Outline for SimpleShape { impl Piece for SimpleShape { #[throws(IE)] fn svg_piece(&self, f: &mut Html, pri: &PieceRenderInstructions) { - self.svg_piece_raw(f, pri)?; + self.svg_piece_raw(f, pri, &mut |_|Ok(()))?; } fn describe_html(&self, face: Option) -> Html { Html(if_chain! { @@ -190,10 +190,10 @@ impl SimpleShape { } #[throws(IE)] - fn svg_piece_raw< - >(&self, f: &mut Html, pri: &PieceRenderInstructions, - ) - { + fn svg_piece_raw( + &self, f: &mut Html, pri: &PieceRenderInstructions, + stroke_attrs_hook: &mut dyn FnMut(&mut String) -> Result<(),IE>, + ) { let f = &mut f.0; let ef = |f: &mut String, cmap: &ColourMap, attrname: &str, otherwise| { if let Some(colour) = cmap.get(pri.face) { @@ -214,6 +214,7 @@ impl SimpleShape { if self.edges.len() != 0 { write!(f, r##" stroke-width="{}""##, &self.edge_width)?; } + stroke_attrs_hook(f)?; ef(f, &self.edges, "stroke", "")?; write!(f, r##" d="{}"/>"##, &self.path.0)?; }