use crate::RGB;
use rand::Rng;
#[derive(Clone, Debug, Default, PartialEq)]
pub struct Fill {
pub color: RGB,
}
impl Fill {
pub fn new(color: RGB) -> Fill {
Fill { color }
}
}
#[derive(Clone, Debug, Default, PartialEq)]
pub struct Stroke {
pub width: u32,
pub color: RGB,
}
impl Stroke {
pub fn new(width: u32, color: RGB) -> Stroke {
Stroke { width, color }
}
}
#[derive(Default, Clone, Debug, PartialEq)]
pub struct Style {
pub fill: Option<Fill>,
pub stroke: Option<Stroke>,
}
impl Style {
pub fn default() -> Style {
Style {
fill: None,
stroke: None,
}
}
pub fn new(fill: Fill, stroke: Stroke) -> Style {
Style {
fill: Some(fill),
stroke: Some(stroke),
}
}
pub fn filled(color: RGB) -> Style {
Style {
fill: Some(Fill::new(color)),
stroke: None,
}
}
pub fn stroked(width: u32, color: RGB) -> Style {
Style {
fill: None,
stroke: Some(Stroke::new(width, color)),
}
}
}
pub struct Color {}
impl Color {
pub fn black() -> RGB {
RGB { r: 0, g: 0, b: 0 }
}
pub fn gray(shade: u8) -> RGB {
RGB {
r: shade,
g: shade,
b: shade,
}
}
pub fn random() -> RGB {
let mut rng = rand::thread_rng();
RGB {
r: rng.gen_range(0, 255),
g: rng.gen_range(0, 255),
b: rng.gen_range(0, 255),
}
}
}