pub trait Piece : Send + Debug {
fn svg_piece(&self, pri : &PieceRenderInstructions) -> String;
- fn svg_select(&self, pri : &PieceRenderInstructions) -> String;
+ 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)
pri.id_piece(),
dragraise,
pr.p.svg_piece(&pri)).unwrap();
- write!(defs, r##"<g id="{}" stroke="black" fill="none">{}</g>"##,
+ write!(defs, r##"<path id="{}" stroke="black" fill="none" d="{}"/>"##,
pri.id_select(),
- pr.p.svg_select(&pri)).unwrap();
+ pr.p.surround_path(&pri)).unwrap();
write!(defs, "{}", pr.p.svg_x_defs(&pri)).unwrap();
defs
}
impl Piece for SimpleShape {
fn svg_piece(&self, pri : &PieceRenderInstructions) -> String {
- format!(r##"<use fill="{}" href="#{}"/>"##,
- self.colours[pri.face],
- pri.id_x("base"))
+ format!(r##"<path fill="{}" d="{}"/>"##,
+ self.colours[pri.face], self.path)
}
- fn thresh_dragraise(&self, _pri : &PieceRenderInstructions)
- -> Option<Coord> {
- Some(self.approx_dia / 2)
+ fn outline_path(&self, _pri : &PieceRenderInstructions) -> String {
+ self.path.clone()
+ }
+ 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 {
- format!(r#"<path id={} d="{}"></path>"#, pri.id_x("base"), self.path)
+ fn svg_x_defs(&self, _pri : &PieceRenderInstructions) -> String {
+ "".to_owned()
}
fn describe_html(&self, face : Option<FaceId>) -> String {
if let Some(face) = face {