lv_draw_sw_gradient.h

Defines

LV_GRAD_LEFT
LV_GRAD_RIGHT
LV_GRAD_TOP
LV_GRAD_BOTTOM
LV_GRAD_CENTER

Typedefs

typedef lv_color_t lv_grad_color_t
typedef struct _lv_gradient_cache_t lv_grad_t

Functions

void lv_gradient_color_calculate(const lv_grad_dsc_t *dsc, int32_t range, int32_t frac, lv_grad_color_t *color_out, lv_opa_t *opa_out)

Compute the color in the given gradient and fraction Gradient are specified in a virtual [0-255] range, so this function scales the virtual range to the given range

Parameters:
  • dsc -- The gradient descriptor to use

  • range -- The range to use in computation.

  • frac -- The current part used in the range. frac is in [0; range]

lv_grad_t *lv_gradient_get(const lv_grad_dsc_t *gradient, int32_t w, int32_t h)

Get a gradient cache from the given parameters

void lv_gradient_cleanup(lv_grad_t *grad)

Clean up the gradient item after it was get with lv_grad_get_from_cache.

Parameters:

grad -- pointer to a gradient

void lv_gradient_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_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

void lv_gradient_linear_setup(lv_grad_dsc_t *dsc, const lv_area_t *coords)

Calculate constants from the given parameters that are used during rendering

Parameters:

dsc -- gradient descriptor

void lv_gradient_linear_cleanup(lv_grad_dsc_t *dsc)

Free up the allocated memory for the gradient calculation

Parameters:

dsc -- gradient descriptor

void lv_gradient_linear_get_line(lv_grad_dsc_t *dsc, int32_t xp, int32_t yp, int32_t width, lv_grad_t *result)

Calculate a line segment of a linear gradient

Parameters:
  • dsc -- gradient descriptor

  • xp -- starting point x coordinate in gradient space

  • yp -- starting point y coordinate in gradient space

  • width -- width of the line segment in pixels

  • result -- color buffer for the resulting line segment

void lv_gradient_radial_setup(lv_grad_dsc_t *dsc, const lv_area_t *coords)

Calculate constants from the given parameters that are used during rendering

Parameters:

dsc -- gradient descriptor

void lv_gradient_radial_cleanup(lv_grad_dsc_t *dsc)

Free up the allocated memory for the gradient calculation

Parameters:

dsc -- gradient descriptor

void lv_gradient_radial_get_line(lv_grad_dsc_t *dsc, int32_t xp, int32_t yp, int32_t width, lv_grad_t *result)

Calculate a line segment of a radial gradient

Parameters:
  • dsc -- gradient descriptor

  • xp -- starting point x coordinate in gradient space

  • yp -- starting point y coordinate in gradient space

  • width -- width of the line segment in pixels

  • result -- color buffer for the resulting line segment

void lv_gradient_conical_setup(lv_grad_dsc_t *dsc, const lv_area_t *coords)

Calculate constants from the given parameters that are used during rendering

Parameters:

dsc -- gradient descriptor

void lv_gradient_conical_cleanup(lv_grad_dsc_t *dsc)

Free up the allocated memory for the gradient calculation

Parameters:

dsc -- gradient descriptor

void lv_gradient_conical_get_line(lv_grad_dsc_t *dsc, int32_t xp, int32_t yp, int32_t width, lv_grad_t *result)

Calculate a line segment of a conical gradient

Parameters:
  • dsc -- gradient descriptor

  • xp -- starting point x coordinate in gradient space

  • yp -- starting point y coordinate in gradient space

  • width -- width of the line segment in pixels

  • result -- color buffer for the resulting line segment

struct _lv_gradient_cache_t

Public Members

lv_color_t *color_map
lv_opa_t *opa_map
uint32_t size