#[throws(SpecError)]
fn new(desc: Html, path: Html,
outline: Box<dyn Outline>,
- itemname: &'_ str,
+ def_itemname: &'_ str,
common: &piece_specs::SimpleCommon)
-> SimpleShape
{
- let itemname = itemname.to_owned();
+ let itemname = common.itemname.clone()
+ .unwrap_or_else(|| def_itemname.to_string());
let cmap = |spec: &FaceColourSpecs| Ok::<_,SpecError>(
spec
Html::lit("disc"),
svg_circle_path(self.diam as f64)?,
Box::new(outline),
- self.itemname.as_deref().unwrap_or("simple-disc"),
+ "simple-disc",
&self.common,
)?
}
Html::lit("square"),
svg_rectangle_path(self.xy()?.promote())?,
Box::new(outline),
- self.itemname.as_deref().unwrap_or("simple-square"),
+ "simple-square",
&self.common,
)?
}
#[derive(Debug,Serialize,Deserialize)]
pub struct SimpleCommon {
+ pub itemname: Option<String>,
pub faces: IndexVec<FaceId, ColourSpec>,
#[serde(default)] pub edges: IndexVec<FaceId, ColourSpec>,
pub edge_width: Option<f64>,
#[derive(Debug,Serialize,Deserialize)]
pub struct Disc {
pub diam: Coord,
- pub itemname: Option<String>,
#[serde(flatten)]
pub common: SimpleCommon,
}
#[derive(Debug,Serialize,Deserialize)]
pub struct Square {
pub size: Vec<Coord>,
- pub itemname: Option<String>,
#[serde(flatten)]
pub common: SimpleCommon,
}