-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
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 also allow us to deduplicated (un)premultiplied interpolation/gradient stuff.
- Better document
AlphaColorvsPremulColorpremultiplication #190 (comment):One color variant says "I have this kind of [alpha]" (you need to know that premul is an abbreviation for a word and that this word pertains to alpha).
The other says "I have alpha".
This would be break change.
Metadata
Metadata
Assignees
Labels
No labels