Extract the alpha component as a wrapper type #22
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This closes #11 by adding a wrapper type that bolts the alpha component to any color. This works well because of how passive the alpha is in most of the calculations and conversions, and results in a relatively low amount of code duplication.
Each color space (and
Color
) has a sibling type alias with ana
added to the name, such asRgba
. Those are alias forAlpha<C<T>, T>
, whereC
is the color space type, and can be used more or less in the same way as their non-alpha variants. Conversion between alpha types and non-alpha types is as easy as always.This is a breaking change, since the alpha component is removed from every color and constructors are moved and/or renamed. The new constructors follows the same convention as the constructors in
Srgb
andGammaRgb
, which isnew
for float values andnew_u8
foru8
values. The constructors onColor
are roughly the same as before, with the exception of changing things likergb8
torgb_u8
.