fn svg_piece(&self, f: &mut String, pri: &PieceRenderInstructions) -> SR;
fn outline_path(&self, pri : &PieceRenderInstructions) -> String;
fn surround_path(&self, pri : &PieceRenderInstructions) -> String;
- fn svg_x_ids(&self) -> VisiblePieceIdSvgIds;
fn svg_x_defs(&self, pri : &PieceRenderInstructions) -> String;
fn thresh_dragraise(&self, pri : &PieceRenderInstructions)
-> Option<Coord>;
pub face : FaceId,
}
-pub type VisiblePieceIdSvgIds = &'static [&'static str];
-
-impl PieceRenderInstructions {
- pub fn id_use(&self) -> String { format!("use{}", self.id) }
- pub fn id_piece(&self) -> String { format!("piece{}", self.id) }
- pub fn id_select(&self) -> String { format!("select{}", self.id) }
- pub fn id_x(&self, w : &str) -> String { format!("def.{}.{}", self.id, w) }
-}
-
// ========== implementations ==========
// ---------- simple data types ----------
Some(n) => n,
None => -1,
};
- write!(defs, r##"<g id="{}" data-dragraise="{}">"##,
- pri.id_piece(),
- dragraise)?;
+ write!(defs,
+ r##"<g id="piece{}" data-dragraise="{}">"##,
+ pri.id, dragraise)?;
pr.p.svg_piece(&mut defs, &pri)?;
write!(defs, r##"</g>"##)?;
- write!(defs, r##"<path id="{}" stroke="black" fill="none" d="{}"/>"##,
- pri.id_select(),
- pr.p.surround_path(&pri))?;
+ write!(defs,
+ r##"<path id="select{}" stroke="black" fill="none" d="{}"/>"##,
+ pri.id, pr.p.surround_path(&pri))?;
write!(defs, "{}", pr.p.svg_x_defs(&pri))?;
defs
}
fn surround_path(&self, _pri : &PieceRenderInstructions) -> String {
self.scaled_path.clone()
}
- /*
- fn svg_select(&self, pri : &PieceRenderInstructions) -> String {
- format!(r##"<g transform="scale({})"><use href="#{}"/></g>"##,
- SELECT_SCALE,
- pri.id_x("base"))
- }
-*/
fn thresh_dragraise(&self, _pri : &PieceRenderInstructions)
-> Option<Coord> {
Some(self.approx_dia / 2)
}
- fn svg_x_ids(&self) -> VisiblePieceIdSvgIds { &["base"] }
fn svg_x_defs(&self, _pri : &PieceRenderInstructions) -> String {
"".to_owned()
}