From: Ian Jackson Date: Sat, 13 Feb 2021 12:58:38 +0000 (+0000) Subject: pieces: break out svg_piece_raw, nfc X-Git-Tag: otter-0.4.0~514 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=aab0878715ef06db40fab8663beb9795c957e49f;p=otter.git pieces: break out svg_piece_raw, nfc Signed-off-by: Ian Jackson --- diff --git a/src/pieces.rs b/src/pieces.rs index ba26b01e..943d83d7 100644 --- a/src/pieces.rs +++ b/src/pieces.rs @@ -129,28 +129,7 @@ impl Outline for SimpleShape { impl Piece for SimpleShape { #[throws(IE)] fn svg_piece(&self, f: &mut Html, pri: &PieceRenderInstructions) { - let f = &mut f.0; - let ef = |f: &mut String, cmap: &ColourMap, attrname: &str, otherwise| { - if let Some(colour) = cmap.get(pri.face) { - write!(f, r##" {}="{}""##, attrname, colour.0) - } else { - write!(f, "{}", otherwise) - } - }; - if self.colours.len() == 0 { - write!(f, - r##""##, - INVISIBLE_EDGE_SENSITIVE, - &self.path.0)?; - } - write!(f, r##""##, &self.path.0)?; + self.svg_piece_raw(f, pri)?; } fn describe_html(&self, face: Option) -> Html { Html(if_chain! { @@ -209,6 +188,35 @@ impl SimpleShape { shape } + + #[throws(IE)] + fn svg_piece_raw< + >(&self, f: &mut Html, pri: &PieceRenderInstructions, + ) + { + let f = &mut f.0; + let ef = |f: &mut String, cmap: &ColourMap, attrname: &str, otherwise| { + if let Some(colour) = cmap.get(pri.face) { + write!(f, r##" {}="{}""##, attrname, colour.0) + } else { + write!(f, "{}", otherwise) + } + }; + if self.colours.len() == 0 { + write!(f, + r##""##, + INVISIBLE_EDGE_SENSITIVE, + &self.path.0)?; + } + write!(f, r##""##, &self.path.0)?; + } } #[typetag::serde(tag="type")]