lv_line
相关API在lv_line.h
,默认原点在左上角,通过 lv_line_set_y_invert(line, true)接口来反转 y 轴,从而使左下角变为原点.
样式
/*Styles*/
enum {
LV_LINE_PART_MAIN,
};
typedef uint8_t lv_line_style_t;
例子
static void task_cb(lv_task_t* task)
{
lv_obj_t * *dat = (lv_obj_t **)task->user_data;
lv_line_set_y_invert(*dat, !lv_line_get_y_invert(*dat));
}
void lv_ex_line_1(void)
{
/*Create an array for the points of the line*/
static lv_point_t line_points[] = { {0, 0}, {70, 70}, {120, 10}, {180, 60}, {240, 10} };
/*Create style*/
static lv_style_t style_line;
lv_style_init(&style_line);
lv_style_set_line_width(&style_line, LV_STATE_DEFAULT, 8);
lv_style_set_line_color(&style_line, LV_STATE_DEFAULT, LV_COLOR_BLUE);
lv_style_set_line_rounded(&style_line, LV_STATE_DEFAULT, true);
/*Create a line and apply the new style*/
static lv_obj_t * line1;
line1 = lv_line_create(lv_scr_act(), NULL);
lv_line_set_points(line1, line_points, 5); /*Set the points*/
lv_obj_add_style(line1, LV_LINE_PART_MAIN, &style_line); /*Set the points*/
lv_obj_align(line1, NULL, LV_ALIGN_CENTER, 0, 0);
lv_task_t * task = lv_task_create(task_cb, 1000, LV_TASK_PRIO_MID, &line1);
}