colorMode()
Changes how colors are specified - using (Red, Green, Blue) or (Hue, Saturation, Brightness)
Example
RGB Mode (Red, Green, Blue)
HSB Mode (Hue, Saturation, Brightness)
Syntax
or
Input | Description |
---|---|
mode | RGB(Red/Green/Blue) or HSB(Hue/Saturation/Brightness) |
max(optional) | maximum value for each color component |
max1 | maximum value for red/hue component |
max2 | maximum value for green/saturation component |
max3 | maximum value for blue/brightness component |
maxA(optional) | maximum value for alpha component |
Full Example
Description
The colorMode()
function is used to set the range and mode for color values in a sketch. It determines how colors are represented and displayed in the canvas.
When the color mode is set to RGB, the maximum values for red, green, and blue are typically 255, which represents the maximum intensity of each color channel. When the color mode is set to HSB, the maximum values for hue, saturation, and brightness are typically 360, 100, and 100 respectively.
By default, the color mode is set to RGB with a maximum value of 255 for each color channel.
Find these documents helpful? Let the people who made them help your child learn to code at Strivemath!
We'd love to hear your Feedback/Comments here.
Last updated