PySide6.QtCanvasPainter.QCanvasGradient¶
- class QCanvasGradient¶
QCanvasGradientis the base class for allQCanvasPaintergradient brushes.Details
QCanvasGradientis the base class for allQCanvasPaintergradient brushes. Currently there are four type of gradients:QCanvasLinearGradient,QCanvasRadialGradient,QCanvasConicalGradientandQCanvasBoxGradient.If no stops are provided with
setStartColor,setEndColor,setColorAtorsetStops, the gragient is rendered as start color white (255,255,255) and end color transparent (0,0,0,0). If only a single stop is provided, the gradient is filled with this color.QCanvasPainteruses two different approaches for painting gradients.With maximum of 2 stops, the colors are passed into shader as 2 vec4 uniforms. This makes animating 2 stop gradients very performant, with no extra steps in between.
With more than 2 stops, the colors are passed into shader as a one dimensional texture. By default the texture size is 1x256 pixels, optimized for quality and performance. The textures are cached, so when gradient stops or colors don’t change, previous texture can be reused even when other gradient properties (like position, angle etc.) change. Although animating multi-stop gradients is fast, it will cause texture uploads, so consider if it is worth it.
There are few environment variables to control the gradients texture usage:
QCPAINTER_DISABLE_TEXTURE_USAGE_TRACKING - By default, gradient texture usage is tracked and kept under the max amount. Set this environment variable to disable the tracking and keep all gradient textures in memory.
QCPAINTER_MAX_TEXTURES - By default, the maximum amount of textures is
1024. Set this environt variable to contain number of desired maximum texture amount. The currently unused temporary gradient textures are automatically removed when the maximum amount is reached.Note
This does not have an effect when the texture usage tracking has been disabled.
Inherited by:
QCanvasRadialGradient,QCanvasLinearGradient,QCanvasConicalGradient,QCanvasBoxGradientSynopsis¶
Methods¶
def
endColor()def
__ne__()def
__eq__()def
setColorAt()def
setEndColor()def
setStartColor()def
startColor()
Note
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
Returns the gradient end color or the color at the largest position. If the end color has not been set, returns the default end color transparent black (0, 0, 0, 0).
See also
- __ne__(rhs)¶
- Parameters:
rhs –
QCanvasGradient- Return type:
bool
- __eq__(rhs)¶
- Parameters:
rhs –
QCanvasGradient- Return type:
bool
Creates a stop point at the given
positionwith the givencolor. The givenpositionmust be in the range 0 to 1.See also
setStops()stops()Sets the end color of gradient to
color. This is equal to callingsetColorAt()with position1.See also
Sets the start color of gradient to
color. This is equal to callingsetColorAt()with position0.See also
Returns the gradient start color or the color at the smallest position. If the start color has not been set, returns the default start color white (255, 255, 255).
See also