Class: QgsGradientFillSymbolLayer

class qgis.core.QgsGradientFillSymbolLayer(color: QColor | Qt.GlobalColor = DEFAULT_SIMPLEFILL_COLOR, color2: 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

Methods

canCauseArtifactsBetweenAdjacentTiles

rtype:

bool

clone

rtype:

QgsGradientFillSymbolLayer

color2

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

Coordinate mode for gradient.

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

Gradient color mode, controls how gradient color stops are created

gradientSpread

Gradient spread mode.

gradientType

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

rtype:

QPointF

referencePoint1IsCentroid

rtype:

bool

referencePoint2

rtype:

QPointF

referencePoint2IsCentroid

rtype:

bool

renderPolygon

param points:

restoreOldDataDefinedProperties

Restores older data defined properties from string map.

setColor2

param color2:

setColorRamp

Sets the color ramp used for the gradient fill.

setCoordinateMode

param coordinateMode:

setGradientColorType

param gradientColorType:

setGradientSpread

param gradientSpread:

setGradientType

param gradientType:

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

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

setReferencePoint1IsCentroid

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

setReferencePoint2

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

setReferencePoint2IsCentroid

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

startRender

param context:

stopRender

param context:

usesMapUnits

rtype:

bool

Attributes

ColorRamp

Conical

Feature

Linear

Pad

Radial

Reflect

Repeat

SimpleTwoColor

Viewport

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
canCauseArtifactsBetweenAdjacentTiles(self) bool
Return type:

bool

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(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) 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

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
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(self, stringMap: Dict[str, Any])

Restores older data defined properties from string map.

New in version 3.0.

setColor2(self, color2: 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: 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)

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: 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) –

usesMapUnits(self) bool
Return type:

bool