QgsLimitedRandomColorRamp class

Constrained random color ramp, which returns random colors based on preset parameters.

Base classes

class QgsColorRamp
Abstract base class for color ramps.

Public static functions

static auto create(const QgsStringMap& properties = QgsStringMap()) -> QgsColorRamp*
Returns a new QgsLimitedRandomColorRamp color ramp created using the properties encoded in a string map.
static auto randomColors(int count, int hueMax = DEFAULT_RANDOM_HUE_MAX, int hueMin = DEFAULT_RANDOM_HUE_MIN, int satMax = DEFAULT_RANDOM_SAT_MAX, int satMin = DEFAULT_RANDOM_SAT_MIN, int valMax = DEFAULT_RANDOM_VAL_MAX, int valMin = DEFAULT_RANDOM_VAL_MIN) -> QList<QColor>
Gets a list of random colors.

Constructors, destructors, conversion operators

QgsLimitedRandomColorRamp(int count = DEFAULT_RANDOM_COUNT, int hueMin = DEFAULT_RANDOM_HUE_MIN, int hueMax = DEFAULT_RANDOM_HUE_MAX, int satMin = DEFAULT_RANDOM_SAT_MIN, int satMax = DEFAULT_RANDOM_SAT_MAX, int valMin = DEFAULT_RANDOM_VAL_MIN, int valMax = DEFAULT_RANDOM_VAL_MAX)
Constructor for QgsLimitedRandomColorRamp.

Public functions

auto clone() const -> QgsLimitedRandomColorRamp* 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 hueMax() const -> int
Returns the maximum hue for generated colors.
auto hueMin() const -> int
Returns the minimum hue for generated colors.
auto properties() const -> QgsStringMap override
Returns a string map containing all the color ramp's properties.
auto satMax() const -> int
Returns the maximum saturation for generated colors.
auto satMin() const -> int
Returns the minimum saturation for generated colors.
void setCount(int val)
Sets the number of colors contained in the ramp.
void setHueMax(int val)
Sets the maximum hue for generated colors.
void setHueMin(int val)
Sets the minimum hue for generated colors.
void setSatMax(int val)
Sets the maximum saturation for generated colors.
void setSatMin(int val)
Sets the minimum saturation for generated colors.
void setValMax(int val)
Sets the maximum value for generated colors.
void setValMin(int val)
Sets the minimum value for generated colors.
auto type() const -> QString override
Returns a string representing the color ramp type.
void updateColors()
Must be called after changing the properties of the color ramp to regenerate the list of random colors.
auto valMax() const -> int
Returns the maximum value for generated colors.
auto valMin() const -> int
Returns the minimum value for generated colors.
auto value(int index) const -> double override
Returns relative value between [0,1] of color at specified index.

Function documentation

static QgsColorRamp* QgsLimitedRandomColorRamp::create(const QgsStringMap& properties = QgsStringMap())

Returns a new QgsLimitedRandomColorRamp color ramp created using the properties encoded in a string map.

Parameters
properties color ramp properties

static QList<QColor> QgsLimitedRandomColorRamp::randomColors(int count, int hueMax = DEFAULT_RANDOM_HUE_MAX, int hueMin = DEFAULT_RANDOM_HUE_MIN, int satMax = DEFAULT_RANDOM_SAT_MAX, int satMin = DEFAULT_RANDOM_SAT_MIN, int valMax = DEFAULT_RANDOM_VAL_MAX, int valMin = DEFAULT_RANDOM_VAL_MIN)

Gets a list of random colors.

QgsLimitedRandomColorRamp::QgsLimitedRandomColorRamp(int count = DEFAULT_RANDOM_COUNT, int hueMin = DEFAULT_RANDOM_HUE_MIN, int hueMax = DEFAULT_RANDOM_HUE_MAX, int satMin = DEFAULT_RANDOM_SAT_MIN, int satMax = DEFAULT_RANDOM_SAT_MAX, int valMin = DEFAULT_RANDOM_VAL_MIN, int valMax = DEFAULT_RANDOM_VAL_MAX)

Constructor for QgsLimitedRandomColorRamp.

Parameters
count number of colors in ramp
hueMin minimum hue
hueMax maximum hue
satMin minimum saturation
satMax maximum saturation
valMin minimum color value
valMax maximum color value

QColor QgsLimitedRandomColorRamp::color(double value) const override

Returns the color corresponding to a specified value.

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

int QgsLimitedRandomColorRamp::hueMax() const

Returns the maximum hue for generated colors.

int QgsLimitedRandomColorRamp::hueMin() const

Returns the minimum hue for generated colors.

int QgsLimitedRandomColorRamp::satMax() const

Returns the maximum saturation for generated colors.

int QgsLimitedRandomColorRamp::satMin() const

Returns the minimum saturation for generated colors.

void QgsLimitedRandomColorRamp::setHueMax(int val)

Sets the maximum hue for generated colors.

void QgsLimitedRandomColorRamp::setHueMin(int val)

Sets the minimum hue for generated colors.

void QgsLimitedRandomColorRamp::setSatMax(int val)

Sets the maximum saturation for generated colors.

void QgsLimitedRandomColorRamp::setSatMin(int val)

Sets the minimum saturation for generated colors.

void QgsLimitedRandomColorRamp::setValMax(int val)

Sets the maximum value for generated colors.

void QgsLimitedRandomColorRamp::setValMin(int val)

Sets the minimum value for generated colors.

int QgsLimitedRandomColorRamp::valMax() const

Returns the maximum value for generated colors.

int QgsLimitedRandomColorRamp::valMin() const

Returns the minimum value for generated colors.