Class: QgsShadowEffect

class qgis.core.QgsShadowEffect

Bases: QgsPaintEffect

Base class for paint effects which offset, blurred shadows

Methods

blendMode

Returns the blend mode for the effect

blurLevel

Returns the blur level (radius) for the shadow.

blurMapUnitScale

Returns the map unit scale used for the shadow blur strength (radius).

blurUnit

Returns the units used for the shadow blur level (radius).

boundingRect

param rect

color

Returns the color used for the shadow.

draw

param context

drawSource

Draws the source QPicture onto the specified painter.

exteriorShadow

Specifies whether the shadow is drawn outside the picture or within the picture.

fixQPictureDpi

Applies a workaround to a QPainter to avoid an issue with incorrect scaling when drawing QPictures.

imageOffset

Returns the offset which should be used when drawing the source image on to a destination render context.

offsetAngle

Returns the angle used for offsetting the shadow.

offsetDistance

Returns the distance used for offsetting the shadow.

offsetMapUnitScale

Returns the map unit scale used for the shadow offset distance.

offsetUnit

Returns the units used for the shadow offset distance.

opacity

Returns the opacity for the effect.

properties

rtype

Dict[str, str]

readProperties

param props

setBlendMode

Sets the blend mode for the effect

setBlurLevel

Sets blur level (radius) for the shadow.

setBlurMapUnitScale

Sets the map unit scale used for the shadow blur strength (radius).

setBlurUnit

Sets the units used for the shadow blur level (radius).

setColor

Sets the color for the shadow.

setOffsetAngle

Sets the angle for offsetting the shadow.

setOffsetDistance

Sets the distance for offsetting the shadow.

setOffsetMapUnitScale

Sets the map unit scale used for the shadow offset distance.

setOffsetUnit

Sets the units used for the shadow offset distance.

setOpacity

Sets the opacity for the effect.

source

Returns the source QPicture.

sourceAsImage

Returns the source QPicture rendered to a new QImage.

blendMode(self) → QPainter.CompositionMode

Returns the blend mode for the effect

Return type

QPainter.CompositionMode

Returns

blend mode used for drawing the effect on to a destination paint device

See also

setBlendMode()

blurLevel(self) → float

Returns the blur level (radius) for the shadow.

Return type

float

Returns

blur level. values indicating greater blur strength.

See also

setBlurLevel()

See also

blurUnit()

blurMapUnitScale(self)QgsMapUnitScale

Returns the map unit scale used for the shadow blur strength (radius).

Return type

QgsMapUnitScale

Returns

map unit scale for blur strength

See also

blurLevel()

See also

blurUnit()

New in version 3.4.9.

blurUnit(self)QgsUnitTypes.RenderUnit

Returns the units used for the shadow blur level (radius).

Return type

QgsUnitTypes.RenderUnit

Returns

units for blur level

See also

setBlurUnit()

See also

blurLevel()

New in version 3.4.9.

boundingRect(self, rect: QRectF, context: QgsRenderContext) → QRectF
Parameters
Return type

QRectF

color(self) → QColor

Returns the color used for the shadow.

Return type

QColor

Returns

shadow color

See also

setColor()

draw(self, context: QgsRenderContext)
Parameters

context (QgsRenderContext) –

drawSource(self, painter: QPainter)

Draws the source QPicture onto the specified painter. Handles scaling of the picture to account for the destination painter’s DPI.

Parameters

painter – destination painter

See also

source()

See also

sourceAsImage()

exteriorShadow(self) → bool

Specifies whether the shadow is drawn outside the picture or within the picture.

Return type

bool

Returns

True if shadow is to be drawn outside the picture, or False to draw shadow within the picture

fixQPictureDpi(self, painter: QPainter)

Applies a workaround to a QPainter to avoid an issue with incorrect scaling when drawing QPictures. This may need to be called by derived classes prior to rendering results onto a painter.

Parameters

painter – destination painter

imageOffset(self, context: QgsRenderContext) → QPointF

Returns the offset which should be used when drawing the source image on to a destination render context.

Parameters

context – destination render context

Returns

point offset for image top left corner

See also

sourceAsImage()

offsetAngle(self) → int

Returns the angle used for offsetting the shadow.

Return type

int

Returns

offset angle in degrees clockwise from North

See also

setOffsetAngle()

See also

offsetDistance()

offsetDistance(self) → float

Returns the distance used for offsetting the shadow.

Return type

float

Returns

offset distance. Distance units are retrieved via offsetUnit()

See also

offsetUnit()

offsetMapUnitScale(self)QgsMapUnitScale

Returns the map unit scale used for the shadow offset distance.

Return type

QgsMapUnitScale

Returns

map unit scale for offset distance

See also

offsetDistance()

See also

offsetUnit()

offsetUnit(self)QgsUnitTypes.RenderUnit

Returns the units used for the shadow offset distance.

Return type

QgsUnitTypes.RenderUnit

Returns

units for offset distance

See also

setOffsetUnit()

See also

offsetDistance()

opacity(self) → float

Returns the opacity for the effect.

Return type

float

Returns

opacity value between 0 and 1 inclusive, where 0 is fully transparent and 1 is fully opaque

See also

setOpacity()

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

Dict[str, str]

readProperties(self, props: Dict[str, str])
Parameters

props (Dict[str) –

setBlendMode(self, mode: QPainter.CompositionMode)

Sets the blend mode for the effect

Parameters

mode (QPainter.CompositionMode) – blend mode used for drawing the effect on to a destination paint device

See also

blendMode()

setBlurLevel(self, level: float)

Sets blur level (radius) for the shadow.

Parameters

level (float) – blur level. values indicating greater blur strength.

See also

blurLevel()

See also

setBlurUnit()

setBlurMapUnitScale(self, scale: QgsMapUnitScale)

Sets the map unit scale used for the shadow blur strength (radius).

Parameters

scale (QgsMapUnitScale) – map unit scale for blur strength

See also

setBlurLevel()

See also

setBlurUnit()

New in version 3.4.9.

setBlurUnit(self, unit: QgsUnitTypes.RenderUnit)

Sets the units used for the shadow blur level (radius).

Parameters

unit (QgsUnitTypes.RenderUnit) – units for blur level

See also

blurUnit()

See also

setBlurLevel()

New in version 3.4.9.

setColor(self, color: Union[QColor, Qt.GlobalColor, QGradient])

Sets the color for the shadow.

Parameters

color (Union[QColor) – shadow color

See also

color()

setOffsetAngle(self, angle: int)

Sets the angle for offsetting the shadow.

Parameters

angle (int) – offset angle in degrees clockwise from North

See also

offsetAngle()

setOffsetDistance(self, distance: float)

Sets the distance for offsetting the shadow.

Parameters

distance (float) – offset distance. Units are specified via setOffsetUnit()

See also

offsetDistance()

See also

setOffsetUnit()

setOffsetMapUnitScale(self, scale: QgsMapUnitScale)

Sets the map unit scale used for the shadow offset distance.

Parameters

scale (QgsMapUnitScale) – map unit scale for offset distance

See also

setOffsetUnit()

setOffsetUnit(self, unit: QgsUnitTypes.RenderUnit)

Sets the units used for the shadow offset distance.

Parameters

unit (QgsUnitTypes.RenderUnit) – units for offset distance

See also

offsetUnit()

setOpacity(self, opacity: float)

Sets the opacity for the effect.

Parameters

opacity (float) – double between 0 and 1 inclusive, where 0 is fully transparent and 1 is fully opaque

See also

opacity()

source(self) → QPicture

Returns the source QPicture. The draw() member can utilize this when drawing the effect.

Returns

source QPicture

See also

drawSource()

See also

sourceAsImage()

sourceAsImage(self, context: QgsRenderContext) → QImage

Returns the source QPicture rendered to a new QImage. The draw() member can utilize this when drawing the effect. The image will be padded or cropped from the original source QPicture by the results of the boundingRect() method. The result is cached to speed up subsequent calls to sourceAsImage.

Returns

source QPicture rendered to an image

See also

drawSource()

See also

source()

See also

imageOffset()

See also

boundingRect()