chiark / gitweb /
labels: Support on outside too
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 24 Mar 2021 15:58:56 +0000 (15:58 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 24 Mar 2021 15:58:56 +0000 (15:58 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/pieces.rs
src/spec.rs

index 0705c0f0adfca1ed6827010a14fda0155efd1f0c..7737011ab4254e355eb28011a59aa34c174f1182 100644 (file)
@@ -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
index 9a1f1166bd44798ff1df06eaff9b357240a41ade..4ad6e1a0879b1d4bb7d15b292115856b2b7eb1a1 100644 (file)
@@ -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)]