RGB::random

Pick a color uniformly at random in RGB color space

Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

Syntax

RGB::random()

Description

RGB::random() returns a random color. The colors returned are distributed independently and uniformly in the RGB color space.

Examples

Example 1

RGB::random can be used to produce high-frequency noise:

plot(plot::Raster([[RGB::random() $ x = 0..42] $ y = 0..42]))

Example 2

It is possible to use RGB::random directly as a color function, but the result may be unexpected:

plot(plot::Waterman(5, FillColorFunction = RGB::random))

The reason is that the color function will be called repeatedly if the same point is met again. It is a better idea to create a bunch of random colors and then use the parameters passed into the color functions to get some consistency into the choice of colors:

colors := [RGB::random() $ i = 1..42]:
plot(plot::Waterman(5, FillColorFunction=((x,y,z,i) -> colors[i])))

Return Values

RGB color: A list of three floating-point values.

See Also

MuPAD Functions

Was this topic helpful?