Skip to content

added documentation to _getBrightness() and _getGreen() function #7908

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 10 commits into from
Jun 18, 2025
12 changes: 12 additions & 0 deletions src/color/p5.Color.js
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,11 @@ class Color {
}
}

/**
* This function extracts the green value from a color object and
* returns it in the range 0–255 by default. When `colorMode()` is given to an
* RBG value, the green value within the givin range is returned
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor - typo: "given"

*/
_getGreen(max=[0, 1]) {
if(!Array.isArray(max)){
max = [0, max];
Expand Down Expand Up @@ -625,6 +630,13 @@ class Color {
return map(to(this._color, 'hsl').coords[1], colorjsMax[0], colorjsMax[1], max[0], max[1]);
}
}
/**
* Brightness obtains the HSB brightness value from either a p5.Color object,
* an array of color components, or a CSS color string.Depending on value,
* when `colorMode()` is set to HSB, this function will return the
* brightness value in the range. By default, this function will return
* the HSB brightness within the range 0 - 100.
*/

_getBrightness(max=[0, 100]) {
if(!Array.isArray(max)){
Expand Down