use super::*;
impl<T> Square<T>
where
T: Num + Clone,
{
pub fn new(x: T, y: T, side: T) -> Self {
Self { x, y, s: side }
}
pub fn from_anchor<P>(anchor: P, side: T) -> Self
where
Point<T>: From<P>,
{
let Point { x, y } = anchor.into();
Self { x, y, s: side }
}
pub fn from_center<P>(center: P, side: T) -> Self
where
Point<T>: From<P>,
{
let Point { x: x0, y: y0 } = center.into();
let Point { x, y } = Point::new(x0 - side.clone() / two(), y0 - side.clone() / two());
Self { x, y, s: side }
}
}