pride_overlay/
opacity.rs

1/// The opacity of a pixel (0-255)
2pub struct Opacity(pub u8);
3
4impl Opacity {
5    pub fn new(opacity: u8) -> Opacity {
6        Opacity(opacity)
7    }
8
9    pub fn from_percentage(percentage: f32) -> Option<Opacity> {
10        if (0. ..=100.).contains(&percentage) {
11            return Some(Opacity((2.55 * percentage).floor() as u8));
12        }
13
14        None
15    }
16}