Inheritance

  • Inherited from the Base object so every lv_obj_... function can be used to set position, size, style and other basic attributes.

Overview

The line object are capable of drawing straight lines between a set of points. The points has to be stored in an lv_point_t array and passed to the object by the lv_line_set_points(lines, point_array, point_num) function.

It is possible to automatically set the size of the line object according to its points. You can enable it with the lv_line_set_auto_size(line, true) function. If enabled then when the points are set then the object width and height will be changed according to the max. x and max. y coordinates among the points. The auto size is enabled by default.

Basically the y == 0 point is in the top of the object but you can invert the y coordinates with lv_line_set_y_invert(line, true). After it the y coordinates will be subtracted from object's height .

Style usage

  • style.line properties are used

Notes

Example of Line in Littlev Graphics Library

						/*Create an array for the points of the line*/
static lv_point_t line_points[] = {{5, 5}, {70, 70}, {120, 10}, {180, 60}, {240, 10}};

/*Create line with default style*/
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_align(line1, NULL, LV_ALIGN_IN_TOP_MID, 0, 20);

/*Create new style (thin light blue)*/
static lv_style_t style_line2;
lv_style_copy(&style_line2, &lv_style_plain);
style_line2.line.color = LV_COLOR_MAKE(0x2e, 0x96, 0xff);
style_line2.line.width = 2;

/*Copy the previous line and apply the new style*/
lv_obj_t * line2 = lv_line_create(lv_scr_act(), line1);
lv_line_set_style(line2, &style_line2);
lv_obj_align(line2, line1, LV_ALIGN_OUT_BOTTOM_MID, 0, -20);

/*Create new style (thick dark blue)*/
static lv_style_t style_line3;
lv_style_copy(&style_line3, &lv_style_plain);
style_line3.line.color = LV_COLOR_MAKE(0x00, 0x3b, 0x75);
style_line3.line.width = 5;

/*Copy the previous line and apply the new style*/
lv_obj_t * line3 = lv_line_create(lv_scr_act(), line1);
lv_line_set_style(line3, &style_line3);
lv_obj_align(line3, line2, LV_ALIGN_OUT_BOTTOM_MID, 0, -20);

lv_obj_t *

lv_line_create

(lv_obj_t * par, lv_obj_t * copy);

Create a line objects

par pointer to an object, it will be the parent of the new line

return pointer to the created line

void

lv_line_set_points

(lv_obj_t * line, const lv_point_t * point_a, uint16_t point_num);

Set an array of points. The line object will connect these points.

line pointer to a line object

point_a an array of points. Only the address is saved,
so the array can NOT be a local variable which will be destroyed

point_num number of points in 'point_a'

void

lv_line_set_auto_size

(lv_obj_t * line, bool autosize_en);

Enable (or disable) the auto-size option. The size of the object will fit to its points.
(set width to x max and height to y max)

line pointer to a line object

autosize_en true: auto size is enabled, false: auto size is disabled

void

lv_line_set_y_invert

(lv_obj_t * line, bool yinv_en);

Enable (or disable) the y coordinate inversion.
If enabled then y will be subtracted from the height of the object,
therefore the y=0 coordinate will be on the bottom.

line pointer to a line object

yinv_en true: enable the y inversion, false:disable the y inversion

void

lv_line_set_style

(lv_obj_t *line, lv_style_t *style);

Set the style of a line

line pointer to a line object

style pointer to a style

void

lv_line_set_upscale

(lv_obj_t * line, bool upcale);

Obsolete since v5.1. Just for compatibility with v5.0. Will be removed in v6.0

line -

upscale -

bool

lv_line_get_auto_size

(lv_obj_t * line);

Get the auto size attribute

line pointer to a line object

return true: auto size is enabled, false: disabled

bool

lv_line_get_y_inv

(lv_obj_t * line);

Get the y inversion attribute

line pointer to a line object

return true: y inversion is enabled, false: disabled

lv_style_t*

lv_line_get_style

(lv_obj_t *line);

Get the style of an line object

line pointer to an line object

return pointer to the line's style

bool

lv_line_get_upscale

(lv_obj_t * line);

Obsolete since v5.1. Just for compatibility with v5.0. Will be removed in v6.0

line -

return false

LittlevGL - Open-source Embedded GUI Library

LittlevGL is a free and open-source graphics library providing everything you need to create embedded GUI with easy-to-use graphical elements, beautiful visual effects and low memory footprint.

If you like LittlevGL, please
support its deveopment!


The founder of Littlev Graphics Library (LittlevGL) and related software modules is:
Gábor Kiss-Vámosi
All Rights Reserved ©  2018 Hungary