-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathblendmodes.rs
70 lines (62 loc) · 2.19 KB
/
blendmodes.rs
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//! A set of predefined blendmodes for use with `Layer::set_blendmode()`.
//!
//! [WIP] These are mostly placeholders for now.
use glium::draw_parameters::*;
use BlendMode;
pub const ALPHA: BlendMode = BlendMode(Blend {
color: BlendingFunction::Addition {
source: LinearBlendingFactor::One,
destination: LinearBlendingFactor::OneMinusSourceAlpha,
},
alpha: BlendingFunction::Addition {
source: LinearBlendingFactor::One,
destination: LinearBlendingFactor::OneMinusSourceAlpha,
},
constant_value: (0.0, 0.0, 0.0, 0.0)
});
pub const MAX: BlendMode = BlendMode(Blend {
color: BlendingFunction::Max,
alpha: BlendingFunction::Max,
constant_value: (0.0, 0.0, 0.0, 0.0),
});
pub const MIN: BlendMode = BlendMode(Blend {
color: BlendingFunction::Min,
alpha: BlendingFunction::Min,
constant_value: (0.0, 0.0, 0.0, 0.0),
});
pub const LIGHTEN: BlendMode = BlendMode(Blend {
color: BlendingFunction::Addition {
source: LinearBlendingFactor::SourceAlpha,
destination: LinearBlendingFactor::One,
},
alpha: BlendingFunction::Addition {
source: LinearBlendingFactor::One,
destination: LinearBlendingFactor::One,
},
constant_value: (0.0, 0.0, 0.0, 0.0),
});
pub const OVERLAY: BlendMode = BlendMode(Blend {
color: BlendingFunction::Addition {
source: LinearBlendingFactor::SourceAlpha,
destination: LinearBlendingFactor::SourceAlpha,
},
alpha: BlendingFunction::Addition {
source: LinearBlendingFactor::One,
destination: LinearBlendingFactor::One,
},
constant_value: (0.0, 0.0, 0.0, 0.0),
});
/// sets the blend function for the layer (like alpha, but adds brightness value)
pub fn alpha_const(brightness: f32) -> BlendMode {
BlendMode(Blend {
color: BlendingFunction::Addition {
source: LinearBlendingFactor::ConstantAlpha,
destination: LinearBlendingFactor::OneMinusSourceAlpha,
},
alpha: BlendingFunction::Addition {
source: LinearBlendingFactor::One,
destination: LinearBlendingFactor::OneMinusSourceAlpha,
},
constant_value: (0.0, 0.0, 0.0, brightness)
})
}