chiark / gitweb /
Outline: change to require outline_path
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 20 Feb 2021 00:46:41 +0000 (00:46 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 20 Feb 2021 10:45:04 +0000 (10:45 +0000)
NFC

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/gamestate.rs
src/hand.rs
src/pieces.rs
src/shapelib.rs

index e69b935645f27a9d4d80858e203ef8ec8968516d..6fc0cb310a91e3946469b7257db75f083f418bf0 100644 (file)
@@ -112,7 +112,11 @@ impl_downcast!(PieceXData);
 
 #[enum_dispatch]
 pub trait Outline: Send + Debug {
-  fn surround_path(&self, pri: &PieceRenderInstructions) -> Result<Html, IE>;
+  fn outline_path(&self, pri: &PieceRenderInstructions, scale: f64)
+          -> Result<Html, IE>;
+  fn surround_path(&self, pri: &PieceRenderInstructions) -> Result<Html, IE> {
+    self.outline_path(pri, SELECT_SCALE)
+  }
   fn thresh_dragraise(&self, pri: &PieceRenderInstructions)
                       -> Result<Option<Coord>, IE>;
   fn bbox_approx(&self) -> [Pos;2];
index 1d657ab4406fe1e19770dcd0c71c1d9122d50df8..17b95189c89f59ebf63147534f3f2a7d9b9e9ca7 100644 (file)
@@ -30,7 +30,7 @@ impl PieceXData for HandState { }
 impl Outline for Hand {
   delegate!{
     to self.shape {
-      fn surround_path(&self, _pri: &PieceRenderInstructions)
+      fn outline_path(&self, _pri: &PieceRenderInstructions, scale: f64)
                        -> Result<Html,IE>;
       fn thresh_dragraise(&self, _pri: &PieceRenderInstructions)
                           -> Result<Option<Coord>,IE>;
index 4e23dd20b4a129a1c331dcf184f21f634cd1cd54..465a5f40f3e52ea3454ceca599cb5e56b79e58c8 100644 (file)
@@ -114,7 +114,7 @@ pub fn svg_rectangle_path(PosC([x,y]): PosC<f64>) -> Html {
 impl Outline for SimpleShape {
   delegate! {
     to self.outline {
-      fn surround_path(&self, _pri: &PieceRenderInstructions)
+      fn outline_path(&self, _pri: &PieceRenderInstructions, scale: f64)
                        -> Result<Html,IE>;
       fn thresh_dragraise(&self, _pri: &PieceRenderInstructions)
                           -> Result<Option<Coord>,IE>;
index 790941f768339197e1eb1a4d5407765780a40d97..97fb1ed898c27f9e1ba14106c81659655f97c172 100644 (file)
@@ -143,7 +143,8 @@ impl ItemEnquiryData {
 }
 
 impl Outline for Item { delegate! { to self.outline {
-  fn surround_path(&self, pri: &PieceRenderInstructions) -> Result<Html, IE>;
+  fn outline_path(&self, pri: &PieceRenderInstructions, scale: f64)
+                  -> Result<Html, IE>;
   fn thresh_dragraise(&self, pri: &PieceRenderInstructions)
                       -> Result<Option<Coord>, IE>;
   fn bbox_approx(&self) -> [Pos; 2];
@@ -497,8 +498,8 @@ pub struct Circle { pub diam: f64 }
 
 impl Outline for Circle {
   #[throws(IE)]
-  fn surround_path(&self, _pri: &PieceRenderInstructions) -> Html {
-    svg_circle_path(self.diam * SELECT_SCALE)?
+  fn outline_path(&self, _pri: &PieceRenderInstructions, scale: f64) -> Html {
+    svg_circle_path(self.diam * scale)?
   }
   #[throws(IE)]
   fn thresh_dragraise(&self, _pri: &PieceRenderInstructions) -> Option<Coord> {
@@ -538,9 +539,9 @@ pub struct Rectangle { pub xy: PosC<f64> }
 
 impl Outline for Rectangle {
   #[throws(IE)]
-  fn surround_path(&self, _pri: &PieceRenderInstructions) -> Html {
-    let size = self.xy * SELECT_SCALE;
-    svg_rectangle_path(size)?
+  fn outline_path(&self, _pri: &PieceRenderInstructions, scale: f64) -> Html {
+    let xy = self.xy * scale;
+    svg_rectangle_path(xy)?
   }
   #[throws(IE)]
   fn thresh_dragraise(&self, _pri: &PieceRenderInstructions)