// There is NO WARRANTY.
use crate::prelude::*;
-use shapelib::RectShape;
+use shapelib::RectOutline;
use nix::sys::time::TimeValLike as TVL;
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. ====================
#[derive(Debug,Serialize,Deserialize)]
struct Deck {
- shape: GenericSimpleShape<(), RectShape>,
+ shape: GenericSimpleShape<(), RectOutline>,
label: Option<PieceLabelLoaded>,
}
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(
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,
}
} 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 = {
#[derive(Debug,Serialize,Deserialize)]
struct Hand {
- shape: GenericSimpleShape<(), RectShape>,
+ shape: GenericSimpleShape<(), RectOutline>,
label: Option<PieceLabelLoaded>,
#[serde(default="Behaviour::backcompat_upgrade")]
#[serde(alias="sort")]
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(
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::*;
impl PieceLabelLoaded {
#[throws(IE)]
pub fn svg(&self, f: &mut Html,
- outline: &RectShape,
+ outline: &RectOutline,
def_colour: Option<&Colour>,
text: &Html) {
let colour = {
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(),
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" }
/// 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>;
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> {
}
#[dyn_upcast]
-impl OutlineTrait for RectShape {
+impl OutlineTrait for RectOutline {
#[throws(IE)]
fn outline_path(&self, scale: f64) -> Html {
let xy = (self.xy * scale)?;
struct RectDefn;
impl OutlineDefnTrait for RectDefn {
fn load(&self, size: PosC<f64>) -> Outline {
- RectShape { xy: size }.into()
+ RectOutline { xy: size }.into()
}
#[throws(LibraryLoadError)]
}
}
-//---------- 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)?
.map(OrderedFloat)
.max().unwrap().
into_inner();
- CircleShape {
+ CircleOutline {
diam,
}.into()
}
size => throw!(LLE::WrongNumberOfSizeDimensions
{ got: size.len(), expected: [1,1] }),
};
- CircleShape {
+ CircleOutline {
diam,
}.into()
}
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::*;