1use super::{Color, Gradient, Image};
5
6#[derive(Clone, PartialEq, Debug)]
8pub enum Brush {
9 Solid(Color),
11 Gradient(Gradient),
13 Image(Image),
15}
16
17impl From<Color> for Brush {
18 fn from(c: Color) -> Self {
19 Self::Solid(c)
20 }
21}
22
23impl From<Gradient> for Brush {
24 fn from(g: Gradient) -> Self {
25 Self::Gradient(g)
26 }
27}
28
29#[derive(Clone, PartialEq, Debug)]
35pub enum BrushRef<'a> {
36 Solid(Color),
38 Gradient(&'a Gradient),
40 Image(&'a Image),
42}
43
44impl<'a> BrushRef<'a> {
45 pub fn to_owned(&self) -> Brush {
47 match self {
48 Self::Solid(color) => Brush::Solid(*color),
49 Self::Gradient(gradient) => Brush::Gradient((*gradient).clone()),
50 Self::Image(image) => Brush::Image((*image).clone()),
51 }
52 }
53}
54
55impl From<Color> for BrushRef<'_> {
56 fn from(color: Color) -> Self {
57 Self::Solid(color)
58 }
59}
60
61impl<'a> From<&'a Color> for BrushRef<'_> {
62 fn from(color: &'a Color) -> Self {
63 Self::Solid(*color)
64 }
65}
66
67impl<'a> From<&'a Gradient> for BrushRef<'a> {
68 fn from(gradient: &'a Gradient) -> Self {
69 Self::Gradient(gradient)
70 }
71}
72
73impl<'a> From<&'a Image> for BrushRef<'a> {
74 fn from(image: &'a Image) -> Self {
75 Self::Image(image)
76 }
77}
78
79impl<'a> From<&'a Brush> for BrushRef<'a> {
80 fn from(brush: &'a Brush) -> Self {
81 match brush {
82 Brush::Solid(color) => Self::Solid(*color),
83 Brush::Gradient(gradient) => Self::Gradient(gradient),
84 Brush::Image(image) => Self::Image(image),
85 }
86 }
87}
88
89#[derive(Copy, Clone, PartialEq, Eq, Default, Debug)]
92pub enum Extend {
93 #[default]
95 Pad,
96 Repeat,
98 Reflect,
100}