impl SimpleShape {
#[throws(SpecError)]
fn new(desc: Html, path: Html,
- faces: &IndexVec<FaceId,ColourSpec>,
outline: Box<dyn Outline>,
- spec_itemname: &Option<String>,
- def_itemname: &'_ str)
+ def_itemname: &'_ str,
+ common: &piece_specs::SimpleCommon)
-> SimpleShape
{
- let itemname = spec_itemname.clone()
+ let itemname = common.itemname.clone()
.unwrap_or_else(|| def_itemname.to_string());
- let colours = faces
+ let colours = common.faces
.iter()
.map(|s| s.try_into())
.collect::<Result<_,SpecError>>()?;
SimpleShape::new(
Html::lit("disc"),
svg_circle_path(self.diam as f64)?,
- &self.faces,
Box::new(outline),
- &self.itemname,
"simple-disc",
+ &self.common,
)?
}
}
SimpleShape::new(
Html::lit("square"),
svg_rectangle_path(self.xy()?.promote())?,
- &self.faces,
Box::new(outline),
- &self.itemname,
"simple-square",
+ &self.common,
)?
}
}
pub type FaceColourSpecs = IndexVec<FaceId,ColourSpec>;
#[derive(Debug,Serialize,Deserialize)]
- pub struct Disc {
+ pub struct SimpleCommon {
pub itemname: Option<String>,
- pub diam: Coord,
pub faces: IndexVec<FaceId, ColourSpec>,
}
+ #[derive(Debug,Serialize,Deserialize)]
+ pub struct Disc {
+ pub diam: Coord,
+ #[serde(flatten)]
+ pub common: SimpleCommon,
+ }
+
#[derive(Debug,Serialize,Deserialize)]
pub struct Square {
- pub itemname: Option<String>,
pub size: Vec<Coord>,
- pub faces: IndexVec<FaceId, ColourSpec>,
+ #[serde(flatten)]
+ pub common: SimpleCommon,
}
/*
pub struct Hand {