Class: QgsPainting¶
Contains miscellaneous painting utility functions.
Enums
Blending modes defining the available composition modes that can be used when painting. |
Static Methods
Applies a workaround to a painter to avoid an issue with incorrect scaling when drawing QPictures. |
|
Draws a picture onto a painter, correctly applying workarounds to avoid issues with incorrect scaling. |
|
Draws a triangle onto a painter using a mapped texture image. |
|
Returns a |
|
Returns a QPainter.CompositionMode corresponding to a |
|
Returns |
|
Returns the default Qt horizontal DPI. |
|
Returns the default Qt vertical DPI. |
|
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 qgis.core.QgsPainting[source]¶
Bases:
object
- class BlendMode(*values)¶
Bases:
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.Added in version 3.30.
Normal
: NormalAvailable as
QgsPainting.BlendNormal
in older QGIS releases.Lighten
: LightenAvailable as
QgsPainting.BlendLighten
in older QGIS releases.Screen
: ScreenAvailable as
QgsPainting.BlendScreen
in older QGIS releases.Dodge
: DodgeAvailable as
QgsPainting.BlendDodge
in older QGIS releases.Addition
: AdditionAvailable as
QgsPainting.BlendAddition
in older QGIS releases.Darken
: DarkenAvailable as
QgsPainting.BlendDarken
in older QGIS releases.Multiply
: MultipleAvailable as
QgsPainting.BlendMultiply
in older QGIS releases.Burn
: BurnAvailable as
QgsPainting.BlendBurn
in older QGIS releases.Overlay
: OverlayAvailable as
QgsPainting.BlendOverlay
in older QGIS releases.SoftLight
: Soft lightAvailable as
QgsPainting.BlendSoftLight
in older QGIS releases.HardLight
: Hard lightAvailable as
QgsPainting.BlendHardLight
in older QGIS releases.Difference
: DifferenceAvailable as
QgsPainting.BlendDifference
in older QGIS releases.Subtract
: SubtractAvailable as
QgsPainting.BlendSubtract
in older QGIS releases.Source
: SourceAvailable as
QgsPainting.BlendSource
in older QGIS releases.DestinationOver
: Destination overAvailable as
QgsPainting.BlendDestinationOver
in older QGIS releases.Clear
: ClearAvailable as
QgsPainting.BlendClear
in older QGIS releases.Destination
: DestinationAvailable as
QgsPainting.BlendDestination
in older QGIS releases.SourceIn
: Source inAvailable as
QgsPainting.BlendSourceIn
in older QGIS releases.DestinationIn
: Destination inAvailable as
QgsPainting.BlendDestinationIn
in older QGIS releases.SourceOut
: Source outAvailable as
QgsPainting.BlendSourceOut
in older QGIS releases.DestinationOut
: Destination outAvailable as
QgsPainting.BlendDestinationOut
in older QGIS releases.SourceAtop
: Source atopAvailable as
QgsPainting.BlendSourceAtop
in older QGIS releases.DestinationAtop
: Destination atopAvailable as
QgsPainting.BlendDestinationAtop
in older QGIS releases.Xor
: XORAvailable as
QgsPainting.BlendXor
in older QGIS releases.
- static applyScaleFixForQPictureDpi(painter: QPainter | None)[source]¶
Applies a workaround to a
painter
to avoid an issue with incorrect scaling when drawing QPictures.Note
This is a low-level method, which alters the
painter
state and relies on the caller saving/restoring painter state accordingly. Consider using the high-leveldrawPicture()
method instead.See also
Added in version 3.40.
- Parameters:
painter (Optional[QPainter])
- static drawPicture(painter: QPainter | None, point: QPointF | QPoint, picture: QPicture)[source]¶
Draws a picture onto a
painter
, correctly applying workarounds to avoid issues with incorrect scaling.See also
Added in version 3.40.
- Parameters:
painter (Optional[QPainter])
point (Union[QPointF, QPoint])
picture (QPicture)
- static drawTriangleUsingTexture(painter: QPainter | None, triangle: QPolygonF, textureImage: QImage, textureX1: float, textureY1: float, textureX2: float, textureY2: float, textureX3: float, textureY3: float) bool [source]¶
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).Added in version 3.34.
- Parameters:
painter (Optional[QPainter])
triangle (QPolygonF)
textureImage (QImage)
textureX1 (float)
textureY1 (float)
textureX2 (float)
textureY2 (float)
textureX3 (float)
textureY3 (float)
- Return type:
bool
- static getBlendModeEnum(blendMode: QPainter.CompositionMode) Qgis.BlendMode [source]¶
Returns a
Qgis
.BlendMode corresponding to a QPainter.CompositionMode.See also
- Parameters:
blendMode (QPainter.CompositionMode)
- Return type:
- static getCompositionMode(blendMode: Qgis.BlendMode) QPainter.CompositionMode [source]¶
Returns a QPainter.CompositionMode corresponding to a
Qgis
.BlendMode.See also
- Parameters:
blendMode (Qgis.BlendMode)
- Return type:
QPainter.CompositionMode
- static isClippingMode(mode: Qgis.BlendMode) bool [source]¶
Returns
True
ifmode
is a clipping blend mode.Added in version 3.30.
- Parameters:
mode (Qgis.BlendMode)
- Return type:
bool
- static qtDefaultDpiX() int [source]¶
Returns the default Qt horizontal DPI.
Note
This method proxies the internal Qt
qt_defaultDpiX()
function.See also
Added in version 3.40.
- Return type:
int
- static qtDefaultDpiY() int [source]¶
Returns the default Qt vertical DPI.
Note
This method proxies the internal Qt
qt_defaultDpiY()
function.See also
Added in version 3.40.
- Return type:
int
- static 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)[source]¶
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) -> (QTransform) – destination triangle vertex 3 y-coordinate
- Returns:
Calculated transform (if possible)
ok:
True
if the transform could be determined.
Added in version 3.34.