lv_area.h

Defines

_LV_COORD_TYPE_SHIFT
_LV_COORD_TYPE_MASK
_LV_COORD_TYPE(x)
_LV_COORD_PLAIN(x)
_LV_COORD_TYPE_PX
_LV_COORD_TYPE_SPEC
_LV_COORD_TYPE_PX_NEG
LV_COORD_IS_PX(x)
LV_COORD_IS_SPEC(x)
LV_COORD_SET_SPEC(x)
LV_PCT(x)
LV_COORD_IS_PCT(x)
LV_COORD_GET_PCT(x)
LV_SIZE_CONTENT
LV_COORD_MAX
LV_COORD_MIN

Typedefs

typedef _lv_align_t lv_align_t
typedef _lv_dir_t lv_dir_t

Enums

enum _lv_align_t

Alignments

Values:

enumerator LV_ALIGN_DEFAULT
enumerator LV_ALIGN_TOP_LEFT
enumerator LV_ALIGN_TOP_MID
enumerator LV_ALIGN_TOP_RIGHT
enumerator LV_ALIGN_BOTTOM_LEFT
enumerator LV_ALIGN_BOTTOM_MID
enumerator LV_ALIGN_BOTTOM_RIGHT
enumerator LV_ALIGN_LEFT_MID
enumerator LV_ALIGN_RIGHT_MID
enumerator LV_ALIGN_CENTER
enumerator LV_ALIGN_OUT_TOP_LEFT
enumerator LV_ALIGN_OUT_TOP_MID
enumerator LV_ALIGN_OUT_TOP_RIGHT
enumerator LV_ALIGN_OUT_BOTTOM_LEFT
enumerator LV_ALIGN_OUT_BOTTOM_MID
enumerator LV_ALIGN_OUT_BOTTOM_RIGHT
enumerator LV_ALIGN_OUT_LEFT_TOP
enumerator LV_ALIGN_OUT_LEFT_MID
enumerator LV_ALIGN_OUT_LEFT_BOTTOM
enumerator LV_ALIGN_OUT_RIGHT_TOP
enumerator LV_ALIGN_OUT_RIGHT_MID
enumerator LV_ALIGN_OUT_RIGHT_BOTTOM
enum _lv_dir_t

Values:

enumerator LV_DIR_NONE
enumerator LV_DIR_LEFT
enumerator LV_DIR_RIGHT
enumerator LV_DIR_TOP
enumerator LV_DIR_BOTTOM
enumerator LV_DIR_HOR
enumerator LV_DIR_VER
enumerator LV_DIR_ALL

Functions

void lv_area_set(lv_area_t *area_p, int32_t x1, int32_t y1, int32_t x2, int32_t y2)

Initialize an area

参数:
  • area_p -- pointer to an area

  • x1 -- left coordinate of the area

  • y1 -- top coordinate of the area

  • x2 -- right coordinate of the area

  • y2 -- bottom coordinate of the area

static inline void lv_area_copy(lv_area_t *dest, const lv_area_t *src)

Copy an area

参数:
  • dest -- pointer to the destination area

  • src -- pointer to the source area

static inline int32_t lv_area_get_width(const lv_area_t *area_p)

Get the width of an area

参数:

area_p -- pointer to an area

返回:

the width of the area (if x1 == x2 -> width = 1)

static inline int32_t lv_area_get_height(const lv_area_t *area_p)

Get the height of an area

参数:

area_p -- pointer to an area

返回:

the height of the area (if y1 == y2 -> height = 1)

void lv_area_set_width(lv_area_t *area_p, int32_t w)

Set the width of an area

参数:
  • area_p -- pointer to an area

  • w -- the new width of the area (w == 1 makes x1 == x2)

void lv_area_set_height(lv_area_t *area_p, int32_t h)

Set the height of an area

参数:
  • area_p -- pointer to an area

  • h -- the new height of the area (h == 1 makes y1 == y2)

void _lv_area_set_pos(lv_area_t *area_p, int32_t x, int32_t y)

Set the position of an area (width and height will be kept)

参数:
  • area_p -- pointer to an area

  • x -- the new x coordinate of the area

  • y -- the new y coordinate of the area

uint32_t lv_area_get_size(const lv_area_t *area_p)

Return with area of an area (x * y)

参数:

area_p -- pointer to an area

返回:

size of area

void lv_area_increase(lv_area_t *area, int32_t w_extra, int32_t h_extra)
void lv_area_move(lv_area_t *area, int32_t x_ofs, int32_t y_ofs)
bool _lv_area_intersect(lv_area_t *res_p, const lv_area_t *a1_p, const lv_area_t *a2_p)

Get the common parts of two areas

参数:
  • res_p -- pointer to an area, the result will be stored her

  • a1_p -- pointer to the first area

  • a2_p -- pointer to the second area

返回:

false: the two area has NO common parts, res_p is invalid

int8_t _lv_area_diff(lv_area_t res_p[], const lv_area_t *a1_p, const lv_area_t *a2_p)

Get resulting sub areas after removing the common parts of two areas from the first area

参数:
  • res_p -- pointer to an array of areas with a count of 4, the resulting areas will be stored here

  • a1_p -- pointer to the first area

  • a2_p -- pointer to the second area

返回:

number of results (max 4) or -1 if no intersect

void _lv_area_join(lv_area_t *a_res_p, const lv_area_t *a1_p, const lv_area_t *a2_p)

Join two areas into a third which involves the other two

参数:
  • a_res_p -- pointer to an area, the result will be stored here

  • a1_p -- pointer to the first area

  • a2_p -- pointer to the second area

bool _lv_area_is_point_on(const lv_area_t *a_p, const lv_point_t *p_p, int32_t radius)

Check if a point is on an area

参数:
  • a_p -- pointer to an area

  • p_p -- pointer to a point

  • radius -- radius of area (e.g. for rounded rectangle)

返回:

false:the point is out of the area

bool _lv_area_is_on(const lv_area_t *a1_p, const lv_area_t *a2_p)

Check if two area has common parts

参数:
  • a1_p -- pointer to an area.

  • a2_p -- pointer to an other area

返回:

false: a1_p and a2_p has no common parts

bool _lv_area_is_in(const lv_area_t *ain_p, const lv_area_t *aholder_p, int32_t radius)

Check if an area is fully on an other

参数:
  • ain_p -- pointer to an area which could be in 'aholder_p'

  • aholder_p -- pointer to an area which could involve 'ain_p'

  • radius -- radius of aholder_p (e.g. for rounded rectangle)

返回:

true: ain_p is fully inside aholder_p

bool _lv_area_is_out(const lv_area_t *aout_p, const lv_area_t *aholder_p, int32_t radius)

Check if an area is fully out of an other

参数:
  • aout_p -- pointer to an area which could be in 'aholder_p'

  • aholder_p -- pointer to an area which could involve 'ain_p'

  • radius -- radius of aholder_p (e.g. for rounded rectangle)

返回:

true: aout_p is fully outside aholder_p

bool _lv_area_is_equal(const lv_area_t *a, const lv_area_t *b)

Check if 2 area is the same

参数:
  • a -- pointer to an area

  • b -- pointer to another area

void lv_area_align(const lv_area_t *base, lv_area_t *to_align, lv_align_t align, int32_t ofs_x, int32_t ofs_y)

Align an area to an other

参数:
  • base -- an area where the other will be aligned

  • to_align -- the area to align

  • align -- LV_ALIGN_...

  • ofs_x -- X offset

  • ofs_y -- Y offset

void lv_point_transform(lv_point_t *point, int32_t angle, int32_t scale_x, int32_t scale_y, const lv_point_t *pivot, bool zoom_first)

Transform a point

参数:
  • point -- pointer to a point

  • angle -- angle with 0.1 resolutions (123 means 12.3°)

  • scale_x -- horizontal zoom, 256 means 100%

  • scale_y -- vertical zoom, 256 means 100%

  • pivot -- pointer to the pivot point of the transformation

  • zoom_first -- true: zoom first and rotate after that; else: opssoite order

void lv_point_array_transform(lv_point_t *points, size_t count, int32_t angle, int32_t scale_x, int32_t scale_y, const lv_point_t *pivot, bool zoom_first)

Transform an array of points

参数:
  • points -- pointer to an array of points

  • count -- number of points in the array

  • angle -- angle with 0.1 resolutions (123 means 12.3°)

  • scale_x -- horizontal zoom, 256 means 100%

  • scale_y -- vertical zoom, 256 means 100%

  • pivot -- pointer to the pivot point of the transformation

  • zoom_first -- true: zoom first and rotate after that; else: opssoite order

static inline lv_point_t lv_point_from_precise(const lv_point_precise_t *p)
static inline lv_point_precise_t lv_point_to_precise(const lv_point_t *p)
static inline void lv_point_set(lv_point_t *p, int32_t x, int32_t y)
static inline void lv_point_precise_set(lv_point_precise_t *p, lv_value_precise_t x, lv_value_precise_t y)
static inline void lv_point_swap(lv_point_t *p1, lv_point_t *p2)
static inline void lv_point_precise_swap(lv_point_precise_t *p1, lv_point_precise_t *p2)
static inline int32_t lv_pct(int32_t x)

Convert a percentage value to int32_t. Percentage values are stored in special range

参数:

x -- the percentage (0..1000)

返回:

a coordinate that stores the percentage

static inline int32_t lv_pct_to_px(int32_t v, int32_t base)
struct lv_point_t
#include <lv_area.h>

Represents a point on the screen.

Public Members

int32_t x
int32_t y
struct lv_point_precise_t
struct lv_area_t
#include <lv_area.h>

Represents an area of the screen.

Public Members

int32_t x1
int32_t y1
int32_t x2
int32_t y2