From 995bd4dd8d1794ece3ef0fe10b7359fbfac67cdd Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 20 Feb 2021 00:46:41 +0000 Subject: [PATCH] Outline: change to require outline_path NFC Signed-off-by: Ian Jackson --- src/gamestate.rs | 6 +++++- src/hand.rs | 2 +- src/pieces.rs | 2 +- src/shapelib.rs | 13 +++++++------ 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/gamestate.rs b/src/gamestate.rs index e69b9356..6fc0cb31 100644 --- a/src/gamestate.rs +++ b/src/gamestate.rs @@ -112,7 +112,11 @@ impl_downcast!(PieceXData); #[enum_dispatch] pub trait Outline: Send + Debug { - fn surround_path(&self, pri: &PieceRenderInstructions) -> Result; + fn outline_path(&self, pri: &PieceRenderInstructions, scale: f64) + -> Result; + fn surround_path(&self, pri: &PieceRenderInstructions) -> Result { + self.outline_path(pri, SELECT_SCALE) + } fn thresh_dragraise(&self, pri: &PieceRenderInstructions) -> Result, IE>; fn bbox_approx(&self) -> [Pos;2]; diff --git a/src/hand.rs b/src/hand.rs index 1d657ab4..17b95189 100644 --- a/src/hand.rs +++ b/src/hand.rs @@ -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; fn thresh_dragraise(&self, _pri: &PieceRenderInstructions) -> Result,IE>; diff --git a/src/pieces.rs b/src/pieces.rs index 4e23dd20..465a5f40 100644 --- a/src/pieces.rs +++ b/src/pieces.rs @@ -114,7 +114,7 @@ pub fn svg_rectangle_path(PosC([x,y]): PosC) -> Html { impl Outline for SimpleShape { delegate! { to self.outline { - fn surround_path(&self, _pri: &PieceRenderInstructions) + fn outline_path(&self, _pri: &PieceRenderInstructions, scale: f64) -> Result; fn thresh_dragraise(&self, _pri: &PieceRenderInstructions) -> Result,IE>; diff --git a/src/shapelib.rs b/src/shapelib.rs index 790941f7..97fb1ed8 100644 --- a/src/shapelib.rs +++ b/src/shapelib.rs @@ -143,7 +143,8 @@ impl ItemEnquiryData { } impl Outline for Item { delegate! { to self.outline { - fn surround_path(&self, pri: &PieceRenderInstructions) -> Result; + fn outline_path(&self, pri: &PieceRenderInstructions, scale: f64) + -> Result; fn thresh_dragraise(&self, pri: &PieceRenderInstructions) -> Result, 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 { @@ -538,9 +539,9 @@ pub struct Rectangle { pub xy: PosC } 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) -- 2.30.2