From: Ian Jackson Date: Thu, 19 May 2022 12:18:41 +0000 (+0100) Subject: TextOptions: break out y_adjust X-Git-Tag: otter-1.1.0~65 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=c15ec79462549768d039a3334a199adf1f18859d;p=otter.git TextOptions: break out y_adjust Signed-off-by: Ian Jackson --- diff --git a/src/dice.rs b/src/dice.rs index 79833f6f..22682941 100644 --- a/src/dice.rs +++ b/src/dice.rs @@ -512,7 +512,7 @@ impl InertPieceTrait for Die { let tc = OverlayTemplateContext { label_text: label, label_options: &self.text_options, - label_y_adjust: self.text_options.size * SVG_FONT_Y_ADJUST_OF_FONT_SIZE, + label_y_adjust: self.text_options.y_adjust(), cooldown_active, radius: self.cooldown_radius, diff --git a/src/ui.rs b/src/ui.rs index e31cc484..1275c84b 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -135,12 +135,15 @@ impl Display for AbbrevPresentationLayout { } impl TextOptions { + pub fn y_adjust(&self) -> f64 { + self.size * SVG_FONT_Y_ADJUST_OF_FONT_SIZE + } + pub fn start_element(&self) -> Html { - let y_adj = self.size * SVG_FONT_Y_ADJUST_OF_FONT_SIZE; hformat!{ r##"{} text-align="center" text-anchor="middle" x="0" y="{}" fill="{}" font-size="{}px""##, HTML_TEXT_LABEL_ELEM_START, - y_adj, &self.colour, self.size, + self.y_adjust(), &self.colour, self.size, } } }