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
alias of
GradientColorSource
alias of
SymbolCoordinateReference
Bases:
enum.IntEnum
Bases:
enum.IntEnum
Methods
- rtype:
bool
- rtype:
QgsGradientFillSymbolLayer
Returns the color for endpoint of gradient, only used if the gradient color type is set to SimpleTwoColor.
Returns the color ramp used for the gradient fill.
Returns the coordinate mode for gradient, which controls how the gradient stops are positioned.
Copies all data defined properties of this layer to another symbol layer.
Copies paint effect of this layer to another symbol layer
Creates a new
QgsGradientFillSymbolLayer
using the specifiedproperties
map containing symbol properties (seeproperties()
).- param context:
Returns the gradient color mode, which controls how gradient color stops are created.
Returns the gradient spread mode, which controls how the gradient behaves outside of the predefined stops.
Returns the type of gradient, e.g., linear or radial.
When rendering, install masks on
context
painter ifrecursive
isTrue
masks are installed recursively for all children symbol layers- rtype:
str
- rtype:
QgsMapUnitScale
Returns the offset by which polygons will be translated during rendering.
Returns the map unit scale for the fill's offset.
Returns the units for the fill's offset.
- rtype:
Qgis.RenderUnit
- rtype:
Dict[str, Any]
Returns the starting point of gradient fill, in the range [0,0] - [1,1].
Returns whether the starting point for the gradient is taken from the feature centroid.
Returns the end point of gradient fill, in the range [0,0] - [1,1].
Returns whether the end point for the gradient is taken from the feature centroid.
When rendering, remove previously installed masks from
context
painter ifrecursive
isTrue
masks are removed recursively for all children symbol layers- param points:
Restores older data defined properties from string map.
Sets the color for endpoint of gradient, only used if the gradient color type is set to SimpleTwoColor.
Sets the color ramp used for the gradient fill.
Sets the coordinate mode for gradient, which controls how the gradient stops are positioned.
Sets the gradient color mode, which controls how gradient color stops are created.
Sets the gradient spread mode, which controls how the gradient behaves outside of the predefined stops.
Sets the type of gradient, e.g., linear or radial.
- param scale:
Sets an
offset
by which polygons will be translated during rendering.Sets the map unit
scale
for the fill's offset.Sets the
unit
for the fill's offset.- param unit:
Sets the starting point of gradient fill, in the range [0,0] - [1,1].
Sets whether the starting point for the gradient is taken from the feature centroid.
Sets the end point of gradient fill, in the range [0,0] - [1,1].
Sets whether the end point for the gradient is taken from the feature centroid.
Returns
True
if the symbol layer should be rendered using the selection color from the render context.- param context:
- param context:
- 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
.GradientSpreadNew in version 3.24.
Pad
: Pad out gradient using colors at endpoint of gradientReflect
: Reflect gradientRepeat
: Repeat gradient
- class GradientType(value)¶
Bases:
enum.IntEnum
Gradient types.
Note
Prior to QGIS 3.24 this was available as
QgsGradientFillSymbolLayer
.GradientTypeNew in version 3.24.
Linear
: Linear gradientRadial
: Radial (circular) gradientConical
: Conical (polar) gradient
- canCauseArtifactsBetweenAdjacentTiles(self) bool ¶
- Return type:
bool
- clone(self) QgsGradientFillSymbolLayer ¶
- Return type:
- color2(self) QColor ¶
Returns the color for endpoint of gradient, only used if the gradient color type is set to SimpleTwoColor.
See also
- 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
See also
- Return type:
- coordinateMode(self) Qgis.SymbolCoordinateReference ¶
Returns the coordinate mode for gradient, which controls how the gradient stops are positioned.
See also
- Return type:
- 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
- create(properties: Dict[str, Any] = {}) QgsSymbolLayer ¶
Creates a new
QgsGradientFillSymbolLayer
using the specifiedproperties
map containing symbol properties (seeproperties()
).Caller takes ownership of the returned symbol layer.
- Parameters:
properties (Dict[str) –
- Return type:
- 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.
See also
- Return type:
- gradientSpread(self) Qgis.GradientSpread ¶
Returns the gradient spread mode, which controls how the gradient behaves outside of the predefined stops.
See also
- Return type:
- gradientType(self) Qgis.GradientType ¶
Returns the type of gradient, e.g., linear or radial.
See also
- Return type:
- installMasks(self, context: QgsRenderContext, recursive: bool)¶
When rendering, install masks on
context
painter ifrecursive
isTrue
masks are installed recursively for all children symbol layersSee also
prepareMasks()
See also
New in version 3.30.
- layerType(self) str ¶
- Return type:
str
- mapUnitScale(self) QgsMapUnitScale ¶
- Return type:
- offset(self) QPointF ¶
Returns the offset by which polygons will be translated during rendering.
Units are specified by
offsetUnit()
.See also
See also
- Return type:
QPointF
- offsetMapUnitScale(self) QgsMapUnitScale ¶
Returns the map unit scale for the fill’s offset.
See also
See also
- Return type:
- offsetUnit(self) Qgis.RenderUnit ¶
Returns the units for the fill’s offset.
See also
See also
- Return type:
- outputUnit(self) Qgis.RenderUnit ¶
- Return type:
- 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].
See also
- Return type:
QPointF
- referencePoint1IsCentroid(self) bool ¶
Returns whether the starting point for the gradient is taken from the feature centroid.
See also
- Return type:
bool
- referencePoint2(self) QPointF ¶
Returns the end point of gradient fill, in the range [0,0] - [1,1].
See also
- Return type:
QPointF
- referencePoint2IsCentroid(self) bool ¶
Returns whether the end point for the gradient is taken from the feature centroid.
See also
- Return type:
bool
- removeMasks(self, context: QgsRenderContext, recursive: bool)¶
When rendering, remove previously installed masks from
context
painter ifrecursive
isTrue
masks are removed recursively for all children symbol layersSee also
prepareMasks()
See also
New in version 3.30.
- renderPolygon(self, points: QPolygonF, rings: Iterable[QPolygonF], context: QgsSymbolRenderContext)¶
- Parameters:
points (QPolygonF) –
rings (Iterable[QPolygonF]) –
context (QgsSymbolRenderContext) –
- restoreOldDataDefinedProperties(self, stringMap: Dict[str, Any])¶
Restores older data defined properties from string map.
- 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
- 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
See also
- setCoordinateMode(self, coordinateMode: Qgis.SymbolCoordinateReference)¶
Sets the coordinate mode for gradient, which controls how the gradient stops are positioned.
See also
- Parameters:
coordinateMode (Qgis.SymbolCoordinateReference) –
- setGradientColorType(self, gradientColorType: Qgis.GradientColorSource)¶
Sets the gradient color mode, which controls how gradient color stops are created.
See also
- 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
- Parameters:
gradientSpread (Qgis.GradientSpread) –
- setGradientType(self, gradientType: Qgis.GradientType)¶
Sets the type of gradient, e.g., linear or radial.
See also
- 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
See also
- Parameters:
offset (Union[QPointF) –
- setOffsetMapUnitScale(self, scale: QgsMapUnitScale)¶
Sets the map unit
scale
for the fill’s offset.See also
See also
- Parameters:
scale (QgsMapUnitScale) –
- setOffsetUnit(self, unit: Qgis.RenderUnit)¶
Sets the
unit
for the fill’s offset.See also
See also
- Parameters:
unit (Qgis.RenderUnit) –
- setOutputUnit(self, unit: Qgis.RenderUnit)¶
- Parameters:
unit (Qgis.RenderUnit) –
- setReferencePoint1(self, referencePoint: QPointF | QPoint)¶
Sets the starting point of gradient fill, in the range [0,0] - [1,1].
See also
- Parameters:
referencePoint (Union[QPointF) –
- setReferencePoint1IsCentroid(self, isCentroid: bool)¶
Sets whether the starting point for the gradient is taken from the feature centroid.
See also
- Parameters:
isCentroid (bool) –
- setReferencePoint2(self, referencePoint: QPointF | QPoint)¶
Sets the end point of gradient fill, in the range [0,0] - [1,1].
See also
- Parameters:
referencePoint (Union[QPointF) –
- setReferencePoint2IsCentroid(self, isCentroid: bool)¶
Sets whether the end point for the gradient is taken from the feature centroid.
See also
- Parameters:
isCentroid (bool) –
- shouldRenderUsingSelectionColor(self, context: QgsSymbolRenderContext) bool ¶
Returns
True
if the symbol layer should be rendered using the selection color from the render context.New in version 3.34.
- startRender(self, context: QgsSymbolRenderContext)¶
- Parameters:
context (QgsSymbolRenderContext) –
- stopRender(self, context: QgsSymbolRenderContext)¶
- Parameters:
context (QgsSymbolRenderContext) –
- usesMapUnits(self) bool ¶
- Return type:
bool