1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use crate::*;

/// Specifies how a region should be filled.
#[derive(Clone)]
pub enum Paint {
    /// Fill a region with a solid color.
    Color(Color),

    /// Fill a region with a linear gradient between two colors.
    Gradient {
        start: LocalPoint,
        end: LocalPoint,
        inner_color: Color,
        outer_color: Color,
    },
}

impl Paint {
    pub fn vger_paint(&self, vger: &mut Vger) -> PaintIndex {
        match self {
            Paint::Color(color) => vger.color_paint(*color),
            Paint::Gradient {
                start,
                end,
                inner_color,
                outer_color,
            } => vger.linear_gradient(*start, *end, *inner_color, *outer_color, 0.0),
        }
    }
}