Class: QgsLimitedRandomColorRamp

class qgis.core.QgsLimitedRandomColorRamp

Bases: QgsColorRamp

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

QgsLimitedRandomColorRamp(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 – 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

QgsLimitedRandomColorRamp(QgsLimitedRandomColorRamp)

Methods

clone

rtype:

QgsLimitedRandomColorRamp

color

param value:

count

rtype:

int

create

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

hueMax

Returns the maximum hue for generated colors

hueMin

Returns the minimum hue for generated colors

properties

rtype:

Dict[str, Any]

randomColors

Gets a list of random colors

satMax

Returns the maximum saturation for generated colors

satMin

Returns the minimum saturation for generated colors

setCount

Sets the number of colors contained in the ramp.

setHueMax

Sets the maximum hue for generated colors

setHueMin

Sets the minimum hue for generated colors

setSatMax

Sets the maximum saturation for generated colors

setSatMin

Sets the minimum saturation for generated colors

setValMax

Sets the maximum value for generated colors

setValMin

Sets the minimum value for generated colors

type

rtype:

str

typeString

Returns the string identifier for QgsLimitedRandomColorRamp.

updateColors

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

valMax

Returns the maximum value for generated colors

valMin

Returns the minimum value for generated colors

value

param index:

clone(self) QgsLimitedRandomColorRamp
Return type:

QgsLimitedRandomColorRamp

color(self, value: float) QColor
Parameters:

value (float) –

Return type:

QColor

count(self) int
Return type:

int

create(properties: Dict[str, Any] = {}) QgsColorRamp

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

Parameters:

properties (Dict[str) – color ramp properties

See also

properties()

Return type:

QgsColorRamp

hueMax(self) int

Returns the maximum hue for generated colors

See also

setHueMax()

Return type:

int

hueMin(self) int

Returns the minimum hue for generated colors

See also

setHueMin()

Return type:

int

properties(self) Dict[str, Any]
Return type:

Dict[str, Any]

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

Returns the maximum saturation for generated colors

See also

setSatMax()

Return type:

int

satMin(self) int

Returns the minimum saturation for generated colors

See also

setSatMin()

Return type:

int

setCount(self, val: int)

Sets the number of colors contained in the ramp.

Parameters:

val (int) –

setHueMax(self, val: int)

Sets the maximum hue for generated colors

See also

hueMax()

Parameters:

val (int) –

setHueMin(self, val: int)

Sets the minimum hue for generated colors

See also

hueMin()

Parameters:

val (int) –

setSatMax(self, val: int)

Sets the maximum saturation for generated colors

See also

satMax()

Parameters:

val (int) –

setSatMin(self, val: int)

Sets the minimum saturation for generated colors

See also

satMin()

Parameters:

val (int) –

setValMax(self, val: int)

Sets the maximum value for generated colors

See also

valMax()

Parameters:

val (int) –

setValMin(self, val: int)

Sets the minimum value for generated colors

See also

valMin()

Parameters:

val (int) –

type(self) str
Return type:

str

typeString() str

Returns the string identifier for QgsLimitedRandomColorRamp.

New in version 3.16.

Return type:

str

updateColors(self)

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

valMax(self) int

Returns the maximum value for generated colors

See also

setValMax()

Return type:

int

valMin(self) int

Returns the minimum value for generated colors

See also

setValMin()

Return type:

int

value(self, index: int) float
Parameters:

index (int) –

Return type:

float