Class: QgsPainting

class qgis.core.QgsPainting

Bases: sip.wrapper

Contains miscellaneous painting utility functions.

Enums

BlendMode

Bases: enum.IntEnum

Methods

drawTriangleUsingTexture

Draws a triangle onto a painter using a mapped texture image.

getBlendModeEnum

Returns a Qgis.BlendMode corresponding to a QPainter.CompositionMode.

getCompositionMode

Returns a QPainter.CompositionMode corresponding to a Qgis.BlendMode.

isClippingMode

Returns True if mode is a clipping blend mode.

triangleToTriangleTransform

Calculates the QTransform which maps the triangle defined by the points (inX1, inY1), (inY2, inY2), (inX3, inY3) to the triangle defined by (outX1, outY1), (outY2, outY2), (outX3, outY3).

class BlendMode(value)

Bases: enum.IntEnum

Blending modes defining the available composition modes that can be used when painting.

Note

Prior to QGIS 3.30 this was available as QgsPainting.BlendMode.

New in version 3.30.

  • BlendNormal: Normal

  • BlendLighten: Lighten

  • BlendScreen: Screen

  • BlendDodge: Dodge

  • BlendAddition: Addition

  • BlendDarken: Darken

  • BlendMultiply: Multiple

  • BlendBurn: Burn

  • BlendOverlay: Overlay

  • BlendSoftLight: Soft light

  • BlendHardLight: Hard light

  • BlendDifference: Difference

  • BlendSubtract: Subtract

  • BlendSource: Source

  • BlendDestinationOver: Destination over

  • BlendClear: Clear

  • BlendDestination: Destination

  • BlendSourceIn: Source in

  • BlendDestinationIn: Destination in

  • BlendSourceOut: Source out

  • BlendDestinationOut: Destination out

  • BlendSourceAtop: Source atop

  • BlendDestinationAtop: Destination atop

  • BlendXor: XOR

baseClass

alias of Qgis

drawTriangleUsingTexture(painter: QPainter, triangle: QPolygonF, textureImage: QImage, textureX1: float, textureY1: float, textureX2: float, textureY2: float, textureX3: float, textureY3: float) bool

Draws a triangle onto a painter using a mapped texture image.

The triangle will be rendered using the portion of the texture image described by the triangle (textureX1, textureY1), (textureX2, textureY2), (textureX3, textureY3). Texture coordinates should be in the range 0-1 (as a fraction of the image size), where (0, 0) coorresponds to the top-left of the texture image.

The caller must ensure that triangle is a closed QPolygonF consisting of 4 vertices (the 3 triangle vertices + the first vertex again to close the polygon).

Returns True if the triangle could be rendered, or False if it could not (e.g. when the described points are co-linear).

New in version 3.34.

Parameters:
  • painter (QPainter) –

  • triangle (QPolygonF) –

  • textureImage (QImage) –

  • textureX1 (float) –

  • textureY1 (float) –

  • textureX2 (float) –

  • textureY2 (float) –

  • textureX3 (float) –

  • textureY3 (float) –

Return type:

bool

getBlendModeEnum(blendMode: QPainter.CompositionMode) Qgis.BlendMode

Returns a Qgis.BlendMode corresponding to a QPainter.CompositionMode.

Parameters:

blendMode (QPainter.CompositionMode) –

Return type:

Qgis.BlendMode

getCompositionMode(blendMode: Qgis.BlendMode) QPainter.CompositionMode

Returns a QPainter.CompositionMode corresponding to a Qgis.BlendMode.

Parameters:

blendMode (Qgis.BlendMode) –

Return type:

QPainter.CompositionMode

isClippingMode(mode: Qgis.BlendMode) bool

Returns True if mode is a clipping blend mode.

New in version 3.30.

Parameters:

mode (Qgis.BlendMode) –

Return type:

bool

triangleToTriangleTransform(inX1: float, inY1: float, inX2: float, inY2: float, inX3: float, inY3: float, outX1: float, outY1: float, outX2: float, outY2: float, outX3: float, outY3: float) Tuple[QTransform, bool]

Calculates the QTransform which maps the triangle defined by the points (inX1, inY1), (inY2, inY2), (inX3, inY3) to the triangle defined by (outX1, outY1), (outY2, outY2), (outX3, outY3).

Parameters:
  • inX1 (float) – source triangle vertex 1 x-coordinate

  • inY1 (float) – source triangle vertex 1 y-coordinate

  • inX2 (float) – source triangle vertex 2 x-coordinate

  • inY2 (float) – source triangle vertex 2 y-coordinate

  • inX3 (float) – source triangle vertex 3 x-coordinate

  • inY3 (float) – source triangle vertex 3 y-coordinate

  • outX1 (float) – destination triangle vertex 1 x-coordinate

  • outY1 (float) – destination triangle vertex 1 y-coordinate

  • outX2 (float) – destination triangle vertex 2 x-coordinate

  • outY2 (float) – destination triangle vertex 2 y-coordinate

  • outX3 (float) – destination triangle vertex 3 x-coordinate

  • outY3 (float) – destination triangle vertex 3 y-coordinate

Return type:

Tuple[QTransform, bool]

Returns:

  • Calculated transform (if possible)

  • ok: will be set to True if the transform could be determined.

New in version 3.34.