chiark / gitweb /
Add shape method to OutlineTrait
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 14 May 2022 22:17:24 +0000 (23:17 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 14 May 2022 22:35:42 +0000 (23:35 +0100)
dice will use this to decide their own outline.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/clock.rs
src/dice.rs
src/gamestate.rs
src/outline.rs

index 7e3e42d47cd92fcce5e02ad5b03adac0d541ce99..bd042565b18e48ba8d5e32a069b986d6789b2bd5 100644 (file)
@@ -427,6 +427,7 @@ impl OutlineTrait for Clock {
       fn outline_path(&self, scale: f64) -> Result<Html, IE>;
       fn thresh_dragraise(&self) -> Result<Option<Coord>, IE>;
       fn bbox_approx(&self) -> Result<Rect, IE>;
+      fn shape(&self) -> Option<Shape>;
     }
   }
 }
index d858c6a24bd7f08d0fec8deb472ba6a46f7390d7..c77215f714d3a099b2474d2831637483976d4d9d 100644 (file)
@@ -314,6 +314,7 @@ impl OutlineTrait for Die {
       fn outline_path(&self, scale: f64) -> Result<Html, IE>;
       fn thresh_dragraise(&self) -> Result<Option<Coord>, IE>;
       fn bbox_approx(&self) -> Result<Rect, IE>;
+      fn shape(&self) -> Option<Shape>;
     }
   }
 }
index 79ccca91ca12248d0cd540cf7f5c5c1dfa4b0585..bca44d128338e687611dc650eb8720219352b7c6 100644 (file)
@@ -166,6 +166,7 @@ pub trait OutlineTrait: Debug + Sync + Send + 'static {
   }
   fn thresh_dragraise(&self) -> Result<Option<Coord>, IE>;
   fn bbox_approx(&self) -> Result<Rect, IE>;
+  fn shape(&self) -> Option<Shape>; // None means not a sane shape
 }
 
 #[derive(Debug,Copy,Clone,Serialize,Deserialize)]
index d5a06b44bec754a6e3860e3e9a73080ddeaa6b2c..b51fe2ef4cf9fc94863a8b0a51c919971663f92f 100644 (file)
@@ -74,6 +74,7 @@ impl OutlineTrait for CircleOutline {
     let d = (self.diam * 0.5).round() as Coord;
     Rect{ corners: [PosC::new(-d,-d), PosC::new(d, d)]}
   }
+  fn shape(&self) -> Option<Shape> { Some(Shape::Circle) }
 }
 
 //---------- RectOutline ----------
@@ -126,4 +127,5 @@ impl OutlineTrait for RectOutline {
     let neg = (-pos)?;
     Rect{ corners: [ neg, pos ] }
   }
+  fn shape(&self) -> Option<Shape> { Some(Shape::Rect) }
 }