palette/oklch/
alpha.rs
1use crate::{Alpha, OklabHue};
2
3use super::Oklch;
4
5pub type Oklcha<T = f32> = Alpha<Oklch<T>, T>;
8
9impl<T, A> Alpha<Oklch<T>, A> {
11 pub fn new<H: Into<OklabHue<T>>>(l: T, chroma: T, hue: H, alpha: A) -> Self {
13 Alpha {
14 color: Oklch::new(l, chroma, hue),
15 alpha,
16 }
17 }
18
19 pub const fn new_const(l: T, chroma: T, hue: OklabHue<T>, alpha: A) -> Self {
22 Alpha {
23 color: Oklch::new_const(l, chroma, hue),
24 alpha,
25 }
26 }
27
28 pub fn into_components(self) -> (T, T, OklabHue<T>, A) {
30 (self.color.l, self.color.chroma, self.color.hue, self.alpha)
31 }
32
33 pub fn from_components<H: Into<OklabHue<T>>>((l, chroma, hue, alpha): (T, T, H, A)) -> Self {
35 Self::new(l, chroma, hue, alpha)
36 }
37}