#[throws(SpecError)]
fn new(desc: Html, path: Html,
outline: Box<dyn Outline>,
- def_itemname: &'_ str,
+ itemname: &'_ str,
common: &piece_specs::SimpleCommon)
-> SimpleShape
{
- let itemname = common.itemname.clone()
- .unwrap_or_else(|| def_itemname.to_string());
+ let itemname = itemname.to_owned();
let cmap = |spec: &FaceColourSpecs| Ok::<_,SpecError>(
spec
Html::lit("disc"),
svg_circle_path(self.diam as f64)?,
Box::new(outline),
- "simple-disc",
+ self.itemname.as_deref().unwrap_or("simple-disc"),
&self.common,
)?
}
Html::lit("square"),
svg_rectangle_path(self.xy()?.promote())?,
Box::new(outline),
- "simple-square",
+ self.itemname.as_deref().unwrap_or("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,
}