From: Ian Jackson Date: Wed, 24 Mar 2021 15:58:56 +0000 (+0000) Subject: labels: Support on outside too X-Git-Tag: otter-0.5.0~459 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=07b6c34261550537142b51f7ac1f81c6213dc930;p=otter.git labels: Support on outside too Signed-off-by: Ian Jackson --- diff --git a/src/pieces.rs b/src/pieces.rs index 0705c0f0..7737011a 100644 --- a/src/pieces.rs +++ b/src/pieces.rs @@ -163,13 +163,17 @@ impl piece_specs::PieceLabel { let fontsz = 4.; let PosC([x,y]) = { use piece_specs::PieceLabelPlace::*; - let eff_size = (outline.xy - PosC([2.,2.]))?; + let inout = match self.place { + BottomLeft | TopLeft => 1., + BottomLeftOutside | TopLeftOutside => -1., + }; + let eff_size = (outline.xy - PosC([2., inout * 2.]))?; let mut pos = (eff_size * -0.5)?; let y = &mut pos.0[1]; - *y += 0.5 * fontsz; + *y += 0.5 * fontsz * inout; match self.place { - BottomLeft => { *y *= -1. }, - TopLeft => { } + BottomLeft | BottomLeftOutside => { *y *= -1. }, + TopLeft | TopLeftOutside => { }, }; *y += 0.5 * fontsz; pos diff --git a/src/spec.rs b/src/spec.rs index 9a1f1166..4ad6e1a0 100644 --- a/src/spec.rs +++ b/src/spec.rs @@ -257,8 +257,8 @@ pub mod piece_specs { #[derive(Debug,Copy,Clone,Serialize,Deserialize,Eq,PartialEq)] pub enum PieceLabelPlace { - BottomLeft, - TopLeft, + BottomLeft, TopLeft, + BottomLeftOutside, TopLeftOutside, } #[derive(Debug,Serialize,Deserialize)]