Class: QgsGradientFillSymbolLayer

class qgis.core.QgsGradientFillSymbolLayer(color: Union[QColor, Qt.GlobalColor] = DEFAULT_SIMPLEFILL_COLOR, color2: Union[QColor, Qt.GlobalColor] = Qt.white, gradientColorType: QgsGradientFillSymbolLayer.GradientColorType = QgsGradientFillSymbolLayer.SimpleTwoColor, gradientType: QgsGradientFillSymbolLayer.GradientType = QgsGradientFillSymbolLayer.Linear, coordinateMode: QgsGradientFillSymbolLayer.GradientCoordinateMode = QgsGradientFillSymbolLayer.Feature, gradientSpread: QgsGradientFillSymbolLayer.GradientSpread = QgsGradientFillSymbolLayer.Pad)

Bases: QgsFillSymbolLayer

QgsGradientFillSymbolLayer(QgsGradientFillSymbolLayer)

Parameters
  • color (Union[QColor) –

  • color2 (Union[QColor) –

  • gradientColorType (QgsGradientFillSymbolLayer.GradientColorType = QgsGradientFillSymbolLayer.SimpleTwoColor) –

  • gradientType (QgsGradientFillSymbolLayer.GradientType = QgsGradientFillSymbolLayer.Linear) –

  • coordinateMode (QgsGradientFillSymbolLayer.GradientCoordinateMode = QgsGradientFillSymbolLayer.Feature) –

  • gradientSpread

ColorRamp = 1
Conical = 2
Feature = 0
class GradientColorType

Bases: int

class GradientCoordinateMode

Bases: int

class GradientSpread

Bases: int

class GradientType

Bases: int

Linear = 0
Pad = 0
Radial = 1
Reflect = 1
Repeat = 2
SimpleTwoColor = 0
Viewport = 1
clone(self) → QgsGradientFillSymbolLayer
Return type

QgsGradientFillSymbolLayer

color2(self) → QColor

Color for endpoint of gradient, only used if the gradient color type is set to SimpleTwoColor

Return type

QColor

colorRamp(self) → QgsColorRamp

Returns the color ramp used for the gradient fill. This is only used if the gradient color type is set to ColorRamp.

See also

setColorRamp()

Return type

QgsColorRamp

coordinateMode(self) → QgsGradientFillSymbolLayer.GradientCoordinateMode

Coordinate mode for gradient. Controls how the gradient stops are positioned.

Return type

QgsGradientFillSymbolLayer.GradientCoordinateMode

copyDataDefinedProperties()
copyPaintEffect()
create(properties: Dict[str, str] = {}) → QgsSymbolLayer
Parameters

properties (Dict[str) –

Return type

QgsSymbolLayer

estimateMaxBleed(self, context: QgsRenderContext) → float
Parameters

context (QgsRenderContext) –

Return type

float

gradientColorType(self) → QgsGradientFillSymbolLayer.GradientColorType

Gradient color mode, controls how gradient color stops are created

Return type

QgsGradientFillSymbolLayer.GradientColorType

gradientSpread(self) → QgsGradientFillSymbolLayer.GradientSpread

Gradient spread mode. Controls how the gradient behaves outside of the predefined stops

Return type

QgsGradientFillSymbolLayer.GradientSpread

gradientType(self) → QgsGradientFillSymbolLayer.GradientType

Type of gradient, e.g., linear or radial

Return type

QgsGradientFillSymbolLayer.GradientType

layerType(self) → str
Return type

str

mapUnitScale(self) → QgsMapUnitScale
Return type

QgsMapUnitScale

offset(self) → QPointF
Return type

QPointF

offsetMapUnitScale(self) → QgsMapUnitScale
Return type

QgsMapUnitScale

offsetUnit(self) → QgsUnitTypes.RenderUnit
Return type

QgsUnitTypes.RenderUnit

outputUnit(self) → QgsUnitTypes.RenderUnit
Return type

QgsUnitTypes.RenderUnit

properties(self) → Dict[str, str]
Return type

Dict[str, str]

referencePoint1(self) → QPointF
Return type

QPointF

referencePoint1IsCentroid(self) → bool
Return type

bool

referencePoint2(self) → QPointF
Return type

QPointF

referencePoint2IsCentroid(self) → bool
Return type

bool

renderPolygon(self, points: QPolygonF, rings: Iterable[QPolygonF], context: QgsSymbolRenderContext)
Parameters
restoreOldDataDefinedProperties()
setColor2(self, color2: Union[QColor, Qt.GlobalColor])
Parameters

color2 (Union[QColor) –

setColorRamp(self, ramp: QgsColorRamp)

Sets the color ramp used for the gradient fill. This is only used if the gradient color type is set to ColorRamp.

Parameters

ramp (QgsColorRamp) – color ramp. Ownership is transferred.

See also

colorRamp()

setCoordinateMode(self, coordinateMode: QgsGradientFillSymbolLayer.GradientCoordinateMode)
Parameters

coordinateMode (QgsGradientFillSymbolLayer.GradientCoordinateMode) –

setGradientColorType(self, gradientColorType: QgsGradientFillSymbolLayer.GradientColorType)
Parameters

gradientColorType (QgsGradientFillSymbolLayer.GradientColorType) –

setGradientSpread(self, gradientSpread: QgsGradientFillSymbolLayer.GradientSpread)
Parameters

gradientSpread (QgsGradientFillSymbolLayer.GradientSpread) –

setGradientType(self, gradientType: QgsGradientFillSymbolLayer.GradientType)
Parameters

gradientType (QgsGradientFillSymbolLayer.GradientType) –

setMapUnitScale(self, scale: QgsMapUnitScale)
Parameters

scale (QgsMapUnitScale) –

setOffset(self, offset: Union[QPointF, QPoint])

Offset for gradient fill

Parameters

offset (Union[QPointF) –

setOffsetMapUnitScale(self, scale: QgsMapUnitScale)
Parameters

scale (QgsMapUnitScale) –

setOffsetUnit(self, unit: QgsUnitTypes.RenderUnit)

Units for gradient fill offset

Parameters

unit (QgsUnitTypes.RenderUnit) –

setOutputUnit(self, unit: QgsUnitTypes.RenderUnit)
Parameters

unit (QgsUnitTypes.RenderUnit) –

setReferencePoint1(self, referencePoint: Union[QPointF, QPoint])

Starting point of gradient fill, in the range [0,0] - [1,1]

Parameters

referencePoint (Union[QPointF) –

setReferencePoint1IsCentroid(self, isCentroid: bool)

Sets the starting point of the gradient to be the feature centroid

Parameters

isCentroid (bool) –

setReferencePoint2(self, referencePoint: Union[QPointF, QPoint])

End point of gradient fill, in the range [0,0] - [1,1]

Parameters

referencePoint (Union[QPointF) –

setReferencePoint2IsCentroid(self, isCentroid: bool)

Sets the end point of the gradient to be the feature centroid

Parameters

isCentroid (bool) –

startRender(self, context: QgsSymbolRenderContext)
Parameters

context (QgsSymbolRenderContext) –

stopRender(self, context: QgsSymbolRenderContext)
Parameters

context (QgsSymbolRenderContext) –