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
use crate::{util, LinRgba};
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, PartialOrd)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct SrgbRgba([f32; 4]);
impl SrgbRgba {
impl_ctors!();
pub fn a(self, alpha: f32) -> Self {
self.to_linear().a(alpha).to_srgb()
}
pub fn pma(self) -> Self {
self.a(self.0[3])
}
pub fn to_linear(self) -> LinRgba {
util::map_color(self.0, util::srgb_to_linear).into()
}
}
impl_from_into!(SrgbRgba);