use crate::hues::OklabHue;
use crate::{angle::FromAngle, stimulus::FromStimulus, Alpha};
use super::Okhsl;
pub type Okhsla<T = f32> = Alpha<Okhsl<T>, T>;
impl<T, A> Alpha<Okhsl<T>, A> {
pub fn new<H: Into<OklabHue<T>>>(hue: H, saturation: T, lightness: T, alpha: A) -> Self {
Alpha {
color: Okhsl::new(hue, saturation, lightness),
alpha,
}
}
pub const fn new_const(hue: OklabHue<T>, saturation: T, lightness: T, alpha: A) -> Self {
Alpha {
color: Okhsl::new_const(hue, saturation, lightness),
alpha,
}
}
pub fn into_format<U, B>(self) -> Alpha<Okhsl<U>, B>
where
U: FromStimulus<T> + FromAngle<T>,
B: FromStimulus<A>,
{
Alpha {
color: self.color.into_format(),
alpha: B::from_stimulus(self.alpha),
}
}
pub fn from_format<U, B>(color: Alpha<Okhsl<U>, B>) -> Self
where
T: FromStimulus<U> + FromAngle<U>,
A: FromStimulus<B>,
{
color.into_format()
}
pub fn into_components(self) -> (OklabHue<T>, T, T, A) {
(
self.color.hue,
self.color.saturation,
self.color.lightness,
self.alpha,
)
}
pub fn from_components<H: Into<OklabHue<T>>>(
(hue, saturation, lightness, alpha): (H, T, T, A),
) -> Self {
Self::new(hue, saturation, lightness, alpha)
}
}