From 07b6c34261550537142b51f7ac1f81c6213dc930 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 24 Mar 2021 15:58:56 +0000 Subject: [PATCH] labels: Support on outside too Signed-off-by: Ian Jackson --- src/pieces.rs | 12 ++++++++---- src/spec.rs | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) 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)] -- 2.30.2