QgsRandomColorRamp class

Totally random color ramp.

Returns colors generated at random, but constrained to some hardcoded saturation and value ranges to prevent ugly color generation.

Base classes

class QgsColorRamp
Abstract base class for color ramps.

Constructors, destructors, conversion operators

QgsRandomColorRamp() defaulted
Constructor for QgsRandomColorRamp.

Public functions

auto clone() const -> QgsRandomColorRamp* override
Creates a clone of the color ramp.
auto color(double value) const -> QColor override
Returns the color corresponding to a specified value.
auto count() const -> int override
Returns number of defined colors, or -1 if undefined.
auto properties() const -> QgsStringMap override
Returns a string map containing all the color ramp's properties.
void setTotalColorCount(int colorCount) virtual
Sets the desired total number of unique colors for the resultant ramp.
auto type() const -> QString override
Returns a string representing the color ramp type.
auto value(int index) const -> double override
Returns relative value between [0,1] of color at specified index.

Function documentation

QColor QgsRandomColorRamp::color(double value) const override

Returns the color corresponding to a specified value.

Parameters
value value between [0, 1] inclusive
Returns color for value

void QgsRandomColorRamp::setTotalColorCount(int colorCount) virtual

Sets the desired total number of unique colors for the resultant ramp.

Parameters
colorCount number of unique colors

Calling this method pregenerates a set of visually distinct colors which are returned by subsequent calls to color().