# lv_draw_line.h (/api/draw/lv_draw_line_h)



<ApiSummary functions="4" structs="1" macros="1" />

Functions [#functions]

<ApiTabs items="[&#x22;Getters (1)&#x22;,&#x22;Other (3)&#x22;]">
  <ApiTab value="Getters (1)">
    <ApiMember kind="function" name="lv_draw_task_get_line_dsc" file="draw/lv_draw_line.h" line="95" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/draw/lv_draw_line.h#L95">
      lv_draw_task_get_line_dsc [#lv_draw_task_get_line_dsc]

      Try to get a line draw descriptor from a draw task.

      ```c title=" " lineNumbers=1
      lv_draw_line_dsc_t * lv_draw_task_get_line_dsc(lv_draw_task_t *task)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name   | Type                                                         | Description |
      | ------ | ------------------------------------------------------------ | ----------- |
      | `task` | <ApiLink name="lv_draw_task_t" display="lv_draw_task_t *" /> | draw task   |

      **Returns:** <ApiLink name="lv_draw_line_dsc_t" display="lv_draw_line_dsc_t *" /> — the task's draw descriptor or NULL if the task is not of type LV\_DRAW\_TASK\_TYPE\_LINE
    </ApiMember>
  </ApiTab>

  <ApiTab value="Other (3)">
    <ApiMember kind="function" name="lv_draw_line_dsc_init" file="draw/lv_draw_line.h" line="88" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/draw/lv_draw_line.h#L88">
      lv_draw_line_dsc_init [#lv_draw_line_dsc_init]

      Initialize a line draw descriptor

      ```c title=" " lineNumbers=1
      void lv_draw_line_dsc_init(lv_draw_line_dsc_t *dsc)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name  | Type                                                                 | Description                  |
      | ----- | -------------------------------------------------------------------- | ---------------------------- |
      | `dsc` | <ApiLink name="lv_draw_line_dsc_t" display="lv_draw_line_dsc_t *" /> | pointer to a draw descriptor |
    </ApiMember>

    <ApiMember kind="function" name="lv_draw_line" file="draw/lv_draw_line.h" line="102" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/draw/lv_draw_line.h#L102">
      lv_draw_line [#lv_draw_line]

      Create a line draw task

      ```c title=" " lineNumbers=1
      void lv_draw_line(lv_layer_t *layer, const lv_draw_line_dsc_t *dsc)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name    | Type                                                                       | Description                                                              |
      | ------- | -------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
      | `layer` | <ApiLink name="lv_layer_t" display="lv_layer_t *" />                       | pointer to a layer                                                       |
      | `dsc`   | <ApiLink name="lv_draw_line_dsc_t" display="const lv_draw_line_dsc_t *" /> | pointer to an initialized <ApiLink name="lv_draw_line_dsc_t" /> variable |
    </ApiMember>

    <ApiMember kind="function" name="lv_draw_line_iterate" file="draw/lv_draw_line.h" line="112" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/draw/lv_draw_line.h#L112">
      lv_draw_line_iterate [#lv_draw_line_iterate]

      A helper function to call a callback which draws a line between two points. This way it doesn't matter if `p1, p2` or `points` were used as it calls the `callback` as needed.

      ```c title=" " lineNumbers=1
      void lv_draw_line_iterate(lv_draw_task_t *t, lv_draw_line_dsc_t *dsc, void(*draw_line_cb)(lv_draw_task_t *t, const lv_draw_line_dsc_t *dsc))
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name           | Type                                                                                                | Description                                                  |
      | -------------- | --------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ |
      | `t`            | <ApiLink name="lv_draw_task_t" display="lv_draw_task_t *" />                                        | draw task                                                    |
      | `dsc`          | <ApiLink name="lv_draw_line_dsc_t" display="lv_draw_line_dsc_t *" />                                | pointer to a draw descriptor                                 |
      | `draw_line_cb` | `void(*)(`<ApiLink name="lv_draw_task_t" />`*t, const`<ApiLink name="lv_draw_line_dsc_t" />` *dsc)` | a callback that draws a line between `dsc->p1` and `dsc->p2` |
    </ApiMember>
  </ApiTab>
</ApiTabs>

Structs [#structs]

<ApiMember kind="struct" name="lv_draw_line_dsc_t">
  lv_draw_line_dsc_t [#lv_draw_line_dsc_t]

  | Member        | Type                                                                 | Description                                                                                                            |
  | ------------- | -------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
  | `base`        | <ApiLink name="lv_draw_dsc_base_t" />                                |                                                                                                                        |
  | `p1`          | <ApiLink name="lv_point_precise_t" />                                | The first point of the line. If `LV_USE_FLOAT` is enabled float number can be also used. Ignored if `points` are set   |
  | `p2`          | <ApiLink name="lv_point_precise_t" />                                | The second point of the line. If `LV_USE_FLOAT` is enabled float number can be also used Ignored if `points` are set   |
  | `points`      | <ApiLink name="lv_point_precise_t" display="lv_point_precise_t *" /> | Array of points to draw. If `LV_USE_FLOAT` is enabled, float numbers can also be used.                                 |
  | `point_cnt`   | <ApiLink name="int32_t" />                                           | Number of points in the `points`                                                                                       |
  | `color`       | <ApiLink name="lv_color_t" />                                        | The color of the line                                                                                                  |
  | `width`       | <ApiLink name="int32_t" />                                           | The width (thickness) of the line                                                                                      |
  | `dash_width`  | <ApiLink name="int32_t" />                                           | The length of a dash (0: don't dash)                                                                                   |
  | `dash_gap`    | <ApiLink name="int32_t" />                                           | The length of the gaps between dashes (0: don't dash)                                                                  |
  | `opa`         | <ApiLink name="lv_opa_t" />                                          | Opacity of the line in 0...255 range. LV\_OPA\_TRANSP, LV\_OPA\_10, LV\_OPA\_20, .. LV\_OPA\_COVER can be used as well |
  | `round_start` | <ApiLink name="uint8_t" />                                           | Make the line start rounded                                                                                            |
  | `round_end`   | <ApiLink name="uint8_t" />                                           | Make the line end rounded                                                                                              |
  | `raw_end`     | <ApiLink name="uint8_t" />                                           | 1: Do not bother with line ending (if it's not visible for any reason)                                                 |
</ApiMember>

<TypeUsedBy name="lv_draw_line_dsc_t" count="12">
  * `lv_obj_init_draw_line_dsc` — param `draw_dsc`
  * `lv_draw_eve_line` — param `dsc`
  * `lv_draw_line_dsc_init` — param `dsc`
  * `lv_draw_line` — param `dsc`
  * `lv_draw_line_iterate` — param `dsc`
  * `lv_draw_line_iterate` — param `draw_line_cb`
  * `lv_draw_nanovg_line` — param `dsc`
  * `lv_draw_nema_gfx_line` — param `dsc`
  * `lv_draw_dave2d_line` — param `dsc`
  * `lv_draw_sdl_line` — param `dsc`
  * `lv_draw_sw_line` — param `dsc`
  * `lv_draw_vg_lite_line` — param `dsc`
</TypeUsedBy>

Macros [#macros]

<ApiMember kind="macro" name="LV_DRAW_LINE_POINT_NONE" file="draw/lv_draw_line.h" line="26" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/draw/lv_draw_line.h#L26">
  LV_DRAW_LINE_POINT_NONE [#lv_draw_line_point_none]

  ```c title=" " lineNumbers=1
  #define LV_DRAW_LINE_POINT_NONE FLT_MAX
  ```
</ApiMember>

Dependencies [#dependencies]

<FileIncludes includes="[&#x22;lv_conf_internal.h&#x22;, &#x22;lv_color.h&#x22;, &#x22;lv_area.h&#x22;, &#x22;lv_style.h&#x22;, &#x22;float.h&#x22;]" includedBy="[&#x22;lv_obj_draw.h&#x22;, &#x22;lv_draw_eve_private.h&#x22;, &#x22;lv_draw_nanovg_private.h&#x22;, &#x22;lv_draw_nema_gfx.h&#x22;, &#x22;lv_draw_dave2d.h&#x22;, &#x22;lv_draw_sdl.h&#x22;, &#x22;lv_draw_sw.h&#x22;, &#x22;lv_draw_vg_lite.h&#x22;]" transitiveIncludes="[&#x22;lv_anim.h&#x22;, &#x22;lv_assert.h&#x22;, &#x22;lv_bidi.h&#x22;, &#x22;lv_color_op.h&#x22;, &#x22;lv_conf_kconfig.h&#x22;, &#x22;lv_draw_buf.h&#x22;, &#x22;lv_ext_data.h&#x22;, &#x22;lv_flex.h&#x22;, &#x22;lv_font.h&#x22;, &#x22;lv_grad.h&#x22;, &#x22;lv_grid.h&#x22;, &#x22;lv_image_dsc.h&#x22;, &#x22;lv_layout.h&#x22;, &#x22;lv_ll.h&#x22;, &#x22;lv_log.h&#x22;, &#x22;lv_math.h&#x22;, &#x22;lv_mem.h&#x22;, &#x22;lv_palette.h&#x22;, &#x22;lv_sprintf.h&#x22;, &#x22;lv_string.h&#x22;, &#x22;lv_style_gen.h&#x22;, &#x22;lv_symbol_def.h&#x22;, &#x22;lv_text.h&#x22;, &#x22;lv_tick.h&#x22;, &#x22;lv_timer.h&#x22;, &#x22;lv_types.h&#x22;]" />
