thorvg_python.gradient.radial¶
Classes¶
Radial Gradient API |
Module Contents¶
-
class thorvg_python.gradient.radial.RadialGradient(engine: thorvg_python.engine.Engine, grad: thorvg_python.base.GradientPointer | None =
None)¶ Bases:
thorvg_python.gradient.GradientRadial Gradient API
- engine¶
- thorvg_lib¶
- _new() thorvg_python.base.GradientPointer¶
Creates a new radial gradient object.
Note
You need not call this method as it is auto called when initializing
LinearGradient().
- set(cx: float, cy: float, r: float, fx: float, fy: float, fr: float) thorvg_python.base.Result¶
Sets the radial gradient attributes.
The radial gradient is defined by the end circle with a center (
cx,cy) and a radiusrand the start circle with a center/focal point (fx,fy) and a radiusfr. The gradient will be rendered such that the gradient stop at an offset of 100% aligns with the edge of the end circle and the stop at an offset of 0% aligns with the edge of the start circle.- Parameters:¶
- cx : float¶
The horizontal coordinate of the center of the end circle.
- cy : float¶
The vertical coordinate of the center of the end circle.
- r : float¶
The radius of the end circle.
- fx : float¶
The horizontal coordinate of the center of the start circle.
- fy : float¶
The vertical coordinate of the center of the start circle.
- fr : float¶
The radius of the start circle.
TVG_RESULT_INVALID_ARGUMENT An invalid GradientPointer or the radius
rorfrvalue is negative.
Note
In case the radius
ris zero, an object is filled with a single color using the last color specified in the specified in the Gradient.set_color_stops().Note
In case the focal point (
fx` and ``fy) lies outside the end circle, it is projected onto the edge of the end circle.Note
If the start circle doesn’t fully fit inside the end circle (after possible repositioning), the
fris reduced accordingly.Note
By manipulating the position and size of the focal point, a wide range of visual effects can be achieved, such as directing the gradient focus towards a specific edge or enhancing the depth and complexity of shading patterns. If a focal effect is not desired, simply align the focal point (
fxandfy) with the center of the end circle (cxandcy) and set the radius (fr) to zero. This will result in a uniform gradient without any focal variations.See also
Gradient.set_color_stops()
- get() tuple[thorvg_python.base.Result, float, float, float, float, float, float]¶
The function gets radial gradient attributes.
- Returns:¶
Result.INVALID_ARGUMENT An invalid GradientPointer.
- Return type:¶
- Returns:¶
The horizontal coordinate of the center of the bounding circle.
- Return type:¶
float
- Returns:¶
The vertical coordinate of the center of the bounding circle.
- Return type:¶
float
- Returns:¶
The radius of the bounding circle.
- Return type:¶
float
- Returns:¶
The horizontal coordinate of the center of the start circle.
- Return type:¶
float
- Returns:¶
The vertical coordinate of the center of the start circle.
- Return type:¶
float
- Returns:¶
The radius of the start circle.
- Return type:¶
float