| ThorVG v0.9

Public Member Functions | Static Public Member Functions | List of all members
LinearGradientfinal
ThorVG

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

Inheritance diagram for LinearGradient:
[legend]

## Public Member Functions
Result | linear (float x1, float y1, float x2, float y2) noexcept
| Sets the linear gradient bounds. More...
Result | linear (float *x1, float *y1, float *x2, float *y2) const noexcept
| Gets the linear gradient bounds. More...
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. More...
Result | spread (FillSpread s) noexcept
| Sets the FillSpread value, which specifies how to fill the area outside the gradient bounds. More...
Result | transform (const Matrix &m) noexcept
| Sets the matrix of the affine transformation for the gradient fill. More...
uint32_t | colorStops (const ColorStop **colorStops) const noexcept
| Gets the parameters of the colors of the gradient, their position and number. More...
FillSpread | spread () const noexcept
| Gets the FillSpread value of the fill. More...
Matrix | transform () const noexcept
| Gets the matrix of the affine transformation of the gradient fill. More...
Fill * | duplicate () const noexcept
| Creates a copy of the Fill object. More...
uint32_t | identifier () const noexcept
| Return the unique id value of the Fill instance. More...

## Static Public Member Functions
static std::unique_ptr< LinearGradient > | gen () noexcept
| Creates a new LinearGradient object. More...
static uint32_t | identifier () noexcept
| Return the unique id value of this class. More...

## Detailed Description

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

Besides the APIs inherited from the Fill class, it enables setting and getting the linear gradient bounds. The behavior outside the gradient bounds depends on the value specified in the spread API.

## Member Function Documentation

## ◆ gen()

static std::unique_ptr<LinearGradient> gen | ( |  | ) |
| static noexcept

Creates a new LinearGradient object.

Returns
  A new LinearGradient object.

## ◆ identifier()

static uint32_t identifier | ( |  | ) |
| static noexcept

Return the unique id value of this class.

This method can be referred for identifying the LinearGradient class type.

Returns
  The type id of the LinearGradient class.

## ◆ linear() [1/2]

Result linear | ( | float * | x1,
|  | float * | y1,
|  | float * | x2,
|  | float * | y2
| ) |  | const
| noexcept

Gets the linear gradient bounds.

The bounds of the linear gradient are defined as a surface constrained by two parallel lines crossing the given points (`x1`, `y1`) and (`x2`, `y2`), respectively. Both lines are perpendicular to the line linking (`x1`, `y1`) and (`x2`, `y2`).

Parameters

  [out] | x1 | The horizontal coordinate of the first point used to determine the gradient bounds.
  [out] | y1 | The vertical coordinate of the first point used to determine the gradient bounds.
  [out] | x2 | The horizontal coordinate of the second point used to determine the gradient bounds.
  [out] | y2 | The vertical coordinate of the second point used to determine the gradient bounds.

Returns
  Result::Success when succeed.

## ◆ linear() [2/2]

Result linear | ( | float | x1,
|  | float | y1,
|  | float | x2,
|  | float | y2
| ) |  |
| noexcept

Sets the linear gradient bounds.

The bounds of the linear gradient are defined as a surface constrained by two parallel lines crossing the given points (`x1`, `y1`) and (`x2`, `y2`), respectively. Both lines are perpendicular to the line linking (`x1`, `y1`) and (`x2`, `y2`).

Parameters

  [in] | x1 | The horizontal coordinate of the first point used to determine the gradient bounds.
  [in] | y1 | The vertical coordinate of the first point used to determine the gradient bounds.
  [in] | x2 | The horizontal coordinate of the second point used to determine the gradient bounds.
  [in] | y2 | The vertical coordinate of the second point used to determine the gradient bounds.

Returns
  Result::Success when succeed.

Note
  In case the first and the second points are equal, an object filled with such a gradient fill is not rendered.