Class: QgsColorRampTransformer¶
QgsPropertyTransformer
subclass for transforming a numeric
value into a color from a color ramp.
Class Hierarchy¶
Base classes¶
Abstract base class for objects which transform the calculated value of a property. |
Methods
Calculates the color corresponding to a specific value. |
|
Returns the color ramp used for calculating property colors. |
|
Returns the color corresponding to a null value. |
|
Returns the color ramp's name. |
|
Sets the color ramp to use for calculating property colors. |
|
Sets the color corresponding to a null value. |
|
Sets the color ramp's name. |
- class qgis.core.QgsColorRampTransformer[source]¶
Bases:
QgsPropertyTransformer
- __init__(minValue: float = 0, maxValue: float = 1, ramp: QgsColorRamp | None = None, nullColor: QColor | Qt.GlobalColor = QColor(0, 0, 0, 0), rampName: str | None = '')
Constructor for QgsColorRampTransformer.
- Parameters:
minValue (float = 0) – minimum expected value
maxValue (float = 1) – maximum expected value
ramp (Optional[QgsColorRamp] = None) – source color ramp. Ownership is transferred to the transformer.
nullColor (Union[QColor, Qt.GlobalColor] = QColor(0, 0, 0, 0)) – color to return for null values
rampName (Optional[str] = '') – name of the source color ramp (since QGIS 3.36)
- __init__(other: QgsColorRampTransformer)
- Parameters:
other (QgsColorRampTransformer)
- color(self, value: float) QColor [source]¶
Calculates the color corresponding to a specific value.
- Parameters:
value (float) – value to calculate color for
- Return type:
QColor
- Returns:
calculated color using transformer’s parameters and type
- colorRamp(self) QgsColorRamp | None [source]¶
Returns the color ramp used for calculating property colors.
- Return type:
Optional[QgsColorRamp]
- Returns:
color ramp
See also
- nullColor(self) QColor [source]¶
Returns the color corresponding to a null value.
See also
- Return type:
QColor
- setColorRamp(self, ramp: QgsColorRamp | None)[source]¶
Sets the color ramp to use for calculating property colors.
- Parameters:
ramp (Optional[QgsColorRamp]) – color ramp, ownership of ramp is transferred to the transformer.
See also
- setNullColor(self, color: QColor | Qt.GlobalColor)[source]¶
Sets the color corresponding to a null value.
- Parameters:
color (Union[QColor, Qt.GlobalColor]) – null color
See also