From: Ian Jackson Date: Sat, 14 May 2022 22:17:24 +0000 (+0100) Subject: Add shape method to OutlineTrait X-Git-Tag: otter-1.1.0~154 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=0a22e4cbc0f89fa5e9fb9628036eab9c45515d7d;p=otter.git Add shape method to OutlineTrait dice will use this to decide their own outline. Signed-off-by: Ian Jackson --- diff --git a/src/clock.rs b/src/clock.rs index 7e3e42d4..bd042565 100644 --- a/src/clock.rs +++ b/src/clock.rs @@ -427,6 +427,7 @@ impl OutlineTrait for Clock { fn outline_path(&self, scale: f64) -> Result; fn thresh_dragraise(&self) -> Result, IE>; fn bbox_approx(&self) -> Result; + fn shape(&self) -> Option; } } } diff --git a/src/dice.rs b/src/dice.rs index d858c6a2..c77215f7 100644 --- a/src/dice.rs +++ b/src/dice.rs @@ -314,6 +314,7 @@ impl OutlineTrait for Die { fn outline_path(&self, scale: f64) -> Result; fn thresh_dragraise(&self) -> Result, IE>; fn bbox_approx(&self) -> Result; + fn shape(&self) -> Option; } } } diff --git a/src/gamestate.rs b/src/gamestate.rs index 79ccca91..bca44d12 100644 --- a/src/gamestate.rs +++ b/src/gamestate.rs @@ -166,6 +166,7 @@ pub trait OutlineTrait: Debug + Sync + Send + 'static { } fn thresh_dragraise(&self) -> Result, IE>; fn bbox_approx(&self) -> Result; + fn shape(&self) -> Option; // None means not a sane shape } #[derive(Debug,Copy,Clone,Serialize,Deserialize)] diff --git a/src/outline.rs b/src/outline.rs index d5a06b44..b51fe2ef 100644 --- a/src/outline.rs +++ b/src/outline.rs @@ -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 { Some(Shape::Circle) } } //---------- RectOutline ---------- @@ -126,4 +127,5 @@ impl OutlineTrait for RectOutline { let neg = (-pos)?; Rect{ corners: [ neg, pos ] } } + fn shape(&self) -> Option { Some(Shape::Rect) } }