Class: QgsPainting¶
- class qgis.core.QgsPainting¶
Bases:
sip.wrapper
Contains miscellaneous painting utility functions.
Enums
Bases:
enum.IntEnum
Methods
Draws a
triangle
onto apainter
using a mapped texture image.Returns a
Qgis
.BlendMode corresponding to a QPainter.CompositionMode.Returns a QPainter.CompositionMode corresponding to a
Qgis
.BlendMode.Returns
True
ifmode
is a clipping blend mode.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
: NormalBlendLighten
: LightenBlendScreen
: ScreenBlendDodge
: DodgeBlendAddition
: AdditionBlendDarken
: DarkenBlendMultiply
: MultipleBlendBurn
: BurnBlendOverlay
: OverlayBlendSoftLight
: Soft lightBlendHardLight
: Hard lightBlendDifference
: DifferenceBlendSubtract
: SubtractBlendSource
: SourceBlendDestinationOver
: Destination overBlendClear
: ClearBlendDestination
: DestinationBlendSourceIn
: Source inBlendDestinationIn
: Destination inBlendSourceOut
: Source outBlendDestinationOut
: Destination outBlendSourceAtop
: Source atopBlendDestinationAtop
: Destination atopBlendXor
: XOR
- drawTriangleUsingTexture(painter: QPainter, triangle: QPolygonF, textureImage: QImage, textureX1: float, textureY1: float, textureX2: float, textureY2: float, textureX3: float, textureY3: float) bool ¶
Draws a
triangle
onto apainter
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, orFalse
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.See also
- Parameters:
blendMode (QPainter.CompositionMode) –
- Return type:
- getCompositionMode(blendMode: Qgis.BlendMode) QPainter.CompositionMode ¶
Returns a QPainter.CompositionMode corresponding to a
Qgis
.BlendMode.See also
- Parameters:
blendMode (Qgis.BlendMode) –
- Return type:
QPainter.CompositionMode
- isClippingMode(mode: Qgis.BlendMode) bool ¶
Returns
True
ifmode
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.