| 1 | use crate::alpha::Alpha; |
| 2 | use crate::oklab::Oklab; |
| 3 | |
| 4 | /// Oklab with an alpha component. |
| 5 | pub type Oklaba<T = f32> = Alpha<Oklab<T>, T>; |
| 6 | |
| 7 | ///<span id="Oklaba"></span>[`Oklaba`](crate::Oklaba) implementations. |
| 8 | impl<T, A> Alpha<Oklab<T>, A> { |
| 9 | /// Create an Oklab color with transparency. |
| 10 | pub const fn new(l: T, a: T, b: T, alpha: A) -> Self { |
| 11 | Alpha { |
| 12 | color: Oklab::new(l, a, b), |
| 13 | alpha, |
| 14 | } |
| 15 | } |
| 16 | |
| 17 | /// Convert to a `(L, a, b, alpha)` tuple. |
| 18 | pub fn into_components(self) -> (T, T, T, A) { |
| 19 | (self.color.l, self.color.a, self.color.b, self.alpha) |
| 20 | } |
| 21 | |
| 22 | /// Convert from a `(L, a, b, alpha)` tuple. |
| 23 | pub fn from_components((l, a, b, alpha): (T, T, T, A)) -> Self { |
| 24 | Self::new(l, a, b, alpha) |
| 25 | } |
| 26 | } |