Changes the way color values are interpreted.
By default, the Number
parameters for fill(), stroke(), background(), and color() are defined by values between 0 and 255 using the RGB color model. This is equivalent to calling colorMode(RGB, 255)
. Pure red is color(255, 0, 0)
in this model.
Calling colorMode(RGB, 100)
sets colors to use RGB color values between 0 and 100. Pure red is color(100, 0, 0)
in this model.
Calling colorMode(HSB)
or colorMode(HSL)
changes to HSB or HSL system instead of RGB. Pure red is color(0, 100, 100)
in HSB and color(0, 100, 50)
in HSL.
p5.Color objects remember the mode that they were created in. Changing modes doesn't affect their appearance.
Examples
Syntax
colorMode(mode, [max])
colorMode(mode, max1, max2, max3, [maxA])
Parameters
either RGB, HSB or HSL, corresponding to Red/Green/Blue and Hue/Saturation/Brightness (or Lightness).
range for all values.
range for the red or hue depending on the current color mode.
range for the green or saturation depending on the current color mode.
range for the blue or brightness/lightness depending on the current color mode.
range for the alpha.