[group.clubs]
item_prefix = "card-oxymoron-"
-outline = "Square"
+outline = "Rect"
size = [73, 97]
centre = [36.5, 48.5]
scale = 0.25
[group.chess-board]
size = [242, 246]
scale = 0.38
-outline = "Square"
+outline = "Rect"
files = """
chess-board - the chessboard
"""
"""
[group.misc]
-outline = "Square"
+outline = "Rect"
size = [448,326]
centre = [224, 163]
scale = 0.025
"""
[group.card-backs]
-outline = "Square"
+outline = "Rect"
size = [73, 97]
# sizes to match cards-oxymoron:
"""
[group.cards-bellot]
-outline = "Square"
+outline = "Rect"
size = [73, 97]
# sizes to match cards-oxymoron:
[[pieces]]
pos = [90, 20]
-type = "Square"
+type = "Rect"
size = [10]
angle.Compass = 1
faces = ["blue", "grey"]
[[pieces]]
pos = [120, 30]
-type = "Square"
+type = "Rect"
size = [10]
angle.Compass = 1
faces = [ ]
type = "Hand"
edge = "white"
colour = "grey"
-shape.type = "Rectangle"
+shape.type = "Rect"
shape.xy = [70,20]
[[pieces]]
edges = ["black", "white"]
label.colour = "black"
label.place = "BottomLeftOutside"
-shape.type = "Rectangle"
+shape.type = "Rect"
shape.xy = [25,30]
[[pieces]]
edges = ["black", "white"]
label.colour = "black"
label.place = "BottomLeftOutside"
-shape.type = "Rectangle"
+shape.type = "Rect"
shape.xy = [25,30]
[[pieces]]
edges = ["black", "white"]
label.place = "TopLeftOutside"
label.colour = "black"
-shape.type = "Rectangle"
+shape.type = "Rect"
shape.xy = [25,30]
type = "Hand"
edge = "white"
edge_width = 0.75
-shape.type = "Rectangle"
+shape.type = "Rect"
shape.xy = [97,25]
[[pieces]]
type = "Hand"
edge = "white"
edge_width = 0.75
-shape.type = "Rectangle"
+shape.type = "Rect"
shape.xy = [97,25]
[[pieces]]
type = "Hand"
edge = "white"
edge_width = 0.75
-shape.type = "Rectangle"
+shape.type = "Rect"
shape.xy = [97,25]
[[pieces]]
type = "Hand"
edge = "darkgrey"
edge_width = 1.0
-shape.type = "Rectangle"
+shape.type = "Rect"
shape.xy = [97,25]
[[pieces]]
type = "Hand"
edge = "white"
edge_width = 0.75
-shape.type = "Rectangle"
+shape.type = "Rect"
shape.xy = [97,25]
[[pieces]]
type = "Hand"
edge = "white"
edge_width = 0.75
-shape.type = "Rectangle"
+shape.type = "Rect"
shape.xy = [97,25]
[[pieces]]
type = "Hand"
edge = "white"
edge_width = 0.75
-shape.type = "Rectangle"
+shape.type = "Rect"
shape.xy = [97,25]
[[pieces]]
type = "Hand"
edge = "white"
edge_width = 0.75
-shape.type = "Rectangle"
+shape.type = "Rect"
shape.xy = [97,25]
[[pieces]]
type = "Hand"
edge = "white"
edge_width = 0.75
-shape.type = "Rectangle"
+shape.type = "Rect"
shape.xy = [97,25]
[[pieces]]
type = "Hand"
edge = "darkgrey"
edge_width = 1.0
-shape.type = "Rectangle"
+shape.type = "Rect"
shape.xy = [97,25]
[[pieces]]
pos = [20, 85]
-type = "Square"
+type = "Rect"
faces = ["yellow","#f4f"]
posd = [10, 0]
size = [7,7]
[[pieces]]
pos = [20, 95]
-type = "Square"
+type = "Rect"
faces = ["#333"]
posd = [10, 0]
size = [9,1]
[[pieces]]
pos = [20, 100]
-type = "Square"
+type = "Rect"
faces = ["#333"]
posd = [10, 0]
size = [9,1]
[[pieces]]
pos = [17, 110]
-type = "Square"
+type = "Rect"
faces = ["#333"]
posd = [5, 0]
size = [1,9]
type = "Hand"
edge = "white"
colour = "grey"
-shape.type = "Rectangle"
+shape.type = "Rect"
shape.xy = [20,10]
[[pieces]]
// There is NO WARRANTY.
use crate::prelude::*;
-use shapelib::Rectangle;
+use shapelib::RectShape;
use nix::sys::time::TimeValLike as TVL;
const W: Coord = 40;
const H: Coord = 14;
-const OUTLINE: Rectangle = Rectangle { xy: PosC::new(W as f64, H as f64) };
+const OUTLINE: RectShape = RectShape { xy: PosC::new(W as f64, H as f64) };
// ==================== piece management, loading, etc. ====================
#[derive(Debug,Serialize,Deserialize)]
struct Deck {
- shape: GenericSimpleShape<(), shapelib::Rectangle>,
+ shape: GenericSimpleShape<(), RectShape>,
label: Option<piece_specs::PieceLabel>,
}
edge_width: self.edge_width,
};
let shape = match self.shape {
- Outline::Rectangle(r) => r,
+ Outline::RectShape(r) => r,
_ => throw!(SpecError::UnsupportedShape),
};
let shape = GenericSimpleShape::new(
#[derive(Debug,Serialize,Deserialize)]
struct Hand {
- shape: GenericSimpleShape<(), shapelib::Rectangle>,
+ shape: GenericSimpleShape<(), RectShape>,
label: Option<PieceLabel>,
}
edge_width: self.edge_width,
};
let shape = match self.shape {
- Outline::Rectangle(r) => r,
+ Outline::RectShape(r) => r,
_ => throw!(SpecError::UnsupportedShape),
};
let shape = GenericSimpleShape::new(
impl piece_specs::PieceLabel {
#[throws(IE)]
pub fn svg(&self, f: &mut Html,
- outline: &shapelib::Rectangle,
+ outline: &RectShape,
def_colour: Option<&Colour>,
text: &Html) {
let colour = {
impl SimplePieceSpec for piece_specs::Disc {
#[throws(SpecError)]
fn load_raw(&self) -> (SimpleShape, &SimpleCommon) {
- let outline = shapelib::Circle { diam: self.diam as f64 };
+ let outline = CircleShape { diam: self.diam as f64 };
(SimpleShape::new(
Html::lit("disc"),
outline.into(),
}
}
-impl piece_specs::Square {
+impl piece_specs::Rect {
#[throws(SpecError)]
fn xy(&self) -> Pos {
match *self.size.as_slice() {
}
#[typetag::serde]
-impl SimplePieceSpec for piece_specs::Square {
+impl SimplePieceSpec for piece_specs::Rect {
#[throws(SpecError)]
fn load_raw(&self) -> (SimpleShape, &SimpleCommon) {
- let outline = shapelib::Rectangle { xy: self.xy()?.map(|v| v as f64) };
+ let outline = RectShape { xy: self.xy()?.map(|v| v as f64) };
+ let desc = Html::lit(
+ if outline.xy.x() == outline.xy.y()
+ { "square" } else { "rectangle" }
+ );
(SimpleShape::new(
- Html::lit("square"),
+ desc,
outline.into(),
- "simple-square",
+ "simple-rect",
&self.common,
)?, &self.common)
}
}
#[typetag::serde]
-impl PieceSpec for piece_specs::Square {
+impl PieceSpec for piece_specs::Rect {
#[throws(SpecError)]
fn load(&self, _: usize, _: &mut GPiece, _ir: &InstanceRef)
-> PieceSpecLoaded {
pub use crate::pcrender::*;
pub use crate::pieces::*;
pub use crate::shapelib;
+pub use crate::shapelib::{CircleShape, RectShape};
pub use crate::slotmap_slot_idx::*;
pub use crate::spec::*;
pub use crate::spec::piece_specs::{FaceColourSpecs, SimpleCommon};
/// If specified, pieces in this group can be occulted.
pub occulted: Option<OccultationMethod>,
- /// One of `"Circle"` or `"Square"`, to define the outline shape.
+ /// One of `"Circle"` or `"Rect"`, to define the outline shape.
/// The size is taken from `size`.
///
/// This value is a string, not some weird Rust type, despite
}
#[derive(Clone,Copy,Debug,Serialize,Deserialize)]
-pub struct Circle { pub diam: f64 }
+pub struct CircleShape { pub diam: f64 }
#[dyn_upcast]
-impl OutlineTrait for Circle {
+impl OutlineTrait for CircleShape {
#[throws(IE)]
fn outline_path(&self, scale: f64) -> Html {
svg_circle_path(self.diam * scale)?
#[throws(LibraryLoadError)]
fn check(&self, lgd: &GroupData) { Self::get_size(lgd)?; }
fn load(&self, lgd: &GroupData) -> Result<Outline,IE> {
- Ok(Circle {
+ Ok(CircleShape {
diam: Self::get_size(lgd).map_err(|e| e.ought())?,
}.into())
}
}
#[derive(Clone,Copy,Debug,Serialize,Deserialize)]
-pub struct Rectangle { pub xy: PosC<f64> }
+pub struct RectShape { pub xy: PosC<f64> }
-impl Rectangle {
+impl RectShape {
#[throws(CoordinateOverflow)]
pub fn rect(&self, centre: Pos) -> RectC<Coord> {
let offset = (self.xy * 0.5)?;
}
#[dyn_upcast]
-impl OutlineTrait for Rectangle {
+impl OutlineTrait for RectShape {
#[throws(IE)]
fn outline_path(&self, scale: f64) -> Html {
let xy = (self.xy * scale)?;
}
#[derive(Deserialize,Debug)]
-struct SquareDefn { }
-#[typetag::deserialize(name="Square")]
-impl OutlineDefn for SquareDefn {
+struct RectDefn { }
+#[typetag::deserialize(name="Rect")]
+impl OutlineDefn for RectDefn {
#[throws(LibraryLoadError)]
fn check(&self, lgd: &GroupData) { Self::get(lgd)?; }
fn load(&self, lgd: &GroupData) -> Result<Outline,IE> {
)
}
}
-impl SquareDefn {
+impl RectDefn {
#[throws(LibraryLoadError)]
- fn get(group: &GroupData) -> Rectangle {
- Rectangle { xy: PosC{ coords:
+ fn get(group: &GroupData) -> RectShape {
+ RectShape { xy: PosC{ coords:
match group.d.size.as_slice() {
&[s] => [s,s],
s if s.len() == 2 => s.try_into().unwrap(),
mod outline {
use super::*;
use crate::prelude::*;
- use crate::shapelib::{Circle, Rectangle};
+ use crate::shapelib::{CircleShape, RectShape};
#[dyn_upcast(OutlineTrait)]
#[enum_dispatch(OutlineTrait)]
#[derive(Clone,Debug,Serialize,Deserialize)]
#[serde(tag="type")]
pub enum Outline {
- Circle,
- #[serde(alias="Square")] Rectangle,
+ #[serde(rename="Circle")] CircleShape,
+ #[serde(rename="Rect")] RectShape,
}
}
pub use outline::*;
}
#[derive(Debug,Serialize,Deserialize)]
- pub struct Square {
+ pub struct Rect {
pub size: Vec<Coord>,
#[serde(flatten)]
pub common: SimpleCommon,