use crate::chromatic::Color;
pub struct ShapeAttrs {
pub fill_color: Option<Color>,
pub fill_opacity: f32,
pub stroke_color: Option<Color>,
pub stroke_width: f32,
pub stroke_opacity: f32,
}
impl Default for ShapeAttrs {
fn default() -> Self {
Self {
fill_color: None,
fill_opacity: 1.,
stroke_color: None,
stroke_width: 1.,
stroke_opacity: 1.,
}
}
}
impl ShapeAttrs {
pub fn fill_default() -> Self {
Self {
fill_color: Some(Color::default()),
fill_opacity: 1.,
stroke_color: None,
stroke_width: 1.,
stroke_opacity: 1.,
}
}
pub fn stroke_default() -> Self {
Self {
fill_color: None,
fill_opacity: 1.,
stroke_color: Some(Color::default()),
stroke_width: 1.,
stroke_opacity: 1.,
}
}
}
pub struct LineAttrs {
pub stroke_color: Color,
pub stroke_width: f32,
pub stroke_opacity: f32,
}
impl Default for LineAttrs {
fn default() -> Self {
Self {
stroke_color: Color::default(),
stroke_width: 1.,
stroke_opacity: 1.,
}
}
}
#[derive(Default, Clone)]
pub enum Alignment {
Start,
#[default]
Center,
End,
}
pub struct TextAttrs {
pub fill_color: Color,
pub font_size: f32,
pub align_x: Alignment,
pub align_y: Alignment,
}
impl Default for TextAttrs {
fn default() -> Self {
Self {
fill_color: Color::default(),
font_size: 12.,
align_x: Alignment::default(),
align_y: Alignment::default(),
}
}
}
#[doc = concat!(
"Arrow attributes for shape and color values.\n\n",
include_str!("../../docs/arrow_attrs.svg"),
"\n\n",
"- The bend angle is defined by the three points _A_, _C_, and _B_.\n",
"- The head angle is defined by the three points _S_, _B_, and _C_.\n",
"- The head length is the distance between points _H_ and _B_."
)]
pub struct ArrowAttrs {
pub bend_angle: f32,
pub head_angle: f32,
pub head_length: f32,
pub stroke_color: Color,
pub stroke_width: f32,
pub stroke_opacity: f32,
}
impl Default for ArrowAttrs {
fn default() -> Self {
Self {
bend_angle: 0.,
head_angle: 60.,
head_length: 8.,
stroke_color: Color::default(),
stroke_width: 1.,
stroke_opacity: 1.,
}
}
}