| ThorVG v0.9

thorvg_capi.h
1
18 #ifndef __THORVG_CAPI_H__
19 #define __THORVG_CAPI_H__
20
21 #include <stdint.h>
22 #include <stdbool.h>
23
24 #ifdef TVG_API
25 #undef TVG_API
26 #endif
27
28 #if defined(_WIN32) && !defined(__clang__)
29 #if TVG_BUILD
30 #if TVG_EXPORT
31 #define TVG_API __declspec(dllexport)
32 #else
33 #define TVG_API
34 #endif
35 #else
36 #define TVG_API __declspec(dllimport)
37 #endif
38 #define TVG_DEPRECATED __declspec(deprecated)
39 #else
40 #if TVG_BUILD
41 #if TVG_EXPORT
42 #define TVG_API __attribute__ ((visibility ("default")))
43 #else
44 #define TVG_API
45 #endif
46 #else
47 #define TVG_API
48 #endif
49 #define TVG_DEPRECATED __attribute__ ((__deprecated__))
50 #endif
51
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55
69 typedef struct _Tvg_Canvas Tvg_Canvas;
70
71
77 typedef struct _Tvg_Paint Tvg_Paint;
78
79
83 typedef struct _Tvg_Gradient Tvg_Gradient;
84
85
89 typedef struct _Tvg_Saver Tvg_Saver;
90
91
97 typedef enum {
98 TVG_ENGINE_SW = (1 << 1),
99 TVG_ENGINE_GL = (1 << 2)
100 } Tvg_Engine;
101
102
106 typedef enum {
107 TVG_RESULT_SUCCESS = 0,
108 TVG_RESULT_INVALID_ARGUMENT,
109 TVG_RESULT_INSUFFICIENT_CONDITION,
110 TVG_RESULT_FAILED_ALLOCATION,
111 TVG_RESULT_MEMORY_CORRUPTION,
112 TVG_RESULT_NOT_SUPPORTED,
113 TVG_RESULT_UNKNOWN
114 } Tvg_Result;
115
116
122 typedef enum {
123 TVG_COMPOSITE_METHOD_NONE = 0,
124 TVG_COMPOSITE_METHOD_CLIP_PATH,
125 TVG_COMPOSITE_METHOD_ALPHA_MASK,
126 TVG_COMPOSITE_METHOD_INVERSE_ALPHA_MASK,
127 TVG_COMPOSITE_METHOD_LUMA_MASK
128 } Tvg_Composite_Method;
129
130
138 typedef enum {
139 TVG_IDENTIFIER_UNDEF = 0,
140 TVG_IDENTIFIER_SHAPE,
141 TVG_IDENTIFIER_SCENE,
142 TVG_IDENTIFIER_PICTURE,
143 TVG_IDENTIFIER_LINEAR_GRAD,
144 TVG_IDENTIFIER_RADIAL_GRAD
145 } Tvg_Identifier;
146
147
159 typedef enum {
160 TVG_PATH_COMMAND_CLOSE = 0,
161 TVG_PATH_COMMAND_MOVE_TO,
162 TVG_PATH_COMMAND_LINE_TO,
163 TVG_PATH_COMMAND_CUBIC_TO
164 } Tvg_Path_Command;
165
166
170 typedef enum {
171 TVG_STROKE_CAP_SQUARE = 0,
172 TVG_STROKE_CAP_ROUND,
173 TVG_STROKE_CAP_BUTT
174 } Tvg_Stroke_Cap;
175
176
180 typedef enum {
181 TVG_STROKE_JOIN_BEVEL = 0,
182 TVG_STROKE_JOIN_ROUND,
183 TVG_STROKE_JOIN_MITER
184 } Tvg_Stroke_Join;
185
186
190 typedef enum {
191 TVG_STROKE_FILL_PAD = 0,
192 TVG_STROKE_FILL_REFLECT,
193 TVG_STROKE_FILL_REPEAT
194 } Tvg_Stroke_Fill;
195
196
200 typedef enum {
201 TVG_FILL_RULE_WINDING = 0,
202 TVG_FILL_RULE_EVEN_ODD
203 } Tvg_Fill_Rule;
204 // end addtogroup ThorVGCapi_Shape
206
207
216 typedef struct
217 {
218 float offset;
219 uint8_t r;
220 uint8_t g;
221 uint8_t b;
222 uint8_t a;
223 } Tvg_Color_Stop;
224 // end addtogroup ThorVGCapi_Gradient
226
227
231 typedef struct
232 {
233 float x, y;
234 } Tvg_Point;
235
236
244 typedef struct
245 {
246 float e11, e12, e13;
247 float e21, e22, e23;
248 float e31, e32, e33;
249 } Tvg_Matrix;
250
251
259 /************************************************************************/
260 /* Engine API */
261 /************************************************************************/
290 TVG_API Tvg_Result tvg_engine_init(Tvg_Engine engine_method, unsigned threads);
291
292
318 TVG_API Tvg_Result tvg_engine_term(Tvg_Engine engine_method);
319
320 // end defgroup ThorVGCapi_Initializer
322
323
345 /************************************************************************/
346 /* SwCanvas API */
347 /************************************************************************/
348
352 typedef enum {
353 TVG_MEMPOOL_POLICY_DEFAULT = 0,
354 TVG_MEMPOOL_POLICY_SHAREABLE,
355 TVG_MEMPOOL_POLICY_INDIVIDUAL
356 } Tvg_Mempool_Policy;
357
358
362 typedef enum {
363 TVG_COLORSPACE_ABGR8888 = 0,
364 TVG_COLORSPACE_ARGB8888
365 } Tvg_Colorspace;
366
367
392 TVG_API Tvg_Canvas* tvg_swcanvas_create();
393
394
420 TVG_API Tvg_Result tvg_swcanvas_set_target(Tvg_Canvas* canvas, uint32_t* buffer, uint32_t stride, uint32_t w, uint32_t h, Tvg_Colorspace cs);
421
422
447 TVG_API Tvg_Result tvg_swcanvas_set_mempool(Tvg_Canvas* canvas, Tvg_Mempool_Policy policy);
448 // end defgroup ThorVGCapi_SwCanvas
450
451
452 /************************************************************************/
453 /* Common Canvas API */
454 /************************************************************************/
516 TVG_API Tvg_Result tvg_canvas_destroy(Tvg_Canvas* canvas);
517
518
537 TVG_API Tvg_Result tvg_canvas_push(Tvg_Canvas* canvas, Tvg_Paint* paint);
538
539
571 TVG_API Tvg_Result tvg_canvas_reserve(Tvg_Canvas* canvas, uint32_t n);
572
573
591 TVG_API Tvg_Result tvg_canvas_clear(Tvg_Canvas* canvas, bool free);
592
593
651 TVG_API Tvg_Result tvg_canvas_update(Tvg_Canvas* canvas);
652
653
669 TVG_API Tvg_Result tvg_canvas_update_paint(Tvg_Canvas* canvas, Tvg_Paint* paint);
670
671
687 TVG_API Tvg_Result tvg_canvas_draw(Tvg_Canvas* canvas);
688
689
704 TVG_API Tvg_Result tvg_canvas_sync(Tvg_Canvas* canvas);
705
706 // end defgroup ThorVGCapi_Canvas
708
709
717 /************************************************************************/
718 /* Paint API */
719 /************************************************************************/
750 TVG_API Tvg_Result tvg_paint_del(Tvg_Paint* paint);
751
752
764 TVG_API Tvg_Result tvg_paint_scale(Tvg_Paint* paint, float factor);
765
766
781 TVG_API Tvg_Result tvg_paint_rotate(Tvg_Paint* paint, float degree);
782
783
799 TVG_API Tvg_Result tvg_paint_translate(Tvg_Paint* paint, float x, float y);
800
801
815 TVG_API Tvg_Result tvg_paint_set_transform(Tvg_Paint* paint, const Tvg_Matrix* m);
816
817
830 TVG_API Tvg_Result tvg_paint_get_transform(Tvg_Paint* paint, Tvg_Matrix* m);
831
832
845 TVG_API Tvg_Result tvg_paint_set_opacity(Tvg_Paint* paint, uint8_t opacity);
846
847
858 TVG_API Tvg_Result tvg_paint_get_opacity(const Tvg_Paint* paint, uint8_t* opacity);
859
860
870 TVG_API Tvg_Paint* tvg_paint_duplicate(Tvg_Paint* paint);
871
872
890 TVG_API Tvg_Result tvg_paint_get_bounds(const Tvg_Paint* paint, float* x, float* y, float* w, float* h, bool transformed);
891
892
904 TVG_API Tvg_Result tvg_paint_set_composite_method(Tvg_Paint* paint, Tvg_Paint* target, Tvg_Composite_Method method);
905
906
918 TVG_API Tvg_Result tvg_paint_get_composite_method(const Tvg_Paint* paint, const Tvg_Paint** target, Tvg_Composite_Method* method);
919
920
933 TVG_API Tvg_Result tvg_paint_get_identifier(const Tvg_Paint* paint, Tvg_Identifier* identifier); // end defgroup ThorVGCapi_Paint
935
936
952 /************************************************************************/
953 /* Shape API */
954 /************************************************************************/
960 TVG_API Tvg_Paint* tvg_shape_new();
961
962
976 TVG_API Tvg_Result tvg_shape_reset(Tvg_Paint* paint);
977
978
992 TVG_API Tvg_Result tvg_shape_move_to(Tvg_Paint* paint, float x, float y);
993
994
1010 TVG_API Tvg_Result tvg_shape_line_to(Tvg_Paint* paint, float x, float y);
1011
1012
1033 TVG_API Tvg_Result tvg_shape_cubic_to(Tvg_Paint* paint, float cx1, float cy1, float cx2, float cy2, float x, float y);
1034
1035
1049 TVG_API Tvg_Result tvg_shape_close(Tvg_Paint* paint);
1050
1051
1079 TVG_API Tvg_Result tvg_shape_append_rect(Tvg_Paint* paint, float x, float y, float w, float h, float rx, float ry);
1080
1081
1101 TVG_API Tvg_Result tvg_shape_append_circle(Tvg_Paint* paint, float cx, float cy, float rx, float ry);
1102
1103
1124 TVG_API Tvg_Result tvg_shape_append_arc(Tvg_Paint* paint, float cx, float cy, float radius, float startAngle, float sweep, uint8_t pie);
1125
1126
1144 TVG_API Tvg_Result tvg_shape_append_path(Tvg_Paint* paint, const Tvg_Path_Command* cmds, uint32_t cmdCnt, const Tvg_Point* pts, uint32_t ptsCnt);
1145
1146
1170 TVG_API Tvg_Result tvg_shape_get_path_coords(const Tvg_Paint* paint, const Tvg_Point** pts, uint32_t* cnt);
1171
1172
1196 TVG_API Tvg_Result tvg_shape_get_path_commands(const Tvg_Paint* paint, const Tvg_Path_Command** cmds, uint32_t* cnt);
1197
1198
1210 TVG_API Tvg_Result tvg_shape_set_stroke_width(Tvg_Paint* paint, float width);
1211
1212
1223 TVG_API Tvg_Result tvg_shape_get_stroke_width(const Tvg_Paint* paint, float* width);
1224
1225
1242 TVG_API Tvg_Result tvg_shape_set_stroke_color(Tvg_Paint* paint, uint8_t r, uint8_t g, uint8_t b, uint8_t a);
1243
1244
1259 TVG_API Tvg_Result tvg_shape_get_stroke_color(const Tvg_Paint* paint, uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a);
1260
1261
1276 TVG_API Tvg_Result tvg_shape_set_stroke_linear_gradient(Tvg_Paint* paint, Tvg_Gradient* grad);
1277
1278
1293 TVG_API Tvg_Result tvg_shape_set_stroke_radial_gradient(Tvg_Paint* paint, Tvg_Gradient* grad);
1294
1295
1308 TVG_API Tvg_Result tvg_shape_get_stroke_gradient(const Tvg_Paint* paint, Tvg_Gradient** grad);
1309
1310
1332 TVG_API Tvg_Result tvg_shape_set_stroke_dash(Tvg_Paint* paint, const float* dashPattern, uint32_t cnt);
1333
1334
1348 TVG_API Tvg_Result tvg_shape_get_stroke_dash(const Tvg_Paint* paint, const float** dashPattern, uint32_t* cnt);
1349
1350
1364 TVG_API Tvg_Result tvg_shape_set_stroke_cap(Tvg_Paint* paint, Tvg_Stroke_Cap cap);
1365
1366
1377 TVG_API Tvg_Result tvg_shape_get_stroke_cap(const Tvg_Paint* paint, Tvg_Stroke_Cap* cap);
1378
1379
1391 TVG_API Tvg_Result tvg_shape_set_stroke_join(Tvg_Paint* paint, Tvg_Stroke_Join join);
1392
1393
1404 TVG_API Tvg_Result tvg_shape_get_stroke_join(const Tvg_Paint* paint, Tvg_Stroke_Join* join);
1405
1406
1425 TVG_API Tvg_Result tvg_shape_set_fill_color(Tvg_Paint* paint, uint8_t r, uint8_t g, uint8_t b, uint8_t a);
1426
1427
1441 TVG_API Tvg_Result tvg_shape_get_fill_color(const Tvg_Paint* paint, uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a);
1442
1443
1454 TVG_API Tvg_Result tvg_shape_set_fill_rule(Tvg_Paint* paint, Tvg_Fill_Rule rule);
1455
1456
1467 TVG_API Tvg_Result tvg_shape_get_fill_rule(const Tvg_Paint* paint, Tvg_Fill_Rule* rule);
1468
1469
1500 TVG_API Tvg_Result tvg_shape_set_linear_gradient(Tvg_Paint* paint, Tvg_Gradient* grad);
1501
1502
1533 TVG_API Tvg_Result tvg_shape_set_radial_gradient(Tvg_Paint* paint, Tvg_Gradient* grad);
1534
1535
1548 TVG_API Tvg_Result tvg_shape_get_gradient(const Tvg_Paint* paint, Tvg_Gradient** grad);
1549
1550 // end defgroup ThorVGCapi_Shape
1552
1553
1565 /************************************************************************/
1566 /* Gradient API */
1567 /************************************************************************/
1587 TVG_API Tvg_Gradient* tvg_linear_gradient_new();
1588
1589
1609 TVG_API Tvg_Gradient* tvg_radial_gradient_new();
1610
1611
1631 TVG_API Tvg_Result tvg_linear_gradient_set(Tvg_Gradient* grad, float x1, float y1, float x2, float y2);
1632
1633
1651 TVG_API Tvg_Result tvg_linear_gradient_get(Tvg_Gradient* grad, float* x1, float* y1, float* x2, float* y2);
1652
1653
1668 TVG_API Tvg_Result tvg_radial_gradient_set(Tvg_Gradient* grad, float cx, float cy, float radius);
1669
1670
1683 TVG_API Tvg_Result tvg_radial_gradient_get(Tvg_Gradient* grad, float* cx, float* cy, float* radius);
1684
1685
1697 TVG_API Tvg_Result tvg_gradient_set_color_stops(Tvg_Gradient* grad, const Tvg_Color_Stop* color_stop, uint32_t cnt);
1698
1699
1713 TVG_API Tvg_Result tvg_gradient_get_color_stops(const Tvg_Gradient* grad, const Tvg_Color_Stop** color_stop, uint32_t* cnt);
1714
1715
1726 TVG_API Tvg_Result tvg_gradient_set_spread(Tvg_Gradient* grad, const Tvg_Stroke_Fill spread);
1727
1728
1739 TVG_API Tvg_Result tvg_gradient_get_spread(const Tvg_Gradient* grad, Tvg_Stroke_Fill* spread);
1740
1741
1755 TVG_API Tvg_Result tvg_gradient_set_transform(Tvg_Gradient* grad, const Tvg_Matrix* m);
1756
1757
1770 TVG_API Tvg_Result tvg_gradient_get_transform(const Tvg_Gradient* grad, Tvg_Matrix* m);
1771
1784 TVG_API Tvg_Result tvg_gradient_get_identifier(const Tvg_Gradient* grad, Tvg_Identifier* identifier);
1785
1786
1796 TVG_API Tvg_Gradient* tvg_gradient_duplicate(Tvg_Gradient* grad);
1797
1798
1808 TVG_API Tvg_Result tvg_gradient_del(Tvg_Gradient* grad);
1809
1810 // end defgroup ThorVGCapi_Gradient
1812
1813
1823 /************************************************************************/
1824 /* Picture API */
1825 /************************************************************************/
1831 TVG_API Tvg_Paint* tvg_picture_new();
1832
1833
1846 TVG_API Tvg_Result tvg_picture_load(Tvg_Paint* paint, const char* path);
1847
1848
1860 TVG_API Tvg_Result tvg_picture_load_raw(Tvg_Paint* paint, uint32_t *data, uint32_t w, uint32_t h, bool copy);
1861
1862
1880 TVG_API Tvg_Result tvg_picture_load_data(Tvg_Paint* paint, const char *data, uint32_t size, const char *mimetype, bool copy);
1881
1882
1898 TVG_API Tvg_Result tvg_picture_set_size(Tvg_Paint* paint, float w, float h);
1899
1900
1912 TVG_API Tvg_Result tvg_picture_get_size(const Tvg_Paint* paint, float* w, float* h);
1913
1914
1920 TVG_API Tvg_Result tvg_picture_get_viewbox(const Tvg_Paint* paint, float* x, float* y, float* w, float* h);
1921
1922 // end defgroup ThorVGCapi_Picture
1924
1925
1936 /************************************************************************/
1937 /* Scene API */
1938 /************************************************************************/
1946 TVG_API Tvg_Paint* tvg_scene_new();
1947
1948
1963 TVG_API Tvg_Result tvg_scene_reserve(Tvg_Paint* scene, uint32_t size);
1964
1965
1984 TVG_API Tvg_Result tvg_scene_push(Tvg_Paint* scene, Tvg_Paint* paint);
1985
1986
2002 TVG_API Tvg_Result tvg_scene_clear(Tvg_Paint* scene, bool free);
2003 // end defgroup ThorVGCapi_Scene
2005
2006
2017 /************************************************************************/
2018 /* Saver API */
2019 /************************************************************************/
2025 TVG_API Tvg_Saver* tvg_saver_new();
2026
2027
2051 TVG_API Tvg_Result tvg_saver_save(Tvg_Saver* saver, Tvg_Paint* paint, const char* path, bool compress);
2052
2053
2071 TVG_API Tvg_Result tvg_saver_sync(Tvg_Saver* saver);
2072
2073
2083 TVG_API Tvg_Result tvg_saver_del(Tvg_Saver* saver);
2084
2085 // end defgroup ThorVGCapi_Saver
2087
2088 // end defgroup ThorVG_CAPI
2090
2091
2092 #ifdef __cplusplus
2093 }
2094 #endif
2095
2096 #endif //_THORVG_CAPI_H_
tvg_canvas_destroy
TVG_API Tvg_Result tvg_canvas_destroy(Tvg_Canvas *canvas)
Clears the canvas internal data, releases all paints stored by the canvas and destroys the canvas obj...
tvg_canvas_reserve
TVG_API Tvg_Result tvg_canvas_reserve(Tvg_Canvas *canvas, uint32_t n)
Reserves a memory block where the objects pushed into a canvas are stored.
tvg_canvas_push
TVG_API Tvg_Result tvg_canvas_push(Tvg_Canvas *canvas, Tvg_Paint *paint)
Inserts a drawing element into the canvas using a Tvg_Paint object.
tvg_canvas_clear
TVG_API Tvg_Result tvg_canvas_clear(Tvg_Canvas *canvas, bool free)
Sets the total number of the paints pushed into the canvas to be zero. Tvg_Paint objects stored in th...
tvg_canvas_sync
TVG_API Tvg_Result tvg_canvas_sync(Tvg_Canvas *canvas)
Guarantees that the drawing process is finished.
tvg_canvas_update_paint
TVG_API Tvg_Result tvg_canvas_update_paint(Tvg_Canvas *canvas, Tvg_Paint *paint)
Updates the given Tvg_Paint object from the canvas before the rendering.
tvg_canvas_update
TVG_API Tvg_Result tvg_canvas_update(Tvg_Canvas *canvas)
Updates all paints in a canvas.
tvg_canvas_draw
TVG_API Tvg_Result tvg_canvas_draw(Tvg_Canvas *canvas)
Requests the canvas to draw the Tvg_Paint objects.
tvg_gradient_duplicate
TVG_API Tvg_Gradient * tvg_gradient_duplicate(Tvg_Gradient *grad)
Duplicates the given Tvg_Gradient object.
tvg_gradient_get_identifier
TVG_API Tvg_Result tvg_gradient_get_identifier(const Tvg_Gradient *grad, Tvg_Identifier *identifier)
Gets the unique id value of the gradient instance indicating the instance type.
tvg_linear_gradient_new
TVG_API Tvg_Gradient * tvg_linear_gradient_new()
Creates a new linear gradient object.
tvg_gradient_set_transform
TVG_API Tvg_Result tvg_gradient_set_transform(Tvg_Gradient *grad, const Tvg_Matrix *m)
Sets the matrix of the affine transformation for the gradient object.
tvg_linear_gradient_set
TVG_API Tvg_Result tvg_linear_gradient_set(Tvg_Gradient *grad, float x1, float y1, float x2, float y2)
Sets the linear gradient bounds.
tvg_gradient_get_spread
TVG_API Tvg_Result tvg_gradient_get_spread(const Tvg_Gradient *grad, Tvg_Stroke_Fill *spread)
Gets the FillSpread value of the gradient object.
tvg_radial_gradient_new
TVG_API Tvg_Gradient * tvg_radial_gradient_new()
Creates a new radial gradient object.
tvg_gradient_del
TVG_API Tvg_Result tvg_gradient_del(Tvg_Gradient *grad)
Deletes the given gradient object.
tvg_gradient_get_color_stops
TVG_API Tvg_Result tvg_gradient_get_color_stops(const Tvg_Gradient *grad, const Tvg_Color_Stop **color_stop, uint32_t *cnt)
Gets the parameters of the colors of the gradient, their position and number.
tvg_gradient_set_spread
TVG_API Tvg_Result tvg_gradient_set_spread(Tvg_Gradient *grad, const Tvg_Stroke_Fill spread)
Sets the Tvg_Stroke_Fill value, which specifies how to fill the area outside the gradient bounds.
tvg_radial_gradient_get
TVG_API Tvg_Result tvg_radial_gradient_get(Tvg_Gradient *grad, float *cx, float *cy, float *radius)
The function gets radial gradient center point ant radius.
tvg_linear_gradient_get
TVG_API Tvg_Result tvg_linear_gradient_get(Tvg_Gradient *grad, float *x1, float *y1, float *x2, float *y2)
Gets the linear gradient bounds.
tvg_gradient_set_color_stops
TVG_API Tvg_Result tvg_gradient_set_color_stops(Tvg_Gradient *grad, const Tvg_Color_Stop *color_stop, uint32_t cnt)
Sets the parameters of the colors of the gradient and their position.
tvg_gradient_get_transform
TVG_API Tvg_Result tvg_gradient_get_transform(const Tvg_Gradient *grad, Tvg_Matrix *m)
Gets the matrix of the affine transformation of the gradient object.
tvg_radial_gradient_set
TVG_API Tvg_Result tvg_radial_gradient_set(Tvg_Gradient *grad, float cx, float cy, float radius)
Sets the radial gradient bounds.
tvg_engine_init
TVG_API Tvg_Result tvg_engine_init(Tvg_Engine engine_method, unsigned threads)
Initializes TVG engines.
Tvg_Engine
Tvg_Engine
Enumeration specifying the engine type used for the graphics backend. For multiple backends bitwise o...
Definition: thorvg_capi.h:97
tvg_engine_term
TVG_API Tvg_Result tvg_engine_term(Tvg_Engine engine_method)
Terminates TVG engines.
TVG_ENGINE_GL
@ TVG_ENGINE_GL
OpenGL rasterizer.
Definition: thorvg_capi.h:99
TVG_ENGINE_SW
@ TVG_ENGINE_SW
CPU rasterizer.
Definition: thorvg_capi.h:98
tvg_paint_get_bounds
TVG_API Tvg_Result tvg_paint_get_bounds(const Tvg_Paint *paint, float *x, float *y, float *w, float *h, bool transformed)
Gets the axis-aligned bounding box of the Tvg_Paint object.
tvg_paint_translate
TVG_API Tvg_Result tvg_paint_translate(Tvg_Paint *paint, float x, float y)
Moves the given Tvg_Paint in a two-dimensional space.
Tvg_Composite_Method
Tvg_Composite_Method
Enumeration indicating the method used in the composition of two objects - the target and the source.
Definition: thorvg_capi.h:122
tvg_paint_set_transform
TVG_API Tvg_Result tvg_paint_set_transform(Tvg_Paint *paint, const Tvg_Matrix *m)
Transforms the given Tvg_Paint using the augmented transformation matrix.
tvg_paint_set_composite_method
TVG_API Tvg_Result tvg_paint_set_composite_method(Tvg_Paint *paint, Tvg_Paint *target, Tvg_Composite_Method method)
Sets the composition target object and the composition method.
tvg_paint_get_composite_method
TVG_API Tvg_Result tvg_paint_get_composite_method(const Tvg_Paint *paint, const Tvg_Paint **target, Tvg_Composite_Method *method)
Gets the composition target object and the composition method.
tvg_paint_del
TVG_API Tvg_Result tvg_paint_del(Tvg_Paint *paint)
Releases the given Tvg_Paint object.
tvg_paint_get_opacity
TVG_API Tvg_Result tvg_paint_get_opacity(const Tvg_Paint *paint, uint8_t *opacity)
Gets the opacity of the given Tvg_Paint.
tvg_paint_set_opacity
TVG_API Tvg_Result tvg_paint_set_opacity(Tvg_Paint *paint, uint8_t opacity)
Sets the opacity of the given Tvg_Paint.
tvg_paint_duplicate
TVG_API Tvg_Paint * tvg_paint_duplicate(Tvg_Paint *paint)
Duplicates the given Tvg_Paint object.
tvg_paint_get_identifier
TVG_API Tvg_Result tvg_paint_get_identifier(const Tvg_Paint *paint, Tvg_Identifier *identifier)
Gets the unique id value of the paint instance indicating the instance type.
Tvg_Identifier
Tvg_Identifier
Enumeration indicating the ThorVG class type.
Definition: thorvg_capi.h:138
tvg_paint_rotate
TVG_API Tvg_Result tvg_paint_rotate(Tvg_Paint *paint, float degree)
Rotates the given Tvg_Paint by the given angle.
tvg_paint_get_transform
TVG_API Tvg_Result tvg_paint_get_transform(Tvg_Paint *paint, Tvg_Matrix *m)
Gets the matrix of the affine transformation of the given Tvg_Paint object.
tvg_paint_scale
TVG_API Tvg_Result tvg_paint_scale(Tvg_Paint *paint, float factor)
Scales the given Tvg_Paint object by the given factor.
TVG_COMPOSITE_METHOD_LUMA_MASK
@ TVG_COMPOSITE_METHOD_LUMA_MASK
The source pixels are converted to grayscale (luma value) and alpha blended with the target....
Definition: thorvg_capi.h:127
TVG_COMPOSITE_METHOD_CLIP_PATH
@ TVG_COMPOSITE_METHOD_CLIP_PATH
The intersection of the source and the target is determined and only the resulting pixels from the so...
Definition: thorvg_capi.h:124
TVG_COMPOSITE_METHOD_NONE
@ TVG_COMPOSITE_METHOD_NONE
No composition is applied.
Definition: thorvg_capi.h:123
TVG_COMPOSITE_METHOD_ALPHA_MASK
@ TVG_COMPOSITE_METHOD_ALPHA_MASK
The pixels of the source and the target are alpha blended. As a result, only the part of the source,...
Definition: thorvg_capi.h:125
TVG_COMPOSITE_METHOD_INVERSE_ALPHA_MASK
@ TVG_COMPOSITE_METHOD_INVERSE_ALPHA_MASK
The pixels of the source and the complement to the target's pixels are alpha blended....
Definition: thorvg_capi.h:126
TVG_IDENTIFIER_SHAPE
@ TVG_IDENTIFIER_SHAPE
A shape type paint.
Definition: thorvg_capi.h:140
TVG_IDENTIFIER_PICTURE
@ TVG_IDENTIFIER_PICTURE
A picture type paint.
Definition: thorvg_capi.h:142
TVG_IDENTIFIER_UNDEF
@ TVG_IDENTIFIER_UNDEF
Undefined type.
Definition: thorvg_capi.h:139
TVG_IDENTIFIER_RADIAL_GRAD
@ TVG_IDENTIFIER_RADIAL_GRAD
A radial gradient type.
Definition: thorvg_capi.h:144
TVG_IDENTIFIER_SCENE
@ TVG_IDENTIFIER_SCENE
A scene type paint.
Definition: thorvg_capi.h:141
TVG_IDENTIFIER_LINEAR_GRAD
@ TVG_IDENTIFIER_LINEAR_GRAD
A linear gradient type.
Definition: thorvg_capi.h:143
tvg_picture_get_viewbox
TVG_API Tvg_Result tvg_picture_get_viewbox(const Tvg_Paint *paint, float *x, float *y, float *w, float *h)
Gets the position and the size of the loaded picture. (BETA_API)
tvg_picture_load_data
TVG_API Tvg_Result tvg_picture_load_data(Tvg_Paint *paint, const char *data, uint32_t size, const char *mimetype, bool copy)
Loads a picture data from a memory block of a given size.
tvg_picture_load
TVG_API Tvg_Result tvg_picture_load(Tvg_Paint *paint, const char *path)
Loads a picture data directly from a file.
tvg_picture_get_size
TVG_API Tvg_Result tvg_picture_get_size(const Tvg_Paint *paint, float *w, float *h)
Gets the size of the loaded picture.
tvg_picture_load_raw
TVG_API Tvg_Result tvg_picture_load_raw(Tvg_Paint *paint, uint32_t *data, uint32_t w, uint32_t h, bool copy)
Loads a picture data from a memory block of a given size. (BETA_API)
tvg_picture_new
TVG_API Tvg_Paint * tvg_picture_new()
Creates a new picture object.
tvg_picture_set_size
TVG_API Tvg_Result tvg_picture_set_size(Tvg_Paint *paint, float w, float h)
Resizes the picture content to the given width and height.
tvg_saver_sync
TVG_API Tvg_Result tvg_saver_sync(Tvg_Saver *saver)
Guarantees that the saving task is finished.
tvg_saver_save
TVG_API Tvg_Result tvg_saver_save(Tvg_Saver *saver, Tvg_Paint *paint, const char *path, bool compress)
Exports the given paint data to the given path.
tvg_saver_del
TVG_API Tvg_Result tvg_saver_del(Tvg_Saver *saver)
Deletes the given Tvg_Saver object.
tvg_saver_new
TVG_API Tvg_Saver * tvg_saver_new()
Creates a new Tvg_Saver object.
tvg_scene_reserve
TVG_API Tvg_Result tvg_scene_reserve(Tvg_Paint *scene, uint32_t size)
Sets the size of the container, where all the paints pushed into the scene are stored.
tvg_scene_new
TVG_API Tvg_Paint * tvg_scene_new()
Creates a new scene object.
tvg_scene_clear
TVG_API Tvg_Result tvg_scene_clear(Tvg_Paint *scene, bool free)
Clears a Tvg_Scene objects from pushed paints.
tvg_scene_push
TVG_API Tvg_Result tvg_scene_push(Tvg_Paint *scene, Tvg_Paint *paint)
Passes drawing elements to the scene using Tvg_Paint objects.
tvg_shape_set_fill_rule
TVG_API Tvg_Result tvg_shape_set_fill_rule(Tvg_Paint *paint, Tvg_Fill_Rule rule)
Sets the shape's fill rule.
tvg_shape_get_path_commands
TVG_API Tvg_Result tvg_shape_get_path_commands(const Tvg_Paint *paint, const Tvg_Path_Command **cmds, uint32_t *cnt)
Gets the commands data of the path.
tvg_shape_append_rect
TVG_API Tvg_Result tvg_shape_append_rect(Tvg_Paint *paint, float x, float y, float w, float h, float rx, float ry)
Appends a rectangle to the path.
Tvg_Path_Command
Tvg_Path_Command
Enumeration specifying the values of the path commands accepted by TVG.
Definition: thorvg_capi.h:159
tvg_shape_get_path_coords
TVG_API Tvg_Result tvg_shape_get_path_coords(const Tvg_Paint *paint, const Tvg_Point **pts, uint32_t *cnt)
Gets the points values of the path.
tvg_shape_line_to
TVG_API Tvg_Result tvg_shape_line_to(Tvg_Paint *paint, float x, float y)
Adds a new point to the sub-path, which results in drawing a line from the current point to the given...
tvg_shape_set_fill_color
TVG_API Tvg_Result tvg_shape_set_fill_color(Tvg_Paint *paint, uint8_t r, uint8_t g, uint8_t b, uint8_t a)
Sets the shape's solid color.
tvg_shape_get_stroke_width
TVG_API Tvg_Result tvg_shape_get_stroke_width(const Tvg_Paint *paint, float *width)
Gets the shape's stroke width.
tvg_shape_get_fill_color
TVG_API Tvg_Result tvg_shape_get_fill_color(const Tvg_Paint *paint, uint8_t *r, uint8_t *g, uint8_t *b, uint8_t *a)
Gets the shape's solid color.
tvg_shape_get_gradient
TVG_API Tvg_Result tvg_shape_get_gradient(const Tvg_Paint *paint, Tvg_Gradient **grad)
Gets the gradient fill of the shape.
tvg_shape_set_stroke_radial_gradient
TVG_API Tvg_Result tvg_shape_set_stroke_radial_gradient(Tvg_Paint *paint, Tvg_Gradient *grad)
Sets the radial gradient fill of the stroke for all of the figures from the path.
Tvg_Stroke_Cap
Tvg_Stroke_Cap
Enumeration determining the ending type of a stroke in the open sub-paths.
Definition: thorvg_capi.h:170
tvg_shape_append_path
TVG_API Tvg_Result tvg_shape_append_path(Tvg_Paint *paint, const Tvg_Path_Command *cmds, uint32_t cmdCnt, const Tvg_Point *pts, uint32_t ptsCnt)
Appends a given sub-path to the path.
tvg_shape_set_stroke_dash
TVG_API Tvg_Result tvg_shape_set_stroke_dash(Tvg_Paint *paint, const float *dashPattern, uint32_t cnt)
Sets the shape's stroke dash pattern.
tvg_shape_set_linear_gradient
TVG_API Tvg_Result tvg_shape_set_linear_gradient(Tvg_Paint *paint, Tvg_Gradient *grad)
Sets the linear gradient fill for all of the figures from the path.
tvg_shape_set_stroke_linear_gradient
TVG_API Tvg_Result tvg_shape_set_stroke_linear_gradient(Tvg_Paint *paint, Tvg_Gradient *grad)
Sets the linear gradient fill of the stroke for all of the figures from the path.
tvg_shape_set_stroke_cap
TVG_API Tvg_Result tvg_shape_set_stroke_cap(Tvg_Paint *paint, Tvg_Stroke_Cap cap)
Sets the cap style used for stroking the path.
tvg_shape_set_stroke_join
TVG_API Tvg_Result tvg_shape_set_stroke_join(Tvg_Paint *paint, Tvg_Stroke_Join join)
Sets the join style for stroked path segments.
tvg_shape_append_circle
TVG_API Tvg_Result tvg_shape_append_circle(Tvg_Paint *paint, float cx, float cy, float rx, float ry)
Appends an ellipse to the path.
tvg_shape_get_stroke_color
TVG_API Tvg_Result tvg_shape_get_stroke_color(const Tvg_Paint *paint, uint8_t *r, uint8_t *g, uint8_t *b, uint8_t *a)
Gets the shape's stroke color.
tvg_shape_set_stroke_width
TVG_API Tvg_Result tvg_shape_set_stroke_width(Tvg_Paint *paint, float width)
Sets the stroke width for all of the figures from the paint.
Tvg_Stroke_Fill
Tvg_Stroke_Fill
Enumeration specifying how to fill the area outside the gradient bounds.
Definition: thorvg_capi.h:190
tvg_shape_close
TVG_API Tvg_Result tvg_shape_close(Tvg_Paint *paint)
Closes the current sub-path by drawing a line from the current point to the initial point of the sub-...
tvg_shape_set_radial_gradient
TVG_API Tvg_Result tvg_shape_set_radial_gradient(Tvg_Paint *paint, Tvg_Gradient *grad)
Sets the radial gradient fill for all of the figures from the path.
tvg_shape_new
TVG_API Tvg_Paint * tvg_shape_new()
Creates a new shape object.
tvg_shape_get_fill_rule
TVG_API Tvg_Result tvg_shape_get_fill_rule(const Tvg_Paint *paint, Tvg_Fill_Rule *rule)
Gets the shape's fill rule.
tvg_shape_append_arc
TVG_API Tvg_Result tvg_shape_append_arc(Tvg_Paint *paint, float cx, float cy, float radius, float startAngle, float sweep, uint8_t pie)
Appends a circular arc to the path.
tvg_shape_cubic_to
TVG_API Tvg_Result tvg_shape_cubic_to(Tvg_Paint *paint, float cx1, float cy1, float cx2, float cy2, float x, float y)
Adds new points to the sub-path, which results in drawing a cubic Bezier curve.
tvg_shape_get_stroke_gradient
TVG_API Tvg_Result tvg_shape_get_stroke_gradient(const Tvg_Paint *paint, Tvg_Gradient **grad)
Gets the gradient fill of the shape's stroke.
tvg_shape_set_stroke_color
TVG_API Tvg_Result tvg_shape_set_stroke_color(Tvg_Paint *paint, uint8_t r, uint8_t g, uint8_t b, uint8_t a)
Sets the shape's stroke color.
tvg_shape_reset
TVG_API Tvg_Result tvg_shape_reset(Tvg_Paint *paint)
Resets the shape path properties.
tvg_shape_move_to
TVG_API Tvg_Result tvg_shape_move_to(Tvg_Paint *paint, float x, float y)
Sets the initial point of the sub-path.
tvg_shape_get_stroke_cap
TVG_API Tvg_Result tvg_shape_get_stroke_cap(const Tvg_Paint *paint, Tvg_Stroke_Cap *cap)
Gets the stroke cap style used for stroking the path.
tvg_shape_get_stroke_join
TVG_API Tvg_Result tvg_shape_get_stroke_join(const Tvg_Paint *paint, Tvg_Stroke_Join *join)
The function gets the stroke join method.
Tvg_Stroke_Join
Tvg_Stroke_Join
Enumeration specifying how to fill the area outside the gradient bounds.
Definition: thorvg_capi.h:180
tvg_shape_get_stroke_dash
TVG_API Tvg_Result tvg_shape_get_stroke_dash(const Tvg_Paint *paint, const float **dashPattern, uint32_t *cnt)
Gets the dash pattern of the stroke.
Tvg_Fill_Rule
Tvg_Fill_Rule
Enumeration specifying the algorithm used to establish which parts of the shape are treated as the in...
Definition: thorvg_capi.h:200
TVG_PATH_COMMAND_CUBIC_TO
@ TVG_PATH_COMMAND_CUBIC_TO
Draws a cubic Bezier curve from the current point to the given point using two given control points a...
Definition: thorvg_capi.h:163
TVG_PATH_COMMAND_CLOSE
@ TVG_PATH_COMMAND_CLOSE
Ends the current sub-path and connects it with its initial point - corresponds to Z command in the sv...
Definition: thorvg_capi.h:160
TVG_PATH_COMMAND_MOVE_TO
@ TVG_PATH_COMMAND_MOVE_TO
Sets a new initial point of the sub-path and a new current point - corresponds to M command in the sv...
Definition: thorvg_capi.h:161
TVG_PATH_COMMAND_LINE_TO
@ TVG_PATH_COMMAND_LINE_TO
Draws a line from the current point to the given point and sets a new value of the current point - co...
Definition: thorvg_capi.h:162
TVG_STROKE_CAP_ROUND
@ TVG_STROKE_CAP_ROUND
The stroke is extended in both endpoints of a sub-path by a half circle, with a radius equal to the h...
Definition: thorvg_capi.h:172
TVG_STROKE_CAP_SQUARE
@ TVG_STROKE_CAP_SQUARE
The stroke is extended in both endpoints of a sub-path by a rectangle, with the width equal to the st...
Definition: thorvg_capi.h:171
TVG_STROKE_CAP_BUTT
@ TVG_STROKE_CAP_BUTT
The stroke ends exactly at each of the two endpoints of a sub-path. For zero length sub-paths no stro...
Definition: thorvg_capi.h:173
TVG_STROKE_FILL_REFLECT
@ TVG_STROKE_FILL_REFLECT
The gradient pattern is reflected outside the gradient area until the expected region is filled.
Definition: thorvg_capi.h:192
TVG_STROKE_FILL_PAD
@ TVG_STROKE_FILL_PAD
The remaining area is filled with the closest stop color.
Definition: thorvg_capi.h:191
TVG_STROKE_FILL_REPEAT
@ TVG_STROKE_FILL_REPEAT
The gradient pattern is repeated continuously beyond the gradient area until the expected region is f...
Definition: thorvg_capi.h:193
TVG_STROKE_JOIN_BEVEL
@ TVG_STROKE_JOIN_BEVEL
The outer corner of the joined path segments is bevelled at the join point. The triangular region of ...
Definition: thorvg_capi.h:181
TVG_STROKE_JOIN_MITER
@ TVG_STROKE_JOIN_MITER
The outer corner of the joined path segments is spiked. The spike is created by extension beyond the ...
Definition: thorvg_capi.h:183
TVG_STROKE_JOIN_ROUND
@ TVG_STROKE_JOIN_ROUND
The outer corner of the joined path segments is rounded. The circular region is centered at the join ...
Definition: thorvg_capi.h:182
TVG_FILL_RULE_EVEN_ODD
@ TVG_FILL_RULE_EVEN_ODD
A line from the point to a location outside the shape is drawn and its intersections with the path se...
Definition: thorvg_capi.h:202
TVG_FILL_RULE_WINDING
@ TVG_FILL_RULE_WINDING
A line from the point to a location outside the shape is drawn. The intersections of the line with th...
Definition: thorvg_capi.h:201
tvg_swcanvas_create
TVG_API Tvg_Canvas * tvg_swcanvas_create()
Creates a Canvas object.
tvg_swcanvas_set_target
TVG_API Tvg_Result tvg_swcanvas_set_target(Tvg_Canvas *canvas, uint32_t *buffer, uint32_t stride, uint32_t w, uint32_t h, Tvg_Colorspace cs)
Sets the buffer used in the rasterization process and defines the used colorspace.
tvg_swcanvas_set_mempool
TVG_API Tvg_Result tvg_swcanvas_set_mempool(Tvg_Canvas *canvas, Tvg_Mempool_Policy policy)
Sets the software engine memory pool behavior policy.
Tvg_Colorspace
Tvg_Colorspace
Enumeration specifying the methods of combining the 8-bit color channels into 32-bit color.
Definition: thorvg_capi.h:362
Tvg_Mempool_Policy
Tvg_Mempool_Policy
Enumeration specifying the methods of Memory Pool behavior policy.
Definition: thorvg_capi.h:352
TVG_COLORSPACE_ARGB8888
@ TVG_COLORSPACE_ARGB8888
The 8-bit color channels are combined into 32-bit color in the order: alpha, red, green,...
Definition: thorvg_capi.h:364
TVG_COLORSPACE_ABGR8888
@ TVG_COLORSPACE_ABGR8888
The 8-bit color channels are combined into 32-bit color in the order: alpha, blue,...
Definition: thorvg_capi.h:363
TVG_MEMPOOL_POLICY_INDIVIDUAL
@ TVG_MEMPOOL_POLICY_INDIVIDUAL
Allocate designated memory pool that is used only by the current canvas instance.
Definition: thorvg_capi.h:355
TVG_MEMPOOL_POLICY_DEFAULT
@ TVG_MEMPOOL_POLICY_DEFAULT
Default behavior that ThorVG is designed to.
Definition: thorvg_capi.h:353
TVG_MEMPOOL_POLICY_SHAREABLE
@ TVG_MEMPOOL_POLICY_SHAREABLE
Memory Pool is shared among canvases.
Definition: thorvg_capi.h:354
Tvg_Canvas
struct _Tvg_Canvas Tvg_Canvas
A structure responsible for managing and drawing graphical elements.
Definition: thorvg_capi.h:69
Tvg_Paint
struct _Tvg_Paint Tvg_Paint
A structure representing a graphical element.
Definition: thorvg_capi.h:77
Tvg_Saver
struct _Tvg_Saver Tvg_Saver
A structure representing an object that enables to save a Tvg_Paint object into a file.
Definition: thorvg_capi.h:89
Tvg_Result
Tvg_Result
Enumeration specifying the result from the APIs.
Definition: thorvg_capi.h:106
Tvg_Gradient
struct _Tvg_Gradient Tvg_Gradient
A structure representing a gradient fill of a Tvg_Paint object.
Definition: thorvg_capi.h:83
TVG_RESULT_UNKNOWN
@ TVG_RESULT_UNKNOWN
The value returned in all other cases.
Definition: thorvg_capi.h:113
TVG_RESULT_INVALID_ARGUMENT
@ TVG_RESULT_INVALID_ARGUMENT
The value returned in the event of a problem with the arguments given to the API - e....
Definition: thorvg_capi.h:108
TVG_RESULT_NOT_SUPPORTED
@ TVG_RESULT_NOT_SUPPORTED
The value returned in case of choosing unsupported options.
Definition: thorvg_capi.h:112
TVG_RESULT_FAILED_ALLOCATION
@ TVG_RESULT_FAILED_ALLOCATION
The value returned in case of unsuccessful memory allocation.
Definition: thorvg_capi.h:110
TVG_RESULT_INSUFFICIENT_CONDITION
@ TVG_RESULT_INSUFFICIENT_CONDITION
The value returned in case the request cannot be processed - e.g. asking for properties of an object,...
Definition: thorvg_capi.h:109
TVG_RESULT_MEMORY_CORRUPTION
@ TVG_RESULT_MEMORY_CORRUPTION
The value returned in the event of bad memory handling - e.g. failing in pointer releasing or casting...
Definition: thorvg_capi.h:111
TVG_RESULT_SUCCESS
@ TVG_RESULT_SUCCESS
The value returned in case of a correct request execution.
Definition: thorvg_capi.h:107
Tvg_Color_Stop
A data structure storing the information about the color and its relative position inside the gradien...
Definition: thorvg_capi.h:217
Tvg_Color_Stop::g
uint8_t g
Definition: thorvg_capi.h:220
Tvg_Color_Stop::offset
float offset
Definition: thorvg_capi.h:218
Tvg_Color_Stop::b
uint8_t b
Definition: thorvg_capi.h:221
Tvg_Color_Stop::r
uint8_t r
Definition: thorvg_capi.h:219
Tvg_Color_Stop::a
uint8_t a
Definition: thorvg_capi.h:222
Tvg_Matrix
A data structure representing a three-dimensional matrix.
Definition: thorvg_capi.h:245
Tvg_Point
A data structure representing a point in two-dimensional space.
Definition: thorvg_capi.h:232