lv_grad.h

Enums

enum lv_grad_dir_t

The direction of the gradient.

Values:

enumerator LV_GRAD_DIR_NONE

No gradient (the grad_color property is ignored)

enumerator LV_GRAD_DIR_VER

Simple vertical (top to bottom) gradient

enumerator LV_GRAD_DIR_HOR

Simple horizontal (left to right) gradient

enumerator LV_GRAD_DIR_LINEAR

Linear gradient defined by start and end points. Can be at any angle.

enumerator LV_GRAD_DIR_RADIAL

Radial gradient defined by start and end circles

enumerator LV_GRAD_DIR_CONICAL

Conical gradient defined by center point, start and end angles

enum lv_grad_extend_t

Gradient behavior outside the defined range.

Values:

enumerator LV_GRAD_EXTEND_PAD

Repeat the same color

enumerator LV_GRAD_EXTEND_REPEAT

Repeat the pattern

enumerator LV_GRAD_EXTEND_REFLECT

Repeat the pattern mirrored

Functions

void lv_grad_init_stops(lv_grad_dsc_t *grad, const lv_color_t colors[], const lv_opa_t opa[], const uint8_t fracs[], int num_stops)

Initialize gradient color map from a table

Parameters:
  • grad – pointer to a gradient descriptor

  • colors – color array

  • fracs – position array (0..255): if NULL, then colors are distributed evenly

  • opa – opacity array: if NULL, then LV_OPA_COVER is assumed

  • num_stops – number of gradient stops (1..LV_GRADIENT_MAX_STOPS)

void lv_grad_horizontal_init(lv_grad_dsc_t *dsc)

Helper function to initialize a horizontal gradient.

Parameters:

dsc – gradient descriptor

void lv_grad_vertical_init(lv_grad_dsc_t *dsc)

Helper function to initialize a vertical gradient.

Parameters:

dsc – gradient descriptor

void lv_grad_linear_init(lv_grad_dsc_t *dsc, int32_t from_x, int32_t from_y, int32_t to_x, int32_t to_y, lv_grad_extend_t extend)

Helper function to initialize linear gradient

Parameters:
  • dsc – gradient descriptor

  • from_x – start x position: can be a coordinate or an lv_pct() value predefined constants LV_GRAD_LEFT, LV_GRAD_RIGHT, LV_GRAD_TOP, LV_GRAD_BOTTOM, LV_GRAD_CENTER can be used as well

  • from_y – start y position

  • to_x – end x position

  • to_y – end y position

  • extend – one of LV_GRAD_EXTEND_PAD, LV_GRAD_EXTEND_REPEAT or LV_GRAD_EXTEND_REFLECT

void lv_grad_radial_init(lv_grad_dsc_t *dsc, int32_t center_x, int32_t center_y, int32_t to_x, int32_t to_y, lv_grad_extend_t extend)

Helper function to initialize radial gradient

Parameters:
  • dsc – gradient descriptor

  • center_x – center x position: can be a coordinate or an lv_pct() value predefined constants LV_GRAD_LEFT, LV_GRAD_RIGHT, LV_GRAD_TOP, LV_GRAD_BOTTOM, LV_GRAD_CENTER can be used as well

  • center_y – center y position

  • to_x – point on the end circle x position

  • to_y – point on the end circle y position

  • extend – one of LV_GRAD_EXTEND_PAD, LV_GRAD_EXTEND_REPEAT or LV_GRAD_EXTEND_REFLECT

void lv_grad_radial_set_focal(lv_grad_dsc_t *dsc, int32_t center_x, int32_t center_y, int32_t radius)

Set focal (starting) circle of a radial gradient

Parameters:
  • dsc – gradient descriptor

  • center_x – center x position: can be a coordinate or an lv_pct() value predefined constants LV_GRAD_LEFT, LV_GRAD_RIGHT, LV_GRAD_TOP, LV_GRAD_BOTTOM, LV_GRAD_CENTER can be used as well

  • center_y – center y position

  • radius – radius of the starting circle (NOTE: this must be a scalar number, not percentage)

void lv_grad_conical_init(lv_grad_dsc_t *dsc, int32_t center_x, int32_t center_y, int32_t start_angle, int32_t end_angle, lv_grad_extend_t extend)

Helper function to initialize conical gradient

Parameters:
  • dsc – gradient descriptor

  • center_x – center x position: can be a coordinate or an lv_pct() value predefined constants LV_GRAD_LEFT, LV_GRAD_RIGHT, LV_GRAD_TOP, LV_GRAD_BOTTOM, LV_GRAD_CENTER can be used as well

  • center_y – center y position

  • start_angle – start angle in degrees

  • end_angle – end angle in degrees

  • extend – one of LV_GRAD_EXTEND_PAD, LV_GRAD_EXTEND_REPEAT or LV_GRAD_EXTEND_REFLECT

struct lv_grad_stop_t
#include <lv_grad.h>

A gradient stop definition. This matches a color and a position in a virtual 0-255 scale.

Public Members

lv_color_t color

The stop color

lv_opa_t opa

The opacity of the color

uint8_t frac

The stop position in 1/255 unit

struct lv_grad_dsc_t
#include <lv_grad.h>

A descriptor of a gradient.

Public Members

lv_grad_stop_t stops[2]

A gradient stop array

uint8_t stops_count

The number of used stops in the array

lv_grad_dir_t dir

The gradient direction. Any of LV_GRAD_DIR_NONE, LV_GRAD_DIR_VER, LV_GRAD_DIR_HOR, LV_GRAD_TYPE_LINEAR, LV_GRAD_TYPE_RADIAL, LV_GRAD_TYPE_CONICAL

lv_grad_extend_t extend

Behaviour outside the defined range. LV_GRAD_EXTEND_NONE, LV_GRAD_EXTEND_PAD, LV_GRAD_EXTEND_REPEAT, LV_GRAD_EXTEND_REFLECT

lv_point_t start

Linear gradient vector start point

lv_point_t end

Linear gradient vector end point

Center of the ending circle in local coordinates

struct lv_grad_dsc_t::[anonymous]::[anonymous] linear
lv_point_t focal

Center of the focal (starting) circle in local coordinates

lv_point_t focal_extent

Point on the circle (can be the same as the center)

lv_point_t end_extent

Point on the circle determining the radius of the gradient

struct lv_grad_dsc_t::[anonymous]::[anonymous] radial
lv_point_t center

Conical gradient center point

int16_t start_angle

Start angle 0..3600

int16_t end_angle

End angle 0..3600

struct lv_grad_dsc_t::[anonymous]::[anonymous] conical
union lv_grad_dsc_t::[anonymous] params
void *state