File size: 1,179 Bytes
2409829
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
use graphene_core::BlendMode;
use vello::peniko;

#[cfg(feature = "vello")]
pub trait BlendModeExt {
	fn to_peniko(&self) -> peniko::Mix;
}

#[cfg(feature = "vello")]
impl BlendModeExt for BlendMode {
	fn to_peniko(&self) -> peniko::Mix {
		match self {
			// Normal group
			BlendMode::Normal => peniko::Mix::Normal,
			// Darken group
			BlendMode::Darken => peniko::Mix::Darken,
			BlendMode::Multiply => peniko::Mix::Multiply,
			BlendMode::ColorBurn => peniko::Mix::ColorBurn,
			// Lighten group
			BlendMode::Lighten => peniko::Mix::Lighten,
			BlendMode::Screen => peniko::Mix::Screen,
			BlendMode::ColorDodge => peniko::Mix::ColorDodge,
			// Contrast group
			BlendMode::Overlay => peniko::Mix::Overlay,
			BlendMode::SoftLight => peniko::Mix::SoftLight,
			BlendMode::HardLight => peniko::Mix::HardLight,
			// Inversion group
			BlendMode::Difference => peniko::Mix::Difference,
			BlendMode::Exclusion => peniko::Mix::Exclusion,
			// Component group
			BlendMode::Hue => peniko::Mix::Hue,
			BlendMode::Saturation => peniko::Mix::Saturation,
			BlendMode::Color => peniko::Mix::Color,
			BlendMode::Luminosity => peniko::Mix::Luminosity,
			_ => todo!(),
		}
	}
}