docs(vector): add basic docs about vector drawing (#9888)
Arduino Lint / lint (push) Has been cancelled
Build Examples with C++ Compiler / build-examples (push) Has been cancelled
MicroPython CI / Build esp32 port (push) Has been cancelled
MicroPython CI / Build rp2 port (push) Has been cancelled
MicroPython CI / Build stm32 port (push) Has been cancelled
MicroPython CI / Build unix port (push) Has been cancelled
C/C++ CI / Build OPTIONS_16BIT - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_24BIT - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_FULL_32BIT - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_NORMAL_8BIT - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_SDL - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_16BIT - cl - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_16BIT - gcc - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_24BIT - cl - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_24BIT - gcc - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_FULL_32BIT - cl - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_FULL_32BIT - gcc - Windows (push) Has been cancelled
C/C++ CI / Build ESP IDF ESP32S3 (push) Has been cancelled
C/C++ CI / Run tests with 32bit build (push) Has been cancelled
C/C++ CI / Run tests with 64bit build (push) Has been cancelled
BOM Check / bom-check (push) Has been cancelled
Verify that lv_conf_internal.h matches repository state / verify-conf-internal (push) Has been cancelled
Verify GDB constants are up-to-date / verify-gdb-consts (push) Has been cancelled
Verify the widget property name / verify-property-name (push) Has been cancelled
Verify code formatting / verify-formatting (push) Has been cancelled
Compare file templates with file names / template-check (push) Has been cancelled
Build docs / build-and-deploy (push) Has been cancelled
Test API JSON generator / Test API JSON (push) Has been cancelled
Install LVGL using CMake / build-examples (push) Has been cancelled
Check Makefile / Build using Makefile (push) Has been cancelled
Check Makefile for UEFI / Build using Makefile for UEFI (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark - Script Check (scripts/perf/tests/benchmark_results_comment/test.sh) (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark - Script Check (scripts/perf/tests/filter_docker_logs/test.sh) (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark - Script Check (scripts/perf/tests/serialize_results/test.sh) (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark 32b - lv_conf_perf32b (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark 64b - lv_conf_perf64b (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark - Save PR Number (push) Has been cancelled
Hardware Performance Test / Hardware Performance Benchmark (push) Has been cancelled
Hardware Performance Test / HW Benchmark - Save PR Number (push) Has been cancelled
Performance Tests CI / Perf Tests OPTIONS_TEST_PERF_32B - Ubuntu (push) Has been cancelled
Performance Tests CI / Perf Tests OPTIONS_TEST_PERF_64B - Ubuntu (push) Has been cancelled
Port repo release update / run-release-branch-updater (push) Has been cancelled
Verify Font License / verify-font-license (push) Has been cancelled
Verify Kconfig / verify-kconfig (push) Has been cancelled
Close stale issues and PRs / stale (push) Has been cancelled

This commit is contained in:
Gabor Kiss-Vamosi
2026-03-24 22:44:29 +01:00
committed by GitHub
parent e234e499b2
commit af113e2f1e
3 changed files with 57 additions and 3 deletions
@@ -677,9 +677,64 @@ following fields:
Vector Draw Descriptor
**********************
TODO
Vector rendering works slightly differently than the other draw descriptors, because
the data required to describe the operation doesn't have a fixed length.
The key element of vector rendering is a "path" (:cpp:expr:`lv_vector_path_t`) which describes
the shape of the drawing using lines, arcs, and curves. The paths can be stroked
(draw a line on the path) and filled (fill the path with a color, gradient, or image).
A :cpp:expr:`lv_draw_vector_dsc_t` vector descriptor can hold multiple paths.
The flow of creating a new vector descriptor is the following.
1. Create a vector draw descriptor:
.. code-block:: c
lv_draw_vector_dsc_t * dsc = lv_draw_vector_dsc_create(layer);
2. Create a path
.. code-block:: c
lv_vector_path_t * path = lv_vector_path_create(LV_VECTOR_PATH_QUALITY_MEDIUM);
3. Set the shape of the path. The following show a few simple functions for that:
- :cpp:expr:`lv_vector_path_clear`: Clear all lines, arcs, and curves from a path
- :cpp:expr:`lv_vector_path_move_to`: Move to a point without drawing any lines
- :cpp:expr:`lv_vector_path_line_to`: Add a line to the path from last point to the point
- :cpp:expr:`lv_vector_path_quad_to`: Add a quadratic bezier line to the path from last point to the point
- :cpp:expr:`lv_vector_path_cubic_to`: Add a cubic bezier line to the path from last point to the point
- :cpp:expr:`lv_vector_path_arc_to`: Add ellipse arc to the path from last point to the point
- :cpp:expr:`lv_vector_path_close`: Close the sub path by connecting the first and last point
4. Set the stroke and fill settings on the draw descriptor for the given path. Use functions like:
- :cpp:expr:`lv_draw_vector_dsc_set_stroke_color`: Set stroke color for a descriptor.
- :cpp:expr:`lv_draw_vector_dsc_set_stroke_opa`: Set stroke opacity for a descriptor
- :cpp:expr:`lv_draw_vector_dsc_set_stroke_width`: Set stroke width for a descriptor.
- :cpp:expr:`lv_draw_vector_dsc_set_fill_color`: Set fill color for a descriptor.
- :cpp:expr:`lv_draw_vector_dsc_set_fill_opa`: Set fill opacity for a descriptor.
5. Add the path to the descriptor. It will apply the stroke and fill settings for the path:
.. code-block:: c
lv_draw_vector_dsc_add_path(dsc, path);
6. If more paths are needed, clear the path or create a new one, and add it to the draw descriptor too.
7. Start drawing and clean up:
.. code-block:: c
lv_draw_vector(dsc);
lv_vector_path_delete(path);
lv_draw_vector_dsc_delete(dsc);
To see all the path, stroke, and fill options, check out `lv_draw_vector.h <https://github.com/lvgl/lvgl/blob/master/src/draw/lv_draw_vector.h>`__ .
Masking Operation
*****************