diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-04-08 17:08:30 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-04-09 12:02:35 +0200 |
| commit | 29eb13ca6214461a4b0deb63d589cd39ad6d41c2 (patch) | |
| tree | c86797d440cfcc801c87a3c64f479e39f2c068b1 /src/geom | |
| parent | 712c00ecb72b67da2c0788e5d3eb4dcc6366b2a7 (diff) | |
Sum color and length into stroke
Diffstat (limited to 'src/geom')
| -rw-r--r-- | src/geom/paint.rs | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/src/geom/paint.rs b/src/geom/paint.rs index 3660d528..351ef443 100644 --- a/src/geom/paint.rs +++ b/src/geom/paint.rs @@ -5,7 +5,7 @@ use syntect::highlighting::Color as SynColor; use super::*; /// How a fill or stroke should be painted. -#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] +#[derive(Copy, Clone, Eq, PartialEq, Hash)] pub enum Paint { /// A solid color. Solid(Color), @@ -20,6 +20,14 @@ where } } +impl Debug for Paint { + fn fmt(&self, f: &mut Formatter) -> fmt::Result { + match self { + Self::Solid(color) => color.fmt(f), + } + } +} + /// A color in a dynamic format. #[derive(Copy, Clone, Eq, PartialEq, Hash)] pub enum Color { @@ -234,6 +242,24 @@ impl From<CmykColor> for Color { } } +/// A stroke of a geometric shape. +#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] +pub struct Stroke { + /// The stroke's paint. + pub paint: Paint, + /// The stroke's thickness. + pub thickness: Length, +} + +impl Default for Stroke { + fn default() -> Self { + Self { + paint: Paint::Solid(Color::BLACK.into()), + thickness: Length::pt(1.0), + } + } +} + #[cfg(test)] mod tests { use super::*; |
