blob: b9071c74fe0ffe10d1be4ab101f6b9aefbcb8e37 (
plain) (
blame)
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
31
32
33
34
35
36
37
38
39
40
41
42
|
//! Supported shaders;
use crate::{Color, widget};
use crate::gradient::Gradient;
use crate::widget::canvas::{FillStyle, StrokeStyle};
#[derive(Debug, Clone)]
/// Supported shaders for primitives.
pub enum Shader {
/// Fill a primitive with a solid color.
Solid(Color),
/// Fill a primitive with an interpolated color.
Gradient(Gradient)
}
impl <'a> Into<Shader> for StrokeStyle<'a> {
fn into(self) -> Shader {
match self {
StrokeStyle::Solid(color) => Shader::Solid(color),
StrokeStyle::Gradient(gradient) => gradient.clone().into()
}
}
}
impl <'a> Into<Shader> for FillStyle<'a> {
fn into(self) -> Shader {
match self {
FillStyle::Solid(color) => Shader::Solid(color),
FillStyle::Gradient(gradient) => gradient.clone().into()
}
}
}
impl <'a> Into<Shader> for widget::canvas::Gradient {
fn into(self) -> Shader {
match self {
widget::canvas::Gradient::Linear(linear) => {
Shader::Gradient(Gradient::Linear(linear))
}
}
}
}
|