lv_nanovg_utils.h

Functions

void lv_nanovg_utils_init(struct _lv_draw_nanovg_unit_t *u)

Initialize NanoVG utilities

Parameters:

u – pointer to the nanovg unit

void lv_nanovg_utils_deinit(struct _lv_draw_nanovg_unit_t *u)

Deinitialize NanoVG utilities

Parameters:

u – pointer to the nanovg unit

static inline void lv_nanovg_matrix_convert(float *xform, const lv_matrix_t *matrix)

Convert an LVGL matrix to a NanoVG transform (3x2 matrix)

Parameters:
  • xform – the NanoVG transform array (6 floats)

  • matrix – the LVGL matrix

static inline NVGcolor lv_nanovg_color_convert(lv_color_t color, lv_opa_t opa)

Convert an LVGL color to a NanoVG color

Parameters:
  • color – the LVGL color

  • opa – the opacity

Returns:

the NanoVG color

void lv_nanovg_transform(NVGcontext *ctx, const lv_matrix_t *matrix)

Apply a transform matrix to the NanoVG context

Parameters:
  • ctx – the NanoVG context

  • matrix – the transform matrix

void lv_nanovg_set_clip_area(NVGcontext *ctx, const lv_area_t *area)

Set the clipping area

Parameters:
  • ctx – the NanoVG context

  • area – the clipping area

void lv_nanovg_path_append_rect(NVGcontext *ctx, float x, float y, float w, float h, float r)

Append a rectangle to the path

Parameters:
  • ctx – the NanoVG context

  • x – the x coordinate of the rectangle

  • y – the y coordinate of the rectangle

  • w – the width of the rectangle

  • h – the height of the rectangle

  • r – the radius of the rectangle (0 for no rounding)

void lv_nanovg_path_append_area(NVGcontext *ctx, const lv_area_t *area)

Append an area to the path

Parameters:
  • ctx – the NanoVG context

  • area – the area

void lv_nanovg_path_append_arc_right_angle(NVGcontext *ctx, float start_x, float start_y, float center_x, float center_y, float end_x, float end_y)

Append a right angle arc to the path

Parameters:
  • ctx – the NanoVG context

  • start_x – the starting x coordinate

  • start_y – the starting y coordinate

  • center_x – the center x coordinate

  • center_y – the center y coordinate

  • end_x – the ending x coordinate

  • end_y – the ending y coordinate

void lv_nanovg_path_append_arc(NVGcontext *ctx, float cx, float cy, float radius, float start_angle, float sweep, bool pie)

Append an arc to the path

Parameters:
  • ctx – the NanoVG context

  • cx – the center x coordinate

  • cy – the center y coordinate

  • radius – the radius

  • start_angle – the starting angle in radians

  • sweep – the sweep angle in radians

  • pie – whether to draw a pie slice (connected to center)

void lv_nanovg_fill(NVGcontext *ctx, enum NVGwinding winding, enum NVGcompositeOperation composite_operation, NVGcolor color)

Fill the current path

Parameters:
  • ctx – the NanoVG context

  • winding – the winding rule

  • composite_operation – the blend mode

  • color – the fill color

void lv_nanovg_end_frame(struct _lv_draw_nanovg_unit_t *u)

End the current frame

Parameters:

u – pointer to the nanovg unit

void lv_nanovg_clean_up(struct _lv_draw_nanovg_unit_t *u)

Clean up the NanoVG unit (e.g. at the end of task)

Parameters:

u – pointer to the nanovg unit

lv_draw_buf_t *lv_nanovg_reshape_global_image(struct _lv_draw_nanovg_unit_t *u, lv_color_format_t cf, uint32_t w, uint32_t h)

Reshape the global image buffer

Parameters:
  • u – pointer to the nanovg unit

  • cf – the color format

  • w – the new width

  • h – the new height

Returns:

pointer to the resized draw buffer