use crate::foundations::{Content, Func, Smart, cast, elem};
use crate::layout::{Abs, Angle, Length, Ratio, Rel};
use crate::math::Mathy;
use crate::visualize::Stroke;
#[elem(Mathy)]
pub struct CancelElem {
#[required]
pub body: Content,
#[default(Rel::new(Ratio::one(), Abs::pt(3.0).into()))]
pub length: Rel<Length>,
#[default(false)]
pub inverted: bool,
#[default(false)]
pub cross: bool,
pub angle: Smart<CancelAngle>,
#[fold]
#[default(Stroke {
// Default stroke has 0.5pt for better visuals.
thickness: Smart::Custom(Abs::pt(0.5).into()),
..Default::default()
})]
pub stroke: Stroke,
}
#[derive(Debug, Clone, PartialEq, Hash)]
pub enum CancelAngle {
Angle(Angle),
Func(Func),
}
cast! {
CancelAngle,
self => match self {
Self::Angle(v) => v.into_value(),
Self::Func(v) => v.into_value()
},
v: Angle => CancelAngle::Angle(v),
v: Func => CancelAngle::Func(v),
}