Skip to content

[p5.js 2.0] Restore single color value define grayscale color #7676

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 4, 2025

Conversation

limzykenneth
Copy link
Member

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).

@ksen0
Copy link
Member

ksen0 commented Mar 28, 2025

This seems great! Thank for the clarification too.

@perminder-17 I see the new colorMode arguments are on your documentation list, please prioritize that task one from the remaining "Added" documentation, and include these grayscale updates. I'm adding it to the spreadsheet as well. Thank you!

@perminder-17
Copy link
Contributor

perminder-17 commented Mar 29, 2025

This seems great! Thank for the clarification too.

@perminder-17 I see the new colorMode arguments are on your documentation list, please prioritize that task one from the remaining "Added" documentation, and include these grayscale updates. I'm adding it to the spreadsheet as well. Thank you!

Sure, thanks. I'll do it by today.

@limzykenneth limzykenneth merged commit a19995f into processing:dev-2.0 Apr 4, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants