[p5.js 2.0] Restore single color value define grayscale color #7676
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.
Resolves #7652
Changes:
Defining colors with single value now always gives grayscale color. Behavior of RGB, HSB, and HSL mode should be identical to 1.x (ie. RGB still uses Blue max, not sure if that is still what we want but it can be changed if needed).
Lab, LCH, OKLab, and OKLCH will use the lightness value and max.
HWB is the trickiest one and I don't think have a good solution. The reason is the full range of grayscale value in HWB requires both the whiteness and blackness values (ie. W and B) so it may be required to parse a single max value from potentially 2 different max values. What I have done in this case is to get both maxes and calculate an average max and use that instead (eg. W max is 50 and B max is 100: (50 + 100) / 2 = 75, 75 is the max used). Unlike the other single value max however, it cannot take into account more complex max ranges such as [-100, 100] since that is even more ambiguous (defining max as a range is a new not yet documented feature of the color mode function).