use super::Okhsv;
use crate::angle::FromAngle;
use crate::hues::OklabHue;
use crate::num::{MinMax, Zero};
use crate::stimulus::FromStimulus;
use crate::Alpha;
pub type Okhsva<T = f32> = Alpha<Okhsv<T>, T>;
impl<T, A> Alpha<Okhsv<T>, A> {
pub fn new<H: Into<OklabHue<T>>>(hue: H, saturation: T, value: T, alpha: A) -> Self {
Alpha {
color: Okhsv::new(hue.into(), saturation, value),
alpha,
}
}
pub const fn new_const(hue: OklabHue<T>, saturation: T, value: T, alpha: A) -> Self {
Alpha {
color: Okhsv::new_const(hue, saturation, value),
alpha,
}
}
pub fn into_format<U, B>(self) -> Alpha<Okhsv<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<Okhsv<U>, B>) -> Self
where
T: FromStimulus<U> + FromAngle<U>,
A: FromStimulus<B>,
U: Zero + MinMax,
{
color.into_format()
}
pub fn into_components(self) -> (OklabHue<T>, T, T, A) {
(
self.color.hue,
self.color.saturation,
self.color.value,
self.alpha,
)
}
pub fn from_components<H: Into<OklabHue<T>>>(
(hue, saturation, value, alpha): (H, T, T, A),
) -> Self {
Self::new(hue, saturation, value, alpha)
}
}