Remove ambiguous Color math implementations #3925
Closed
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.
Objective
The implementations are very ambiguous, and it's easy to make bugs using them, especially Hsla variant. They treat
ColorasVec4, which isn't quite right. Color values should be clamped to[0.0,1.0], but there are no checks. It adds/multiplies the first 3 values, regardless of the color's variant (There's no reason why you should multiply 3 values ofHslat once). Also, I (and maybe some other people) initially thoughtColor::GREEN * 0.5would result in semi-transparent green, but it makes it darker instead, so it makes it hard to read.Mul<f32>example (but the same errors apply to every other implementation):Solution
Remove it! It's only used by 1 example (btw it's multiplying ORANGE_RED by 2 making .r() == 2.0, which is a bug, but the renderer somehow handles it).