Class: QgsGlowEffect

class qgis.core.QgsGlowEffect

Bases: QgsPaintEffect

Base class for paint effect which draw a glow inside or outside a picture.

New in version 2.9:

Methods

blendMode

Returns the blend mode for the effect

blurLevel

Returns the blur level (radius) for the glow.

blurMapUnitScale

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

blurUnit

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

boundingRect

param rect

color

Returns the color for the glow.

colorType

Returns the color mode used for the glow.

draw

param context

drawSource

Draws the source QPicture onto the specified painter.

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.

opacity

Returns the opacity for the effect.

properties

rtype

Dict[str, Any]

ramp

Returns the color ramp used for the glow.

readProperties

param props

setBlendMode

Sets the blend mode for the effect

setBlurLevel

Sets blur level (radius) for the glow.

setBlurMapUnitScale

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

setBlurUnit

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

setColor

Sets the color for the glow.

setColorType

Sets the color mode to use for the glow.

setOpacity

Sets the opacity for the effect.

setRamp

Sets the color ramp for the glow.

setSpread

Sets the spread distance for drawing the glow effect.

setSpreadMapUnitScale

Sets the map unit scale used for the spread distance.

setSpreadUnit

Sets the units used for the glow spread distance.

shadeExterior

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

source

Returns the source QPicture.

sourceAsImage

Returns the source QPicture rendered to a new QImage.

spread

Returns the spread distance used for drawing the glow effect.

spreadMapUnitScale

Returns the map unit scale used for the spread distance.

spreadUnit

Returns the units used for the glow spread distance.

Attributes

ColorRamp

SingleColor

ColorRamp = 1
class GlowColorType

Bases: int

SingleColor = 0
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 glow.

Return type

float

Returns

blur level.

See also

setBlurLevel()

See also

blurUnit()

blurMapUnitScale(self) QgsMapUnitScale

Returns the map unit scale used for the glow 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 glow 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 for the glow. This only applies if the colorType() is set to SingleColor. The glow will fade between the specified color and a totally transparent version of the color.

Return type

QColor

Returns

glow color

See also

setColor()

See also

colorType()

colorType(self) QgsGlowEffect.GlowColorType

Returns the color mode used for the glow. The glow can either be drawn using a QgsColorRamp color ramp or by specificing a single color.

Return type

QgsGlowEffect.GlowColorType

Returns

current color mode used for the glow

See also

setColorType()

See also

color()

See also

ramp()

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

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

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, Any]
Return type

Dict[str, Any]

ramp(self) QgsColorRamp

Returns the color ramp used for the glow. This only applies if the colorType() is set to ColorRamp. The glow will utilize colors from the ramp.

Return type

QgsColorRamp

Returns

color ramp for glow

See also

setRamp()

See also

colorType()

readProperties(self, props: Dict[str, Any])
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 glow. This can be used to smooth the output from the glow effect.

Parameters

level (float) – blur level.

See also

blurLevel()

See also

setBlurUnit()

setBlurMapUnitScale(self, scale: QgsMapUnitScale)

Sets the map unit scale used for the glow 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 glow 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 glow. This only applies if the colorType() is set to SingleColor. The glow will fade between the specified color and a totally transparent version of the color.

Parameters

color (Union[QColor) – glow color

See also

color()

See also

setColorType()

setColorType(self, colorType: QgsGlowEffect.GlowColorType)

Sets the color mode to use for the glow. The glow can either be drawn using a QgsColorRamp color ramp or by simply specificing a single color. setColorType is used to specify which mode to use for the glow.

Parameters

colorType (QgsGlowEffect.GlowColorType) – color type to use for glow

See also

colorType()

See also

setColor()

See also

setRamp()

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

setRamp(self, ramp: QgsColorRamp)

Sets the color ramp for the glow. This only applies if the colorType() is set to ColorRamp. The glow will utilize colors from the ramp.

Parameters

ramp (QgsColorRamp) – color ramp for glow. Ownership of the ramp is transferred to the effect.

See also

ramp()

See also

setColorType()

setSpread(self, spread: float)

Sets the spread distance for drawing the glow effect.

Parameters

spread (float) – spread distance. Units are specified via setSpreadUnit()

See also

spread()

See also

setSpreadUnit()

setSpreadMapUnitScale(self, scale: QgsMapUnitScale)

Sets the map unit scale used for the spread distance.

Parameters

scale (QgsMapUnitScale) – map unit scale for spread distance

See also

setSpread()

See also

setSpreadUnit()

setSpreadUnit(self, unit: QgsUnitTypes.RenderUnit)

Sets the units used for the glow spread distance.

Parameters

unit (QgsUnitTypes.RenderUnit) – units for spread distance

See also

spreadUnit()

See also

setSpread()

shadeExterior(self) bool

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

Return type

bool

Returns

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

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

spread(self) float

Returns the spread distance used for drawing the glow effect.

Return type

float

Returns

spread distance. Units are retrieved via spreadUnit()

See also

setSpread()

See also

spreadUnit()

spreadMapUnitScale(self) QgsMapUnitScale

Returns the map unit scale used for the spread distance.

Return type

QgsMapUnitScale

Returns

map unit scale for spread distance

See also

spread()

See also

spreadUnit()

spreadUnit(self) QgsUnitTypes.RenderUnit

Returns the units used for the glow spread distance.

Return type

QgsUnitTypes.RenderUnit

Returns

units for spread distance

See also

setSpreadUnit()

See also

spread()