Class: QgsSVGFillSymbolLayer

A fill symbol layer which fills polygons with a repeated SVG file.

Class Hierarchy

Inheritance diagram of qgis.core.QgsSVGFillSymbolLayer

Base classes

QgsImageFillSymbolLayer

Base class for fill symbol layers which fill polygons with a repeated image.

QgsFillSymbolLayer

Abstract base class for fill symbol layers.

QgsSymbolLayer

Abstract base class for symbol layers.

Methods

parameters

Returns the dynamic SVG parameters

patternWidth

Returns the width of the rendered SVG content within the fill (i.e. the pattern repeat/tile size).

patternWidthMapUnitScale

Returns the map unit scale for the pattern's width.

patternWidthUnit

Returns the units for the width of the SVG images in the pattern.

setParameters

Sets the dynamic SVG parameters

setPatternWidth

Sets the width to render the SVG content as within the fill (i.e. the pattern repeat/tile size).

setPatternWidthMapUnitScale

Sets the map unit scale for the pattern's width.

setPatternWidthUnit

Sets the unit for the width of the SVG images in the pattern.

setSvgFilePath

Sets the path to the SVG file to render in the fill.

setSvgFillColor

Sets the fill color used for rendering the SVG content.

setSvgStrokeColor

Sets the stroke color used for rendering the SVG content.

setSvgStrokeWidth

Sets the stroke width used for rendering the SVG content.

setSvgStrokeWidthMapUnitScale

Sets the map unit scale for the pattern's stroke.

setSvgStrokeWidthUnit

Sets the unit for the stroke width.

svgFilePath

Returns the path to the SVG file used to render the fill.

svgFillColor

Returns the fill color used for rendering the SVG content.

svgStrokeColor

Returns the stroke color used for rendering the SVG content.

svgStrokeWidth

Returns the stroke width used for rendering the SVG content.

svgStrokeWidthMapUnitScale

Returns the map unit scale for the pattern's stroke.

svgStrokeWidthUnit

Returns the units for the stroke width.

Virtual Methods

In PyQGIS, only methods marked as virtual can be safely overridden in a Python subclass of QgsSVGFillSymbolLayer. See the FAQ for more details.

applyBrushTransformFromContext

applyDataDefinedSettings

Static Methods

create

Creates a new QgsSVGFillSymbolLayer from a properties map.

createFromSld

Creates a new QgsSVGFillSymbolLayer from a SLD element.

resolvePaths

Turns relative paths in properties map to absolute when reading and vice versa when writing.

class qgis.core.QgsSVGFillSymbolLayer[source]

Bases: QgsImageFillSymbolLayer

__init__(svgFilePath: str | None, width: float = 20, rotation: float = 0)

Constructor for QgsSVGFillSymbolLayer, using the SVG picture at the specified absolute file path.

Parameters:
  • svgFilePath (Optional[str])

  • width (float = 20)

  • rotation (float = 0)

__init__(svgData: QByteArray | bytes | bytearray, width: float = 20, rotation: float = 0)

Constructor for QgsSVGFillSymbolLayer, using the specified SVG picture data.

Parameters:
  • svgData (Union[QByteArray, bytes, bytearray])

  • width (float = 20)

  • rotation (float = 0)

virtual applyBrushTransformFromContext()
virtual applyDataDefinedSettings(self, context: QgsSymbolRenderContext)[source]
Parameters:

context (QgsSymbolRenderContext)

static create(properties: Dict[str, Any] = {}) QgsSymbolLayer | None[source]

Creates a new QgsSVGFillSymbolLayer from a properties map. The caller takes ownership of the returned object.

Parameters:

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

Return type:

Optional[QgsSymbolLayer]

static createFromSld(element: QDomElement) QgsSymbolLayer | None[source]

Creates a new QgsSVGFillSymbolLayer from a SLD element. The caller takes ownership of the returned object.

Parameters:

element (QDomElement)

Return type:

Optional[QgsSymbolLayer]

parameters(self) Dict[str, QgsProperty]

Returns the dynamic SVG parameters

Added in version 3.18.

Return type:

Dict[str, QgsProperty]

patternWidth(self) float[source]

Returns the width of the rendered SVG content within the fill (i.e. the pattern repeat/tile size).

Units are retrieved by patternWidthUnit()

Return type:

float

patternWidthMapUnitScale(self) QgsMapUnitScale

Returns the map unit scale for the pattern’s width.

See also

patternWidth()

Return type:

QgsMapUnitScale

patternWidthUnit(self) Qgis.RenderUnit[source]

Returns the units for the width of the SVG images in the pattern.

See also

patternWidth()

Return type:

Qgis.RenderUnit

static resolvePaths(properties: Dict[str, Any], pathResolver: QgsPathResolver, saving: bool)[source]

Turns relative paths in properties map to absolute when reading and vice versa when writing. Used internally when reading/writing symbols.

Parameters:
setParameters(self, parameters: Dict[str | None, QgsProperty])[source]

Sets the dynamic SVG parameters

Added in version 3.18.

Parameters:

parameters (Dict[Optional[str], QgsProperty])

setPatternWidth(self, width: float)[source]

Sets the width to render the SVG content as within the fill (i.e. the pattern repeat/tile size).

Units are specified by setPatternWidthUnit()

See also

patternWidth()

Parameters:

width (float)

setPatternWidthMapUnitScale(self, scale: QgsMapUnitScale)[source]

Sets the map unit scale for the pattern’s width.

Parameters:

scale (QgsMapUnitScale)

setPatternWidthUnit(self, unit: Qgis.RenderUnit)[source]

Sets the unit for the width of the SVG images in the pattern.

Parameters:

unit (Qgis.RenderUnit)

setSvgFilePath(self, svgPath: str | None)[source]

Sets the path to the SVG file to render in the fill.

This is usually an absolute file path. Other supported options include

  • relative paths to folders from the user’s SVG search paths

  • base64 encoded content, prefixed with a ‘base64:’ string

  • http(s) paths

See also

svgFilePath()

Parameters:

svgPath (Optional[str])

setSvgFillColor(self, c: QColor | Qt.GlobalColor)[source]

Sets the fill color used for rendering the SVG content.

Fill color is only supported for parametrized SVG files. Color opacity is ignored if the SVG file does not support parametrized fill opacity.

See also

svgFillColor()

Parameters:

c (Union[QColor, Qt.GlobalColor])

setSvgStrokeColor(self, c: QColor | Qt.GlobalColor)[source]

Sets the stroke color used for rendering the SVG content.

Stroke color is only supported for parametrized SVG files. Color opacity is ignored if the SVG file does not support parametrized outline opacity.

See also

svgStrokeColor()

Parameters:

c (Union[QColor, Qt.GlobalColor])

setSvgStrokeWidth(self, w: float)[source]

Sets the stroke width used for rendering the SVG content.

Stroke width is only supported for parametrized SVG files. Units are specified via setSvgStrokeWidthUnit()

See also

svgStrokeWidth()

Parameters:

w (float)

setSvgStrokeWidthMapUnitScale(self, scale: QgsMapUnitScale)[source]

Sets the map unit scale for the pattern’s stroke.

Parameters:

scale (QgsMapUnitScale)

setSvgStrokeWidthUnit(self, unit: Qgis.RenderUnit)[source]

Sets the unit for the stroke width.

Parameters:

unit (Qgis.RenderUnit)

svgFilePath(self) str[source]

Returns the path to the SVG file used to render the fill.

See also

setSvgFilePath()

Return type:

str

svgFillColor(self) QColor[source]

Returns the fill color used for rendering the SVG content.

Fill color is only supported for parametrized SVG files.

See also

svgStrokeColor()

Return type:

QColor

svgStrokeColor(self) QColor[source]

Returns the stroke color used for rendering the SVG content.

Stroke color is only supported for parametrized SVG files.

See also

svgFillColor()

Return type:

QColor

svgStrokeWidth(self) float[source]

Returns the stroke width used for rendering the SVG content.

Stroke width is only supported for parametrized SVG files. Units are retrieved via setSvgStrokeWidthUnit()

Return type:

float

svgStrokeWidthMapUnitScale(self) QgsMapUnitScale

Returns the map unit scale for the pattern’s stroke.

See also

svgStrokeWidth()

Return type:

QgsMapUnitScale

svgStrokeWidthUnit(self) Qgis.RenderUnit[source]

Returns the units for the stroke width.

See also

svgStrokeWidth()

Return type:

Qgis.RenderUnit