ThorVG v1.0
Loading...
Searching...
No Matches
RadialGradient

A class representing the radial gradient fill of the Shape object. More...

#include <thorvg.h>

Inheritance diagram for RadialGradient:
Collaboration diagram for RadialGradient:

Public Member Functions

Result radial (float cx, float cy, float r, float fx, float fy, float fr) noexcept
 Sets the radial gradient attributes.
 
Result radial (float *cx, float *cy, float *r, float *fx=nullptr, float *fy=nullptr, float *fr=nullptr) const noexcept
 Gets the radial gradient attributes.
 
Type type () const noexcept override
 Returns the ID value of this class.
 
- Public Member Functions inherited from Fill
Result colorStops (const ColorStop *colorStops, uint32_t cnt) noexcept
 Sets the parameters of the colors of the gradient and their position.
 
Result spread (FillSpread s) noexcept
 Sets the FillSpread value, which specifies how to fill the area outside the gradient bounds.
 
Result transform (const Matrix &m) noexcept
 Sets the matrix of the affine transformation for the gradient fill.
 
uint32_t colorStops (const ColorStop **colorStops) const noexcept
 Gets the parameters of the colors of the gradient, their position and number.
 
FillSpread spread () const noexcept
 Gets the FillSpread value of the fill.
 
Matrixtransform () const noexcept
 Gets the matrix of the affine transformation of the gradient fill.
 
Fillduplicate () const noexcept
 Creates a copy of the Fill object.
 

Static Public Member Functions

static RadialGradientgen () noexcept
 Creates a new RadialGradient object.
 

Detailed Description

A class representing the radial gradient fill of the Shape object.

Warning
This class is not designed for inheritance.

Member Function Documentation

◆ gen()

static RadialGradient * gen ( )
staticnoexcept

Creates a new RadialGradient object.

Returns
A new RadialGradient object.

◆ radial() [1/2]

Result radial ( float *  cx,
float *  cy,
float *  r,
float *  fx = nullptr,
float *  fy = nullptr,
float *  fr = nullptr 
) const
noexcept

Gets the radial gradient attributes.

Parameters
[out]cxThe horizontal coordinate of the center of the end circle.
[out]cyThe vertical coordinate of the center of the end circle.
[out]rThe radius of the end circle.
[out]fxThe horizontal coordinate of the center of the start circle.
[out]fyThe vertical coordinate of the center of the start circle.
[out]frThe radius of the start circle.
See also
RadialGradient::radial()

◆ radial() [2/2]

Result radial ( float  cx,
float  cy,
float  r,
float  fx,
float  fy,
float  fr 
)
noexcept

Sets the radial gradient attributes.

The radial gradient is defined by the end circle with a center (cx, cy) and a radius r and the start circle with a center/focal point (fx, fy) and a radius fr. 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
[in]cxThe horizontal coordinate of the center of the end circle.
[in]cyThe vertical coordinate of the center of the end circle.
[in]rThe radius of the end circle.
[in]fxThe horizontal coordinate of the center of the start circle.
[in]fyThe vertical coordinate of the center of the start circle.
[in]frThe radius of the start circle.
Return values
Result::InvalidArgumentsin case the radius r or fr value is negative.
Note
In case the radius r is zero, an object is filled with a single color using the last color specified in the colorStops().
In case the focal point (fx and fy) lies outside the end circle, it is projected onto the edge of the end circle.
If the start circle doesn't fully fit inside the end circle (after possible repositioning), the fr is reduced accordingly.
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 (fx and fy) with the center of the end circle (cx and cy) and set the radius (fr) to zero. This will result in a uniform gradient without any focal variations.

◆ type()

Type type ( ) const
overridevirtualnoexcept

Returns the ID value of this class.

This method can be used to check the current concrete instance type.

Returns
The class type ID of the LinearGradient instance.
Since
1.0

Implements Fill.