use crisol_core::color::Rgba;
use crisol_plot_core::transform::{ScreenPoint, ScreenRect};
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Anchor {
Left,
Center,
Right,
}
#[derive(Clone, Debug, PartialEq)]
pub enum Prim {
Rect {
rect: ScreenRect,
fill: Rgba,
stroke: Option<(f32, Rgba)>,
},
Line {
points: Vec<ScreenPoint>,
width: f32,
color: Rgba,
},
Polygon {
points: Vec<ScreenPoint>,
fill: Rgba,
stroke: Option<(f32, Rgba)>,
},
Circle {
center: ScreenPoint,
radius: f32,
fill: Rgba,
stroke: Option<(f32, Rgba)>,
},
Text {
pos: ScreenPoint,
text: String,
size: f32,
color: Rgba,
anchor: Anchor,
},
}
impl Prim {
pub fn hline(from: f32, to: f32, y: f32, width: f32, color: Rgba) -> Self {
Self::Line {
points: vec![ScreenPoint::new(from, y), ScreenPoint::new(to, y)],
width,
color,
}
}
pub fn vline(x: f32, from: f32, to: f32, width: f32, color: Rgba) -> Self {
Self::Line {
points: vec![ScreenPoint::new(x, from), ScreenPoint::new(x, to)],
width,
color,
}
}
}