let path = svg_rescale_path(&unit_path, scale)?;
path
}
+
+#[throws(SE)]
+pub fn svg_rectangle_path(x: f64, y: f64) -> Html {
+ Html(format!("M {} {} h {} v {} h {} z",
+ -x*0.5, -y*0.5, x, y, -x))
+}
+
#[typetag::serde]
impl Outline for SimpleShape {
#[throws(IE)]
[x, y] => (x,y),
_ => throw!(SpecError::ImproperSizeSpec),
};
- let path = Html(format!("M {} {} h {} v {} h {} z",
- -(x as f64)*0.5, -(y as f64)*0.5, x, y, -x));
+ let path = svg_rectangle_path(x as f64, y as f64)?;
let itemname = self.itemname.clone()
.unwrap_or_else(||"simple-square".to_string());
SimpleShape::new_from_path(Html::lit("square"), path, (x+y+1)/2,