Skip to content

Which multiplication *is* Mul<LinSrgb>? #331

Answered by Ogeon
ChasJC23 asked this question in Q&A
Discussion options

You must be logged in to vote

Alright, I'm able to expand on my response a bit, but I hope it was the answer to the main question.

Are they piecewise (or close enough for the difference to not matter in my case)?

Yes. Your initial assumption was entirely correct, and if you stick to Srgb, LinSrgb and similar aliases without the a at the end, you shouldn't get any problems with alpha either, since those don't have the Alpha wrapper involved anywhere. But even with it, the multiplication operator doesn't mix the alpha values into the color values on its own. Here's what the macro expands to in the case of Rgb, for multiplying two colors:

impl<S, T> Mul<Self> for Rgb<S, T>
where
    T: Mul<Output = T>,
{
    type Output

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
6 replies
@Ogeon
Comment options

Answer selected by ChasJC23
@Ogeon
Comment options

@ChasJC23
Comment options

@Ogeon
Comment options

@ChasJC23
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants