.join(" ");
let wh = size.iter().map(|&s| s * SVG_SCALE)
.collect::<Vec<_>>();
- let surround = pc.surround_path(&pri)?;
+ let surround = pc.surround_path()?;
print!(r#"<svg xmlns="http://www.w3.org/2000/svg"
viewBox="{}" width={} height={}>"#,
&viewport, wh[0], wh[1]);
#[enum_dispatch]
pub trait OutlineTrait: Send + Debug {
- fn outline_path(&self, pri: &PieceRenderInstructions, scale: f64)
- -> Result<Html, IE>;
- fn surround_path(&self, pri: &PieceRenderInstructions) -> Result<Html, IE> {
- self.outline_path(pri, SELECT_SCALE)
+ fn outline_path(&self, scale: f64) -> Result<Html, IE>;
+ fn surround_path(&self) -> Result<Html, IE> {
+ self.outline_path(SELECT_SCALE)
}
- fn thresh_dragraise(&self, pri: &PieceRenderInstructions)
- -> Result<Option<Coord>, IE>;
+ fn thresh_dragraise(&self) -> Result<Option<Coord>, IE>;
fn bbox_approx(&self) -> Result<[Pos;2], IE>;
}
let PriOccluded::Visible = pri.occluded;
let mut defs = Html(String::new());
- let dragraise = match p.thresh_dragraise(pri)? {
+ let dragraise = match p.thresh_dragraise()? {
Some(n) if n < 0 => throw!(SvgE::NegativeDragraise),
Some(n) => n,
None => -1,
write!(&mut defs.0, r##"</g>"##)?;
write!(&mut defs.0,
r##"<path id="surround{}" d="{}"/>"##,
- pri.id, p.surround_path(pri)?.0)?;
+ pri.id, p.surround_path()?.0)?;
defs
}
inner(self, gpc, p.borrow())?
impl OutlineTrait for Hand {
delegate!{
to self.shape {
- fn outline_path(&self, _pri: &PieceRenderInstructions, scale: f64)
- -> Result<Html,IE>;
- fn thresh_dragraise(&self, _pri: &PieceRenderInstructions)
- -> Result<Option<Coord>,IE>;
+ fn outline_path(&self, scale: f64) -> Result<Html,IE>;
+ fn thresh_dragraise(&self) -> Result<Option<Coord>,IE>;
fn bbox_approx(&self) -> Result<[Pos;2], IE>;
}
}
{
delegate! {
to self.outline {
- fn outline_path(&self, _pri: &PieceRenderInstructions, scale: f64)
- -> Result<Html,IE>;
- fn thresh_dragraise(&self, _pri: &PieceRenderInstructions)
- -> Result<Option<Coord>,IE>;
+ fn outline_path(&self, scale: f64) -> Result<Html,IE>;
+ fn thresh_dragraise(&self) -> Result<Option<Coord>,IE>;
fn bbox_approx(&self) -> Result<[Pos;2], IE>;
}
}
write!(f, "{}", otherwise)
}
};
- let path = self.outline_path(pri, 1.0)?;
+ let path = self.outline_path(1.0)?;
if self.colours.len() == 0 {
write!(f,
}
impl OutlineTrait for Item { delegate! { to self.outline {
- fn outline_path(&self, pri: &PieceRenderInstructions, scale: f64)
- -> Result<Html, IE>;
- fn thresh_dragraise(&self, pri: &PieceRenderInstructions)
- -> Result<Option<Coord>, IE>;
+ fn outline_path(&self, scale: f64) -> Result<Html, IE>;
+ fn thresh_dragraise(&self) -> Result<Option<Coord>, IE>;
fn bbox_approx(&self) -> Result<[Pos; 2], IE>;
}}}
impl OutlineTrait for Circle {
#[throws(IE)]
- fn outline_path(&self, _pri: &PieceRenderInstructions, scale: f64) -> Html {
+ fn outline_path(&self, scale: f64) -> Html {
svg_circle_path(self.diam * scale)?
}
#[throws(IE)]
- fn thresh_dragraise(&self, _pri: &PieceRenderInstructions) -> Option<Coord> {
+ fn thresh_dragraise(&self) -> Option<Coord> {
Some((self.diam * 0.5) as Coord)
}
#[throws(IE)]
impl OutlineTrait for Rectangle {
#[throws(IE)]
- fn outline_path(&self, _pri: &PieceRenderInstructions, scale: f64) -> Html {
+ fn outline_path(&self, scale: f64) -> Html {
let xy = (self.xy * scale)?;
svg_rectangle_path(xy)?
}
#[throws(IE)]
- fn thresh_dragraise(&self, _pri: &PieceRenderInstructions)
- -> Option<Coord> {
+ fn thresh_dragraise(&self) -> Option<Coord> {
let smallest: f64 = self.xy.0.iter().cloned()
.map(OrderedFloat::from).min().unwrap().into();
Some((smallest * 0.5) as Coord)