MudColor: Fix special case in GenerateGradientPalette #10316
Merged
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.
Description
Follow-up PR for: #10313
This fixes an issue where setting
numberOfColors = 1
inGenerateGradientPalette
causes the following line:to return
NaN
, resulting in the end color being white.The fix adds a special case to handle the situation when
numberOfColors = 1
. An alternative approach would be to throw an exception whennumberOfColors
is less than two, but I believe this approach is better. If someone wants to create a multi-gradient palette,GenerateGradientPalette
could be reused, and there could be scenarios where the number of colors per segment is equal to one, which would cause the same problem again.How Has This Been Tested?
Unit tests, visually
Type of Changes
Checklist
dev
).