Class: QgsGradientFillSymbolLayer

class qgis.core.QgsGradientFillSymbolLayer(color: QColor | Qt.GlobalColor | QGradient = DEFAULT_SIMPLEFILL_COLOR, color2: QColor | Qt.GlobalColor | QGradient = Qt.white, gradientColorType: Qgis.GradientColorSource = Qgis.GradientColorSource.SimpleTwoColor, gradientType: Qgis.GradientType = Qgis.GradientType.Linear, coordinateMode: Qgis.SymbolCoordinateReference = Qgis.SymbolCoordinateReference.Feature, gradientSpread: Qgis.GradientSpread = Qgis.GradientSpread.Pad)

Bases: QgsFillSymbolLayer

Constructor for QgsGradientFillSymbolLayer.

Enums

GradientColorType

alias of GradientColorSource

GradientCoordinateMode

alias of SymbolCoordinateReference

GradientSpread

Bases: enum.IntEnum

GradientType

Bases: enum.IntEnum

Methods

canCauseArtifactsBetweenAdjacentTiles

rtype:

bool

clone

rtype:

QgsGradientFillSymbolLayer

color2

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

colorRamp

Returns the color ramp used for the gradient fill.

coordinateMode

Returns the coordinate mode for gradient, which controls how the gradient stops are positioned.

copyDataDefinedProperties

Copies all data defined properties of this layer to another symbol layer.

copyPaintEffect

Copies paint effect of this layer to another symbol layer

create

Creates a new QgsGradientFillSymbolLayer using the specified properties map containing symbol properties (see properties()).

estimateMaxBleed

param context:

gradientColorType

Returns the gradient color mode, which controls how gradient color stops are created.

gradientSpread

Returns the gradient spread mode, which controls how the gradient behaves outside of the predefined stops.

gradientType

Returns the type of gradient, e.g., linear or radial.

layerType

rtype:

str

mapUnitScale

rtype:

QgsMapUnitScale

offset

Returns the offset by which polygons will be translated during rendering.

offsetMapUnitScale

Returns the map unit scale for the fill's offset.

offsetUnit

Returns the units for the fill's offset.

outputUnit

rtype:

QgsUnitTypes.RenderUnit

properties

rtype:

Dict[str, Any]

referencePoint1

Returns the starting point of gradient fill, in the range [0,0] - [1,1].

referencePoint1IsCentroid

Returns whether the starting point for the gradient is taken from the feature centroid.

referencePoint2

Returns the end point of gradient fill, in the range [0,0] - [1,1].

referencePoint2IsCentroid

Returns whether the end point for the gradient is taken from the feature centroid.

renderPolygon

param points:

restoreOldDataDefinedProperties

Restores older data defined properties from string map.

setColor2

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

setColorRamp

Sets the color ramp used for the gradient fill.

setCoordinateMode

Sets the coordinate mode for gradient, which controls how the gradient stops are positioned.

setGradientColorType

Sets the gradient color mode, which controls how gradient color stops are created.

setGradientSpread

Sets the gradient spread mode, which controls how the gradient behaves outside of the predefined stops.

setGradientType

Sets the type of gradient, e.g., linear or radial.

setMapUnitScale

param scale:

setOffset

Sets an offset by which polygons will be translated during rendering.

setOffsetMapUnitScale

Sets the map unit scale for the fill's offset.

setOffsetUnit

Sets the unit for the fill's offset.

setOutputUnit

param unit:

setReferencePoint1

Sets the starting point of gradient fill, in the range [0,0] - [1,1].

setReferencePoint1IsCentroid

Sets whether the starting point for the gradient is taken from the feature centroid.

setReferencePoint2

Sets the end point of gradient fill, in the range [0,0] - [1,1].

setReferencePoint2IsCentroid

Sets whether the end point for the gradient is taken from the feature centroid.

startRender

param context:

stopRender

param context:

usesMapUnits

rtype:

bool

GradientColorType

alias of GradientColorSource

GradientCoordinateMode

alias of SymbolCoordinateReference

class GradientSpread(value)

Bases: enum.IntEnum

Gradient spread options, which control how gradients are rendered outside of their start and end points.

Note

Prior to QGIS 3.24 this was available as QgsGradientFillSymbolLayer.GradientSpread

New in version 3.24.

  • Pad: Pad out gradient using colors at endpoint of gradient

  • Reflect: Reflect gradient

  • Repeat: Repeat gradient

baseClass

alias of Qgis

class GradientType(value)

Bases: enum.IntEnum

Gradient types.

Note

Prior to QGIS 3.24 this was available as QgsGradientFillSymbolLayer.GradientType

New in version 3.24.

  • Linear: Linear gradient

  • Radial: Radial (circular) gradient

  • Conical: Conical (polar) gradient

baseClass

alias of Qgis

canCauseArtifactsBetweenAdjacentTiles(self) bool
Return type:

bool

clone(self) QgsGradientFillSymbolLayer
Return type:

QgsGradientFillSymbolLayer

color2(self) QColor

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

See also

setColor2()

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) Qgis.SymbolCoordinateReference

Returns the coordinate mode for gradient, which controls how the gradient stops are positioned.

Return type:

Qgis.SymbolCoordinateReference

copyDataDefinedProperties(self, destLayer: QgsSymbolLayer)

Copies all data defined properties of this layer to another symbol layer.

Parameters:

destLayer – destination layer

copyPaintEffect(self, destLayer: QgsSymbolLayer)

Copies paint effect of this layer to another symbol layer

Parameters:

destLayer – destination layer

New in version 2.9.

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

Creates a new QgsGradientFillSymbolLayer using the specified properties map containing symbol properties (see properties()).

Caller takes ownership of the returned symbol layer.

Parameters:

properties (Dict[str) –

Return type:

QgsSymbolLayer

estimateMaxBleed(self, context: QgsRenderContext) float
Parameters:

context (QgsRenderContext) –

Return type:

float

gradientColorType(self) Qgis.GradientColorSource

Returns the gradient color mode, which controls how gradient color stops are created.

Return type:

Qgis.GradientColorSource

gradientSpread(self) Qgis.GradientSpread

Returns the gradient spread mode, which controls how the gradient behaves outside of the predefined stops.

Return type:

Qgis.GradientSpread

gradientType(self) Qgis.GradientType

Returns the type of gradient, e.g., linear or radial.

Return type:

Qgis.GradientType

layerType(self) str
Return type:

str

mapUnitScale(self) QgsMapUnitScale
Return type:

QgsMapUnitScale

offset(self) QPointF

Returns the offset by which polygons will be translated during rendering.

Units are specified by offsetUnit().

See also

setOffset()

See also

offsetUnit()

Return type:

QPointF

offsetMapUnitScale(self) QgsMapUnitScale

Returns the map unit scale for the fill’s offset.

See also

offset()

Return type:

QgsMapUnitScale

offsetUnit(self) QgsUnitTypes.RenderUnit

Returns the units for the fill’s offset.

See also

setOffsetUnit()

See also

offset()

Return type:

QgsUnitTypes.RenderUnit

outputUnit(self) QgsUnitTypes.RenderUnit
Return type:

QgsUnitTypes.RenderUnit

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

Dict[str, Any]

referencePoint1(self) QPointF

Returns the starting point of gradient fill, in the range [0,0] - [1,1].

Return type:

QPointF

referencePoint1IsCentroid(self) bool

Returns whether the starting point for the gradient is taken from the feature centroid.

Return type:

bool

referencePoint2(self) QPointF

Returns the end point of gradient fill, in the range [0,0] - [1,1].

Return type:

QPointF

referencePoint2IsCentroid(self) bool

Returns whether the end point for the gradient is taken from the feature centroid.

Return type:

bool

renderPolygon(self, points: QPolygonF, rings: Iterable[QPolygonF], context: QgsSymbolRenderContext)
Parameters:
restoreOldDataDefinedProperties(self, stringMap: Dict[str, Any])

Restores older data defined properties from string map.

New in version 3.0.

setColor2(self, color2: QColor | Qt.GlobalColor | QGradient)

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

See also

color2()

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: Qgis.SymbolCoordinateReference)

Sets the coordinate mode for gradient, which controls how the gradient stops are positioned.

See also

coordinateMode()

Parameters:

coordinateMode (Qgis.SymbolCoordinateReference) –

setGradientColorType(self, gradientColorType: Qgis.GradientColorSource)

Sets the gradient color mode, which controls how gradient color stops are created.

Parameters:

gradientColorType (Qgis.GradientColorSource) –

setGradientSpread(self, gradientSpread: Qgis.GradientSpread)

Sets the gradient spread mode, which controls how the gradient behaves outside of the predefined stops.

See also

gradientSpread()

Parameters:

gradientSpread (Qgis.GradientSpread) –

setGradientType(self, gradientType: Qgis.GradientType)

Sets the type of gradient, e.g., linear or radial.

See also

gradientType()

Parameters:

gradientType (Qgis.GradientType) –

setMapUnitScale(self, scale: QgsMapUnitScale)
Parameters:

scale (QgsMapUnitScale) –

setOffset(self, offset: QPointF | QPoint)

Sets an offset by which polygons will be translated during rendering.

Units are specified by offsetUnit().

See also

offset()

See also

setOffsetUnit()

Parameters:

offset (Union[QPointF) –

setOffsetMapUnitScale(self, scale: QgsMapUnitScale)

Sets the map unit scale for the fill’s offset.

See also

setOffset()

Parameters:

scale (QgsMapUnitScale) –

setOffsetUnit(self, unit: QgsUnitTypes.RenderUnit)

Sets the unit for the fill’s offset.

See also

offset()

See also

offsetUnit()

Parameters:

unit (QgsUnitTypes.RenderUnit) –

setOutputUnit(self, unit: QgsUnitTypes.RenderUnit)
Parameters:

unit (QgsUnitTypes.RenderUnit) –

setReferencePoint1(self, referencePoint: QPointF | QPoint)

Sets the starting point of gradient fill, in the range [0,0] - [1,1].

Parameters:

referencePoint (Union[QPointF) –

setReferencePoint1IsCentroid(self, isCentroid: bool)

Sets whether the starting point for the gradient is taken from the feature centroid.

Parameters:

isCentroid (bool) –

setReferencePoint2(self, referencePoint: QPointF | QPoint)

Sets the end point of gradient fill, in the range [0,0] - [1,1].

Parameters:

referencePoint (Union[QPointF) –

setReferencePoint2IsCentroid(self, isCentroid: bool)

Sets whether the end point for the gradient is taken from the feature centroid.

Parameters:

isCentroid (bool) –

startRender(self, context: QgsSymbolRenderContext)
Parameters:

context (QgsSymbolRenderContext) –

stopRender(self, context: QgsSymbolRenderContext)
Parameters:

context (QgsSymbolRenderContext) –

usesMapUnits(self) bool
Return type:

bool