Class: QgsRasterShader

class qgis.core.QgsRasterShader

Bases: sip.wrapper

Interface for all raster shaders.

Methods

maximumValue

Returns the maximum value for the raster shader.

minimumValue

Returns the minimum value for the raster shader.

rasterShaderFunction

rtype

QgsRasterShaderFunction

readXml

Reads shader state from an XML element.

setMaximumValue

Sets the maximum value for the raster shader.

setMinimumValue

Sets the minimum value for the raster shader.

setRasterShaderFunction

A public method that allows the user to set their own shader function.

shade

Generates a new RGBA value based on one input value.

writeXml

Writes shader state to an XML element.

maximumValue(self) → float

Returns the maximum value for the raster shader.

See also

minimumValue()

Return type

float

minimumValue(self) → float

Returns the minimum value for the raster shader.

See also

maximumValue()

Return type

float

rasterShaderFunction(self) → QgsRasterShaderFunction
Return type

QgsRasterShaderFunction

readXml(self, elem: QDomElement)

Reads shader state from an XML element.

Parameters

elem (QDomElement) –

setMaximumValue(self, value: float)

Sets the maximum value for the raster shader.

See also

maximumValue()

Parameters

value (float) –

setMinimumValue(self, value: float)

Sets the minimum value for the raster shader.

See also

minimumValue()

Parameters

value (float) –

setRasterShaderFunction(self, function: QgsRasterShaderFunction)

A public method that allows the user to set their own shader function.

Note

Raster shader takes ownership of the shader function instance

Parameters

function (QgsRasterShaderFunction) –

shade(self, value: float) → Tuple[bool, int, int, int, int]

Generates a new RGBA value based on one input value.

Parameters
  • value (float) – The original value to base a new RGBA value on

  • returnRedValue – The red component of the new RGBA value

  • returnGreenValue – The green component of the new RGBA value

  • returnBlueValue – The blue component of the new RGBA value

Returns

  • True if the return values are valid otherwise False

  • returnAlpha: The alpha component of the new RGBA value

shade(self, redValue: float, greenValue: float, blueValue: float, alphaValue: float) -> Tuple[bool, int, int, int, int] Generates a new RGBA value based on an original RGBA value.

Parameters
  • redValue – The red component of the original value to base a new RGBA value on

  • greenValue – The green component of the original value to base a new RGBA value on

  • blueValue – The blue component of the original value to base a new RGBA value on

  • alphaValue – The alpha component of the original value to base a new RGBA value on

  • returnRedValue – The red component of the new RGBA value

  • returnGreenValue – The green component of the new RGBA value

  • returnBlueValue – The blue component of the new RGBA value

Return type

Tuple[bool, int, int, int, int]

Returns

  • True if the return values are valid otherwise False

  • returnAlpha: The alpha component of the new RGBA value

writeXml(self, doc: QDomDocument, parent: QDomElement)

Writes shader state to an XML element.

Parameters
  • doc (QDomDocument) –

  • parent (QDomElement) –