Per my comment in #190 (comment).
Sketch:
// similar to colorspacetag
enum AlphaType {
Alpha,
PremultipliedAlpha,
}
struct Alpha;
struct PremultipliedAlpha;
// for const generic
// alpha trait is like colorspace trait
impl AlphaTrait for Alpha {
const ALPHA = AlphaType::Alpha;
}
impl AlphaTrait for AlphaPremultiplied {
const ALPHA = AlphaType::AlphaPremultiplied;
}
pub struct AlphaColor<CS, A> {
/// The components, which may be manipulated directly.
///
/// The interpretation of the first three components depends on the color
/// space. The fourth component is separate alpha.
pub components: [f32; 4],
/// The color space.
pub cs: PhantomData<CS>,
pub alpha: PhantomData<A>,
}
pub struct DynamicColor {
pub alpha: AlpahType,
/// The color space.
pub cs: ColorSpaceTag,
/// The state of this color, tracking whether it has missing components and how it was
/// constructed. See the documentation of [`Flags`] for more information.
pub flags: Flags,
/// The components.
///
/// The first three components are interpreted according to the
/// color space tag. The fourth component is alpha, interpreted
/// as separate alpha.
pub components: [f32; 4],
}
PremulColor would be AlphaColor<_, PremiltipliedAlpha> so we can share more impls and DynamicColor is now also dynamic over AlphaType.
Motivation:
This would be break change.
Per my comment in #190 (comment).
Sketch:
PremulColorwould beAlphaColor<_, PremiltipliedAlpha>so we can share more impls andDynamicColoris now also dynamic over AlphaType.Motivation:
AlphaColorvsPremulColorpremultiplication #190 (comment):This would be break change.