Referencia toString()

toString()

Returns the color formatted as a String.

Calling myColor.toString() can be useful for debugging, as in print(myColor.toString()). It's also helpful for using p5.js with other libraries.

The parameter, format, is optional. If a format string is passed, as in myColor.toString('#rrggbb'), it will determine how the color string is formatted. By default, color strings are formatted as 'rgba(r, g, b, a)'.

Ejemplos

Sintaxis

toString([format])

Parámetros

format
String:

how the color string will be formatted. Leaving this empty formats the string as rgba(r, g, b, a). '#rgb' '#rgba' '#rrggbb' and '#rrggbbaa' format as hexadecimal color codes. 'rgb' 'hsb' and 'hsl' return the color formatted in the specified color mode. 'rgba' 'hsba' and 'hsla' are the same as above but with alpha channels. 'rgb%' 'hsb%' 'hsl%' 'rgba%' 'hsba%' and 'hsla%' format as percentages.

Returns

String: the formatted string.
Notice any errors or typos? Please let us know. Please feel free to edit src/color/p5.Color.js and open a pull request!

Referencias Relacionadas