Class: QgsLimitedRandomColorRamp

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

Class Hierarchy

Inheritance diagram of qgis.core.QgsLimitedRandomColorRamp

Base classes

QgsColorRamp

Abstract base class for color ramps.

class qgis.core.QgsLimitedRandomColorRamp[source]

Bases: QgsColorRamp

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

Constructor for QgsLimitedRandomColorRamp

Parameters:
  • count (int = DEFAULT_RANDOM_COUNT) – number of colors in ramp

  • hueMin (int = DEFAULT_RANDOM_HUE_MIN) – minimum hue

  • hueMax (int = DEFAULT_RANDOM_HUE_MAX) – maximum hue

  • satMin (int = DEFAULT_RANDOM_SAT_MIN) – minimum saturation

  • satMax (int = DEFAULT_RANDOM_SAT_MAX) – maximum saturation

  • valMin (int = DEFAULT_RANDOM_VAL_MIN) – minimum color value

  • valMax (int = DEFAULT_RANDOM_VAL_MAX) – maximum color value

__init__(a0: QgsLimitedRandomColorRamp)
Parameters:

a0 (QgsLimitedRandomColorRamp)

static create(properties: Dict[str, Any] = {}) QgsColorRamp | None[source]

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

Parameters:

properties (Dict[str, Any] = {}) – color ramp properties

See also

properties()

Return type:

Optional[QgsColorRamp]

hueMax(self) int[source]

Returns the maximum hue for generated colors

See also

setHueMax()

Return type:

int

hueMin(self) int[source]

Returns the minimum hue for generated colors

See also

setHueMin()

Return type:

int

static randomColors(count: int, hueMax: int = DEFAULT_RANDOM_HUE_MAX, hueMin: int = DEFAULT_RANDOM_HUE_MIN, satMax: int = DEFAULT_RANDOM_SAT_MAX, satMin: int = DEFAULT_RANDOM_SAT_MIN, valMax: int = DEFAULT_RANDOM_VAL_MAX, valMin: int = DEFAULT_RANDOM_VAL_MIN) List[QColor]

Gets a list of random colors

Parameters:
  • count (int)

  • hueMax (int = DEFAULT_RANDOM_HUE_MAX)

  • hueMin (int = DEFAULT_RANDOM_HUE_MIN)

  • satMax (int = DEFAULT_RANDOM_SAT_MAX)

  • satMin (int = DEFAULT_RANDOM_SAT_MIN)

  • valMax (int = DEFAULT_RANDOM_VAL_MAX)

  • valMin (int = DEFAULT_RANDOM_VAL_MIN)

Return type:

List[QColor]

satMax(self) int[source]

Returns the maximum saturation for generated colors

See also

setSatMax()

Return type:

int

satMin(self) int[source]

Returns the minimum saturation for generated colors

See also

setSatMin()

Return type:

int

setCount(self, val: int)[source]

Sets the number of colors contained in the ramp.

Parameters:

val (int)

setHueMax(self, val: int)[source]

Sets the maximum hue for generated colors

See also

hueMax()

Parameters:

val (int)

setHueMin(self, val: int)[source]

Sets the minimum hue for generated colors

See also

hueMin()

Parameters:

val (int)

setSatMax(self, val: int)[source]

Sets the maximum saturation for generated colors

See also

satMax()

Parameters:

val (int)

setSatMin(self, val: int)[source]

Sets the minimum saturation for generated colors

See also

satMin()

Parameters:

val (int)

setValMax(self, val: int)[source]

Sets the maximum value for generated colors

See also

valMax()

Parameters:

val (int)

setValMin(self, val: int)[source]

Sets the minimum value for generated colors

See also

valMin()

Parameters:

val (int)

static typeString() str[source]

Returns the string identifier for QgsLimitedRandomColorRamp.

Added in version 3.16.

Return type:

str

updateColors(self)[source]

Must be called after changing the properties of the color ramp to regenerate the list of random colors.

valMax(self) int[source]

Returns the maximum value for generated colors

See also

setValMax()

Return type:

int

valMin(self) int[source]

Returns the minimum value for generated colors

See also

setValMin()

Return type:

int