You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Jolon Faichney edited this page Feb 23, 2017
·
5 revisions
Colour Modes
p5.js supports two colour modes: RGB and HSB
RGB: Red, Green, Blue
HSB: Hue, Saturation, Brightness
By default the colour mode is RGB, however it can be changed using the colorMode() function to HSB, e.g.:
colorMode(HSB);
By default colour values range from 0-255 (which is standard on computers), however you can also change this range, for example from 0-99, you read more about it in the colorMode reference.
Fill Colour
Our shapes so far have been filled with white. We can change this using the fill() function. The fill() function takes a greyscale or RGB colour as parameters. A white and pink ellipse:
Specifying alpha values allows for transparency. In the following example the pink ellipse is 50% transparent, by specifying an alpha of 128 (50% of 255).