chiark / gitweb /
Rename RectOutline and CircleOutline
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 14 May 2022 21:50:56 +0000 (22:50 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 14 May 2022 21:50:56 +0000 (22:50 +0100)
These are outlines and we are going to want an enum for just the
shapes.  Well, that's the Defn from shapelib but we want it more
generally.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/clock.rs
src/deck.rs
src/dice.rs
src/hand.rs
src/imports.rs
src/pieces.rs
src/shapelib.rs
src/spec.rs

index b3c5da3c4bead49443381af2fd72f3d6e6ac78c7..30aebecb53abe7d3821a5463d7b166d30161f0e1 100644 (file)
@@ -3,7 +3,7 @@
 // There is NO WARRANTY.
 
 use crate::prelude::*;
-use shapelib::RectShape;
+use shapelib::RectOutline;
 
 use nix::sys::time::TimeValLike as TVL;
 
@@ -389,7 +389,7 @@ impl ThreadState {
 
 const W: Coord = 40;
 const H: Coord = 14;
-const OUTLINE: RectShape = RectShape { xy: PosC::new(W as f64, H as f64) };
+const OUTLINE: RectOutline = RectOutline { xy: PosC::new(W as f64, H as f64) };
 
 
 // ==================== piece management, loading, etc. ====================
index ecdfcaefeb55b0190bd61ec6cd09f1c76c97d530..10fb6d97e68a1b504ac604cf5fa7290755bae6f7 100644 (file)
@@ -11,7 +11,7 @@ pub const ENABLED_DESC : HtmlLit = Html::lit("a pickup deck (enabled)");
 
 #[derive(Debug,Serialize,Deserialize)]
 struct Deck {
-  shape: GenericSimpleShape<(), RectShape>,
+  shape: GenericSimpleShape<(), RectOutline>,
   label: Option<PieceLabelLoaded>,
 }
 
@@ -45,7 +45,7 @@ impl PieceSpec for piece_specs::Deck {
       edge_width: self.edge_width,
     };
     let shape = match self.shape {
-      Outline::RectShape(r) => r,
+      Outline::RectOutline(r) => r,
       _ => throw!(SpecError::UnsupportedShape),
     };
     let shape = GenericSimpleShape::new(
index 014182dfdbc3119e1dce4a33ed6c224e623a59f0..d858c6a24bd7f08d0fec8deb472ba6a46f7390d7 100644 (file)
@@ -68,7 +68,7 @@ struct Die {
   itemname: String,
   labels: IndexVec<FaceId, String>, // if .len()==1, always use [0]
   image: Arc<dyn InertPieceTrait>, // if image.nfaces()==1, always use face 0
-  surround_outline: CircleShape,
+  surround_outline: CircleOutline,
   cooldown_radius: f64,
   cooldown_time: Duration,
 }
@@ -157,7 +157,7 @@ impl PieceSpec for Spec {
     } else {
       throw!(SpecError::InvalidSizeScale)
     };
-    let surround_outline = CircleShape { diam: radius * 2. };
+    let surround_outline = CircleOutline { diam: radius * 2. };
     let cooldown_radius = radius + COOLDOWN_EXTRA_RADIUS;
 
     let cooldown_time = {
index c5b8bc7bfe9250f0bbcc449bea362b7bf4eed966..960e38afbe6563bfe3e879eb24b4a2a2a8afefd7 100644 (file)
@@ -15,7 +15,7 @@ struct MagicOwner {
 
 #[derive(Debug,Serialize,Deserialize)]
 struct Hand {
-  shape: GenericSimpleShape<(), RectShape>,
+  shape: GenericSimpleShape<(), RectOutline>,
   label: Option<PieceLabelLoaded>,
   #[serde(default="Behaviour::backcompat_upgrade")]
   #[serde(alias="sort")]
@@ -96,7 +96,7 @@ impl piece_specs::OwnedCommon {
       edge_width: self.edge_width,
     };
     let shape = match self.shape {
-      Outline::RectShape(r) => r,
+      Outline::RectOutline(r) => r,
       _ => throw!(SpecError::UnsupportedShape),
     };
     let shape = GenericSimpleShape::new(
index 94c2864bbf3df03c12e8b980f11707d94263f5c6..f1aa955b58e7443896f89a50cc54d6e17488d7bd 100644 (file)
@@ -100,7 +100,7 @@ pub use crate::pcaliases::*;
 pub use crate::pcrender::*;
 pub use crate::pieces::*;
 pub use crate::shapelib;
-pub use crate::shapelib::{CircleShape, RectShape};
+pub use crate::shapelib::{CircleOutline, RectOutline};
 pub use crate::shapelib::{ItemEnquiryData, LibraryEnquiryData};
 pub use crate::shapelib::{LibraryLoadError};
 pub use crate::spec::*;
index 0b83470c1a04099773896429255f9357469e6ac6..9c3c2683b6931c373f3aebe361913b415d7f2cc4 100644 (file)
@@ -185,7 +185,7 @@ impl Option<piece_specs::PieceLabel> {
 impl PieceLabelLoaded {
   #[throws(IE)]
   pub fn svg(&self, f: &mut Html,
-             outline: &RectShape,
+             outline: &RectOutline,
              def_colour: Option<&Colour>,
              text: &Html) {
     let colour = {
@@ -310,7 +310,7 @@ pub trait SimplePieceSpec: Debug {
 impl SimplePieceSpec for piece_specs::Disc {
   #[throws(SpecError)]
   fn load_raw(&self) -> (SimpleShape, &SimpleCommon) {
-    let outline = CircleShape { diam: self.diam as f64 };
+    let outline = CircleOutline { diam: self.diam as f64 };
     (SimpleShape::new(
       Html::lit("disc").into(),
       outline.into(),
@@ -335,7 +335,7 @@ impl piece_specs::Rect {
 impl SimplePieceSpec for piece_specs::Rect {
   #[throws(SpecError)]
   fn load_raw(&self) -> (SimpleShape, &SimpleCommon) {
-    let outline = RectShape { xy: self.xy()?.map(|v| v as f64) };
+    let outline = RectOutline { xy: self.xy()?.map(|v| v as f64) };
     let desc = Html::lit(
       if outline.xy.x() == outline.xy.y()
       { "square" } else { "rectangle" }
index 4a979345a73777e8d5f3441926cdb97e3dfe386c..4737e1d92653e98f178eb71ed4daf08eb03964eb 100644 (file)
@@ -795,7 +795,7 @@ pub trait OutlineDefnTrait: Debug + Sync + Send + 'static {
   /// with a dummy svg_gz of `[1,1]`.  That must correctly predict
   /// success with other sizes.
   fn load(&self, size: PosC<f64>) -> Outline {
-    RectShape { xy: size }.into()
+    RectOutline { xy: size }.into()
   }
 
   fn load_mf1(&self, group: &GroupData) -> Result<Outline,LLE>;
@@ -830,12 +830,12 @@ impl_via_ambassador!{
   impl OutlineDefnTrait for OutlineDefnEnum { defn() }
 }
 
-//---------- RectShape ----------
+//---------- RectOutline ----------
 
 #[derive(Clone,Copy,Debug,Serialize,Deserialize)]
-pub struct RectShape { pub xy: PosC<f64> }
+pub struct RectOutline { pub xy: PosC<f64> }
 
-impl RectShape {
+impl RectOutline {
   // Used by code elsewhere eg deck.rs for occultation boundaries etc.
   #[throws(CoordinateOverflow)]
   pub fn rect(&self, nominal: Pos) -> RectC<Coord> {
@@ -860,7 +860,7 @@ impl RectShape {
 }
 
 #[dyn_upcast]
-impl OutlineTrait for RectShape {
+impl OutlineTrait for RectOutline {
   #[throws(IE)]
   fn outline_path(&self, scale: f64) -> Html {
     let xy = (self.xy * scale)?;
@@ -886,7 +886,7 @@ impl OutlineTrait for RectShape {
 struct RectDefn;
 impl OutlineDefnTrait for RectDefn {
   fn load(&self, size: PosC<f64>) -> Outline {
-    RectShape { xy: size }.into()
+    RectOutline { xy: size }.into()
   }
 
   #[throws(LibraryLoadError)]
@@ -897,13 +897,13 @@ impl OutlineDefnTrait for RectDefn {
   }
 }
 
-//---------- CircleShape ----------
+//---------- CircleOutline ----------
 
 #[derive(Clone,Copy,Debug,Serialize,Deserialize)]
-pub struct CircleShape { pub diam: f64 }
+pub struct CircleOutline { pub diam: f64 }
 
 #[dyn_upcast]
-impl OutlineTrait for CircleShape {
+impl OutlineTrait for CircleOutline {
   #[throws(IE)]
   fn outline_path(&self, scale: f64) -> Html {
     svg_circle_path(self.diam * scale)?
@@ -928,7 +928,7 @@ impl OutlineDefnTrait for CircleDefn {
       .map(OrderedFloat)
       .max().unwrap().
       into_inner();
-    CircleShape {
+    CircleOutline {
       diam,
     }.into()
   }
@@ -940,7 +940,7 @@ impl OutlineDefnTrait for CircleDefn {
       size => throw!(LLE::WrongNumberOfSizeDimensions
                      { got: size.len(), expected: [1,1] }),
     };
-    CircleShape {
+    CircleOutline {
       diam,
     }.into()
   }
index f933dada352bfb15e5fba1e55c5723ea740d40b7..b0a57a688bcbb80bb2ff1692b744685349b2dc9a 100644 (file)
@@ -259,14 +259,14 @@ pub struct ItemSpec {
 mod outline {
   use super::*;
   use crate::prelude::*;
-  use crate::shapelib::{CircleShape, RectShape};
+  use crate::shapelib::{CircleOutline, RectOutline};
   #[dyn_upcast(OutlineTrait)]
   #[enum_dispatch(OutlineTrait)]
   #[derive(Clone,Debug,Serialize,Deserialize)]
   #[serde(tag="type")]
   pub enum Outline {
-    #[serde(rename="Circle")] CircleShape,
-    #[serde(rename="Rect")]   RectShape,
+    #[serde(rename="Circle")] CircleOutline,
+    #[serde(rename="Rect")]   RectOutline,
   }
 }
 pub use outline::*;