ThorVG v1.1
Loading...
Searching...
No Matches
thorvg.h
1#ifndef _THORVG_H_
2#define _THORVG_H_
3
4#include <cstdint>
5#include <functional>
6#include <list>
7#include <cstdarg>
8
9#define TVG_VERSION_MAJOR 1 // for compile-time checks
10#define TVG_VERSION_MINOR 0 // for compile-time checks
11#define TVG_VERSION_MICRO 0 // for compile-time checks
12
13#ifdef TVG_API
14 #undef TVG_API
15#endif
16
17#ifndef TVG_STATIC
18 #ifdef _WIN32
19 #if TVG_BUILD
20 #define TVG_API __declspec(dllexport)
21 #else
22 #define TVG_API __declspec(dllimport)
23 #endif
24 #elif (defined(__SUNPRO_C) || defined(__SUNPRO_CC))
25 #define TVG_API __global
26 #else
27 #if (defined(__GNUC__) && __GNUC__ >= 4) || defined(__INTEL_COMPILER)
28 #define TVG_API __attribute__ ((visibility("default")))
29 #else
30 #define TVG_API
31 #endif
32 #endif
33#else
34 #define TVG_API
35#endif
36
37#ifdef TVG_DEPRECATED
38 #undef TVG_DEPRECATED
39#endif
40
41#ifdef _WIN32
42 #define TVG_DEPRECATED __declspec(deprecated)
43#elif __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
44 #define TVG_DEPRECATED __attribute__ ((__deprecated__))
45#else
46 #define TVG_DEPRECATED
47#endif
48
49#define _TVG_DECLARE_PRIVATE(A) \
50protected: \
51 A(const A&) = delete; \
52 const A& operator=(const A&) = delete; \
53 A()
54
55#define _TVG_DECLARE_PRIVATE_BASE(A) \
56 _TVG_DECLARE_PRIVATE(A); \
57public: \
58 struct Impl; \
59 Impl* pImpl
60
61#define _TVG_DECLARE_PRIVATE_DERIVE(A) \
62 _TVG_DECLARE_PRIVATE(A); \
63protected: \
64 ~A() {}
65
66#define _TVG_DISABLE_CTOR(A) \
67 A() = delete; \
68 ~A() = delete
69
70#define _TVG_DECLARE_ACCESSOR(A) \
71 friend A
72
73namespace tvg
74{
75
76struct RenderMethod;
77struct Animation;
78struct Shape;
79
94enum struct Result
95{
96 Success = 0,
101 NonSupport,
102 Unknown = 255
103};
104
105
109enum struct ColorSpace : uint8_t
110{
111 ABGR8888 = 0,
112 ARGB8888,
113 ABGR8888S,
114 ARGB8888S,
115 Grayscale8,
116 Unknown = 255
117};
118
133enum struct EngineOption : uint8_t
134{
135 None = 0,
136 Default = 1 << 0,
137 SmartRender = 1 << 1,
138 Aliased = 1 << 2
139};
140
141
145enum struct PathCommand : uint8_t
146{
147 Close = 0,
148 MoveTo,
149 LineTo,
150 CubicTo
151};
152
153
157enum struct StrokeCap : uint8_t
158{
159 Butt = 0,
160 Round,
161 Square
162};
163
164
168enum struct StrokeJoin : uint8_t
169{
170 Miter = 0,
171 Round,
172 Bevel
173};
174
175
179enum struct FillSpread : uint8_t
180{
181 Pad = 0,
182 Reflect,
183 Repeat
184};
185
186
190enum struct FillRule : uint8_t
191{
192 NonZero = 0,
193 EvenOdd
194};
195
201enum struct FilterMethod : uint8_t
202{
203 Bilinear = 0,
204 Nearest
205};
206
207
215enum struct MaskMethod : uint8_t
216{
217 None = 0,
218 Alpha,
219 InvAlpha,
220 Luma,
221 InvLuma,
222 Add,
223 Subtract,
224 Intersect,
225 Difference,
226 Lighten,
227 Darken
228};
229
230
240enum struct BlendMethod : uint8_t
241{
242 Normal = 0,
243 Multiply,
244 Screen,
245 Overlay,
246 Darken,
247 Lighten,
248 ColorDodge,
249 ColorBurn,
250 HardLight,
251 SoftLight,
252 Difference,
253 Exclusion,
254 Hue,
255 Saturation,
256 Color,
257 Luminosity,
258 Add,
259 Composition = 255
260};
261
262
273enum struct SceneEffect : uint8_t
274{
275 Clear = 0,
277 DropShadow,
278 Fill,
279 Tint,
280 Tritone
281};
282
283
294enum struct TextWrap : uint8_t
295{
296 None = 0,
297 Character,
298 Word,
299 Smart,
300 Ellipsis
301};
302
303
314enum struct Type : uint8_t
315{
316 Undefined = 0,
317 Shape,
318 Scene,
319 Picture,
320 Text,
321 LinearGradient = 10,
323};
324
325
332struct Point
333{
334 float x;
335 float y;
336};
337
338
346struct Matrix
347{
348 float e11, e12, e13;
349 float e21, e22, e23;
350 float e31, e32, e33;
351};
352
353
364{
365 float ascent;
366 float descent;
367 float linegap;
368 float advance;
369};
370
371
396
397
407struct TVG_API Paint
408{
422 const Paint* parent() const noexcept;
423
443 Result visible(bool on) noexcept;
444
456 Result rotate(float degree) noexcept;
457
466 Result scale(float factor) noexcept;
467
480 Result translate(float x, float y) noexcept;
481
489 Result transform(const Matrix& m) noexcept;
490
501 Matrix& transform() noexcept;
502
510 Result opacity(uint8_t o) noexcept;
511
521 Result mask(Paint* target, MaskMethod method) noexcept;
522
536 Result clip(Shape* clipper) noexcept;
537
549 Result blend(BlendMethod method) noexcept;
550
570 Result bounds(Point* pt4) noexcept;
571
591 Result bounds(float* x, float* y, float* w, float* h) noexcept;
592
596 TVG_DEPRECATED bool intersects(int32_t x, int32_t y, int32_t w = 1, int32_t h = 1) noexcept;
597
625 bool intersects(int32_t x, int32_t y, int32_t w, int32_t h, bool visibleOnly) noexcept;
626
634 Paint* duplicate() const noexcept;
635
641 uint8_t opacity() const noexcept;
642
652 MaskMethod mask(const Paint** target) const noexcept;
653
665 Shape* clip() const noexcept;
666
677 bool visible() const noexcept;
678
693 uint16_t ref() noexcept;
694
710 uint16_t unref(bool free = true) noexcept;
711
724 uint16_t refCnt() const noexcept;
725
735 virtual Type type() const noexcept = 0;
736
744 uint32_t id = 0;
745
756 static void rel(Paint* paint) noexcept;
757
758protected:
759 virtual ~Paint();
760
761 _TVG_DECLARE_PRIVATE_BASE(Paint);
762};
763
764
776struct TVG_API Fill
777{
782 {
783 float offset;
784 uint8_t r;
785 uint8_t g;
786 uint8_t b;
787 uint8_t a;
788 };
789
790 virtual ~Fill();
791
798 Result colorStops(const ColorStop* colorStops, uint32_t cnt) noexcept;
799
806
814 Result transform(const Matrix& m) noexcept;
815
823 uint32_t colorStops(const ColorStop** colorStops) const noexcept;
824
830 FillSpread spread() const noexcept;
831
839 Matrix& transform() const noexcept;
840
848 Fill* duplicate() const noexcept;
849
859 virtual Type type() const noexcept = 0;
860
861 _TVG_DECLARE_PRIVATE_BASE(Fill);
862};
863
864
875struct TVG_API Canvas
876{
877 virtual ~Canvas();
878
891 const std::list<Paint*>& paints() const noexcept;
892
921 Result add(Paint* target, Paint* at = nullptr) noexcept;
922
938 Result remove(Paint* paint = nullptr) noexcept;
939
955 Result update() noexcept;
956
975 Result draw(bool clear = false) noexcept;
976
1003 Result viewport(int32_t x, int32_t y, int32_t w, int32_t h) noexcept;
1004
1013 Result sync() noexcept;
1014
1015 _TVG_DECLARE_PRIVATE_BASE(Canvas);
1016};
1017
1018
1029struct TVG_API LinearGradient : Fill
1030{
1046 Result linear(float x1, float y1, float x2, float y2) noexcept;
1047
1060 Result linear(float* x1, float* y1, float* x2, float* y2) const noexcept;
1061
1067 static LinearGradient* gen() noexcept;
1068
1078 Type type() const noexcept override;
1079
1080 _TVG_DECLARE_PRIVATE(LinearGradient);
1081};
1082
1083
1091struct TVG_API RadialGradient : Fill
1092{
1118 Result radial(float cx, float cy, float r, float fx, float fy, float fr) noexcept;
1119
1132 Result radial(float* cx, float* cy, float* r, float* fx = nullptr, float* fy = nullptr, float* fr = nullptr) const noexcept;
1133
1139 static RadialGradient* gen() noexcept;
1140
1150 Type type() const noexcept override;
1151
1152 _TVG_DECLARE_PRIVATE(RadialGradient);
1153};
1154
1155
1170struct TVG_API Shape : Paint
1171{
1179 Result reset() noexcept;
1180
1189 Result moveTo(float x, float y) noexcept;
1190
1201 Result lineTo(float x, float y) noexcept;
1202
1218 Result cubicTo(float cx1, float cy1, float cx2, float cy2, float x, float y) noexcept;
1219
1227 Result close() noexcept;
1228
1252 Result appendRect(float x, float y, float w, float h, float rx = 0, float ry = 0, bool cw = true) noexcept;
1253
1270 Result appendCircle(float cx, float cy, float rx, float ry, bool cw = true) noexcept;
1271
1286 Result appendPath(const PathCommand* cmds, uint32_t cmdCnt, const Point* pts, uint32_t ptsCnt) noexcept;
1287
1301 Result strokeWidth(float width) noexcept;
1302
1321 Result strokeFill(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255) noexcept;
1322
1335 Result strokeFill(Fill* f) noexcept;
1336
1354 Result strokeDash(const float* dashPattern, uint32_t cnt, float offset = 0.0f) noexcept;
1355
1362 Result strokeCap(StrokeCap cap) noexcept;
1363
1372 Result strokeJoin(StrokeJoin join) noexcept;
1373
1383 Result strokeMiterlimit(float miterlimit) noexcept;
1384
1397 Result trimpath(float begin, float end, bool simultaneous = true) noexcept;
1398
1411 Result fill(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255) noexcept;
1412
1422 Result fill(Fill* f) noexcept;
1423
1432 Result fillRule(FillRule r) noexcept;
1433
1441 Result order(bool strokeFirst) noexcept;
1442
1458 Result path(const PathCommand** cmds, uint32_t* cmdsCnt, const Point** pts, uint32_t* ptsCnt) const noexcept;
1459
1465 const Fill* fill() const noexcept;
1466
1476 Result fill(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a = nullptr) const noexcept;
1477
1487 FillRule fillRule() const noexcept;
1488
1494 float strokeWidth() const noexcept;
1495
1505 Result strokeFill(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a = nullptr) const noexcept;
1506
1512 const Fill* strokeFill() const noexcept;
1513
1524 uint32_t strokeDash(const float** dashPattern, float* offset = nullptr) const noexcept;
1525
1531 StrokeCap strokeCap() const noexcept;
1532
1538 StrokeJoin strokeJoin() const noexcept;
1539
1547 float strokeMiterlimit() const noexcept;
1548
1559 static Shape* gen() noexcept;
1560
1570 Type type() const noexcept override;
1571
1572 _TVG_DECLARE_PRIVATE_DERIVE(Shape);
1573};
1574
1575
1587struct TVG_API Picture : Paint
1588{
1604 Result load(const char* filename) noexcept;
1605
1628 Result load(const char* data, uint32_t size, const char* mimeType, const char* rpath = nullptr, bool copy = false) noexcept;
1629
1640 Result size(float w, float h) noexcept;
1641
1649 Result size(float* w, float* h) const noexcept;
1650
1679 Result origin(float x, float y) noexcept;
1680
1693 Result origin(float* x, float* y) const noexcept;
1694
1713 Result load(const uint32_t* data, uint32_t w, uint32_t h, ColorSpace cs, bool copy = false) noexcept;
1714
1737 Result resolver(std::function<bool(Paint* paint, const char* src, void* data)> func, void* data) noexcept;
1738
1752 Result filter(FilterMethod method) noexcept;
1753
1770 const Paint* paint(uint32_t id) noexcept;
1771
1782 static Picture* gen() noexcept;
1783
1793 Type type() const noexcept override;
1794
1795 bool accessible = false;
1796
1797 _TVG_DECLARE_ACCESSOR(Animation);
1798 _TVG_DECLARE_PRIVATE_DERIVE(Picture);
1799};
1800
1801
1815struct TVG_API Scene : Paint
1816{
1843 Result add(Paint* target, Paint* at = nullptr) noexcept;
1844
1856 const std::list<Paint*>& paints() const noexcept;
1857
1873 Result remove(Paint* paint = nullptr) noexcept;
1874
1894 Result add(SceneEffect effect, ...) noexcept;
1895
1906 static Scene* gen() noexcept;
1907
1917 Type type() const noexcept override;
1918
1919 _TVG_DECLARE_PRIVATE_DERIVE(Scene);
1920};
1921
1922
1932struct TVG_API Text : Paint
1933{
1952 Result font(const char* name) noexcept;
1953
1972 Result size(float size) noexcept;
1973
1985 Result text(const char* text) noexcept;
1986
1998 const char* text() const noexcept;
1999
2014 Result align(float x, float y) noexcept;
2015
2032 Result layout(float w, float h) noexcept;
2033
2047 Result wrap(TextWrap mode) noexcept;
2048
2061 uint32_t lines() noexcept;
2062
2083 Result italic(float shear = 0.18f) noexcept;
2084
2101 Result outline(float width, uint8_t r, uint8_t g, uint8_t b) noexcept;
2102
2115 Result fill(uint8_t r, uint8_t g, uint8_t b) noexcept;
2116
2129 Result fill(Fill* f) noexcept;
2130
2151 Result spacing(float letter, float line) noexcept;
2152
2169 Result metrics(TextMetrics& metrics) const noexcept;
2170
2194 Result metrics(const char* ch, GlyphMetrics& metrics, const char** next = nullptr) const noexcept;
2195
2212 static Result load(const char* filename) noexcept;
2213
2239 static Result load(const char* name, const char* data, uint32_t size, const char* mimeType = "ttf", bool copy = false) noexcept;
2240
2255 static Result unload(const char* filename) noexcept;
2256
2269 static Text* gen() noexcept;
2270
2280 Type type() const noexcept override;
2281
2282 _TVG_DECLARE_PRIVATE_DERIVE(Text);
2283};
2284
2285
2291struct TVG_API SwCanvas final : Canvas
2292{
2293 ~SwCanvas() override;
2294
2317 Result target(uint32_t* buffer, uint32_t stride, uint32_t w, uint32_t h, ColorSpace cs) noexcept;
2318
2331 static SwCanvas* gen(EngineOption op = EngineOption::Default) noexcept;
2332
2333 _TVG_DECLARE_PRIVATE(SwCanvas);
2334};
2335
2336
2344struct TVG_API GlCanvas final : Canvas
2345{
2346 ~GlCanvas() override;
2347
2373 Result target(void* display, void* surface, void* context, int32_t id, uint32_t w, uint32_t h, ColorSpace cs) noexcept;
2374
2391 static GlCanvas* gen(EngineOption op = EngineOption::Default) noexcept;
2392
2393 _TVG_DECLARE_PRIVATE(GlCanvas);
2394};
2395
2396
2406struct TVG_API WgCanvas final : Canvas
2407{
2408 ~WgCanvas() override;
2409
2417 struct Context
2418 {
2419 void* instance; // WGPUInstance, context for all other wgpu objects.
2420 void* adapter; // WGPUAdapter, the adapter associated with the rendering device.
2421 void* device; // WGPUDevice, a desired handle for the wgpu device.
2422 };
2423
2446 Result target(void* device, void* instance, void* target, uint32_t w, uint32_t h, ColorSpace cs, int type = 0) noexcept;
2447
2466 Result target(const Context& context, void* target, uint32_t w, uint32_t h, ColorSpace cs, int type = 0) noexcept;
2467
2484 static WgCanvas* gen(EngineOption op = EngineOption::Default) noexcept;
2485
2486 _TVG_DECLARE_PRIVATE(WgCanvas);
2487};
2488
2489
2495struct TVG_API Initializer final
2496{
2515 static Result init(uint32_t threads = 0) noexcept;
2516
2528 static Result term() noexcept;
2529
2541 static const char* version(uint32_t* major, uint32_t* minor, uint32_t* micro) noexcept;
2542
2543 _TVG_DISABLE_CTOR(Initializer);
2544};
2545
2546
2556struct TVG_API Animation
2557{
2558 virtual ~Animation();
2559
2574 Result frame(float no) noexcept;
2575
2587 Picture* picture() const noexcept;
2588
2599 float curFrame() const noexcept;
2600
2609 float totalFrame() const noexcept;
2610
2618 float duration() const noexcept;
2619
2643 Result segment(float begin, float end) noexcept;
2644
2656 Result segment(float* begin, float* end = nullptr) noexcept;
2657
2663 static Animation* gen() noexcept;
2664
2665 _TVG_DECLARE_PRIVATE_BASE(Animation);
2666};
2667
2668
2686struct TVG_API Saver final
2687{
2688 ~Saver();
2689
2697 Result background(Paint* paint) noexcept;
2698
2719 Result save(Paint* paint, const char* filename, uint32_t quality = 100) noexcept;
2720
2742 Result save(Animation* animation, const char* filename, uint32_t quality = 100, uint32_t fps = 0) noexcept;
2743
2756 Result sync() noexcept;
2757
2765 static Saver* gen() noexcept;
2766
2767 _TVG_DECLARE_PRIVATE_BASE(Saver);
2768};
2769
2782struct TVG_API Accessor
2783{
2784 virtual ~Accessor();
2785
2797 Result set(Paint* paint, std::function<bool(const Paint* paint, void* data)> func, void* data) noexcept;
2798
2814 static uint32_t id(const char* name) noexcept;
2815
2836 const char* name(uint32_t id) noexcept;
2837
2843 static Accessor* gen() noexcept;
2844
2845 _TVG_DECLARE_PRIVATE_BASE(Accessor);
2846};
2847
2850} //namespace
2851
2852#endif //_THORVG_H_
TextWrap
Enumeration that defines methods used for wrapping text.
Definition thorvg.h:295
EngineOption
Enumeration to specify rendering engine behavior.
Definition thorvg.h:134
StrokeJoin
Enumeration determining the style used at the corners of joined stroked path segments.
Definition thorvg.h:169
Result
Enumeration specifying the result from the APIs.
Definition thorvg.h:95
BlendMethod
Enumeration indicates the method used for blending paint. Please refer to the respective formulas for...
Definition thorvg.h:241
Type
Enumeration specifying the ThorVG class type value.
Definition thorvg.h:315
SceneEffect
Enumeration that defines methods used for Scene Effects.
Definition thorvg.h:274
FillSpread
Enumeration specifying how to fill the area outside the gradient bounds.
Definition thorvg.h:180
ColorSpace
Enumeration specifying the methods of combining the 8-bit color channels into 32-bit color.
Definition thorvg.h:110
MaskMethod
Enumeration indicating the method used in the mask of two objects - the target and the source.
Definition thorvg.h:216
StrokeCap
Enumeration determining the ending type of a stroke in the open sub-paths.
Definition thorvg.h:158
PathCommand
Enumeration specifying the values of the path commands accepted by ThorVG.
Definition thorvg.h:146
FillRule
Enumeration specifying the algorithm used to establish which parts of the shape are treated as the in...
Definition thorvg.h:191
FilterMethod
Defines the image filtering method used during image scaling or transformation.
Definition thorvg.h:202
@ Word
Wrap at the word level. Words that do not fit are moved to the next line.
@ Character
Wrap at the character level. If a word cannot fit, it is broken into individual characters to fit the...
@ Ellipsis
Truncate overflowing text and append an ellipsis ("...") at the end. Typically used for single-line l...
@ Smart
Smart choose wrapping method: word wrap first, falling back to character wrap if a word does not fit.
@ Bevel
The outer corner of the joined path segments is bevelled at the join point. The triangular region of ...
@ Miter
The outer corner of the joined path segments is spiked. The spike is created by extension beyond the ...
@ InsufficientCondition
The value returned in case the request cannot be processed - e.g. asking for properties of an object,...
@ Success
The value returned in case of a correct request execution.
@ Unknown
The value returned in all other cases.
@ NonSupport
The value returned in case of choosing unsupported engine features(options).
@ FailedAllocation
The value returned in case of unsuccessful memory allocation.
@ InvalidArguments
The value returned in the event of a problem with the arguments given to the API - e....
@ MemoryCorruption
The value returned in the event of bad memory handling - e.g. failing in pointer releasing or casting...
@ SoftLight
Darkens or lightens the colors, depending on the source color value. If S <= 0.5: D - (1 - 2 * S) * D...
@ Exclusion
The result is twice the product of the top and bottom layers, subtracted from their sum....
@ Saturation
Uses the saturation of the source and the hue and luminosity of the destination.
@ Screen
The values of the pixels in the two layers are inverted, multiplied, and then inverted again....
@ Luminosity
Uses the luminosity of the source and the hue and saturation of the destination.
@ Composition
For intermediate composition layers; suitable for use with Scene or Picture.
@ Overlay
Combines Multiply and Screen blend modes. (2 * S * D) if (D < 128), otherwise 255 - 2 * (255 - S) * (...
@ Normal
Perform the alpha blending(default). S if (Sa == 255), otherwise (Sa * S) + (255 - Sa) * D.
@ ColorBurn
Divides the inverted bottom layer by the top layer, and then inverts the result. 255 - (255 - D) / S.
@ Color
Uses the hue and saturation of the source and the luminosity of the destination.
@ HardLight
The same as Overlay but with the color roles reversed. (2 * S * D) if (S < 128), otherwise 255 - 2 * ...
@ Multiply
Takes the RGB channel values from 0 to 255 of each pixel in the top layer and multiples them with the...
@ ColorDodge
Divides the bottom layer by the inverted top layer. D / (255 - S)
@ Hue
Uses the hue of the source and the saturation and luminosity of the destination.
@ Shape
Shape class.
@ Undefined
Unknown class.
@ Tritone
Apply a tritone color effect to the scene using three color parameters for shadows,...
@ Tint
Tinting the current scene color with a given black, white color parameters. Param(7) = {black_R(int)[...
@ GaussianBlur
Apply a blur effect with a Gaussian filter. Param(4) = {sigma(double)[> 0], direction(int)[both: 0 / ...
@ DropShadow
Apply a drop shadow effect with a Gaussian Blur filter. Param(8) = {color_R(int)[0 - 255],...
@ Clear
Clear all previously applied scene effects, restoring the scene to its original state.
@ Repeat
The gradient pattern is repeated continuously beyond the gradient area until the expected region is f...
@ Reflect
The gradient pattern is reflected outside the gradient area until the expected region is filled.
@ Pad
The remaining area is filled with the closest stop color.
@ ARGB8888S
The channels are joined in the order: alpha, red, green, blue. Colors are un-alpha-premultiplied.
@ ARGB8888
The channels are joined in the order: alpha, red, green, blue. Colors are alpha-premultiplied.
@ ABGR8888
The channels are joined in the order: alpha, blue, green, red. Colors are alpha-premultiplied.
@ Grayscale8
Single channel, 1 byte per pixel 8-bit grayscale.
@ ABGR8888S
The channels are joined in the order: alpha, blue, green, red. Colors are un-alpha-premultiplied.
@ Lighten
Where multiple masks intersect, the highest transparency value is used.
@ Subtract
Subtracts the source color from the target color while considering their respective target alpha....
@ InvAlpha
Alpha Masking using the complement to the masking target's pixels as an alpha value.
@ Difference
Calculates the absolute difference between the target color and the source color multiplied by the co...
@ InvLuma
Alpha Masking using the grayscale (0.2126R + 0.7152G + 0.0722*B) of the complement to the masking tar...
@ Alpha
Alpha Masking using the masking target's pixels as an alpha value.
@ Intersect
Computes the result by taking the minimum value between the target alpha and the source alpha and mul...
@ Luma
Alpha Masking using the grayscale (0.2126R + 0.7152G + 0.0722*B) of the masking target's pixels.
@ Add
Combines the target and source objects pixels using target alpha. (T * TA) + (S * (255 - TA))
@ Darken
Where multiple masks intersect, the lowest transparency value is used.
@ Butt
The stroke ends exactly at each of the two end-points of a sub-path. For zero length sub-paths no str...
@ Round
The stroke is extended in both end-points of a sub-path by a half circle, with a radius equal to the ...
@ Square
The stroke is extended in both end-points of a sub-path by a rectangle, with the width equal to the s...
@ LineTo
Draws a line from the current point to the given point and sets a new value of the current point....
@ CubicTo
Draws a cubic Bezier curve from the current point to the given point using two given control points a...
@ Close
Ends the current sub-path and connects it with its initial point. This command doesn't expect any poi...
@ MoveTo
Sets a new initial point of the sub-path and a new current point. This command expects 1 point: the s...
@ NonZero
A line from the point to a location outside the shape is drawn. The intersections of the line with th...
@ EvenOdd
A line from the point to a location outside the shape is drawn and its intersections with the path se...
@ Nearest
Fast filtering using nearest-neighbor sampling.
@ Bilinear
Smooth interpolation using surrounding pixels for higher quality.
The Accessor is a utility class to debug the Scene structure by traversing the scene-tree.
Definition thorvg.h:2783
static uint32_t id(const char *name) noexcept
Generate a unique ID (hash key) from a given name.
const char * name(uint32_t id) noexcept
Retrieve the original name string from a given unique ID.
Result set(Paint *paint, std::function< bool(const Paint *paint, void *data)> func, void *data) noexcept
Set the access function for traversing the Picture scene tree nodes.
static Accessor * gen() noexcept
Creates a new Accessor object.
The Animation class enables manipulation of animatable images.
Definition thorvg.h:2557
Picture * picture() const noexcept
Retrieves a picture instance associated with this animation instance.
Result frame(float no) noexcept
Specifies the current frame in the animation.
An abstract class for drawing graphical elements.
Definition thorvg.h:876
const std::list< Paint * > & paints() const noexcept
Returns the list of paints currently held by the Canvas.
A data structure storing the information about the color and its relative position inside the gradien...
Definition thorvg.h:782
uint8_t g
Definition thorvg.h:785
float offset
Definition thorvg.h:783
uint8_t b
Definition thorvg.h:786
uint8_t r
Definition thorvg.h:784
uint8_t a
Definition thorvg.h:787
An abstract class representing the gradient fill of the Shape object.
Definition thorvg.h:777
FillSpread spread() const noexcept
Gets the FillSpread value of the fill.
Result colorStops(const ColorStop *colorStops, uint32_t cnt) noexcept
Sets the parameters of the colors of the gradient and their position.
Result transform(const Matrix &m) noexcept
Sets the matrix of the affine transformation for the gradient fill.
uint32_t colorStops(const ColorStop **colorStops) const noexcept
Gets the parameters of the colors of the gradient, their position and number.
Result spread(FillSpread s) noexcept
Sets the FillSpread value, which specifies how to fill the area outside the gradient bounds.
A class for the rendering graphic elements with a GL raster engine.
Definition thorvg.h:2345
Result target(void *display, void *surface, void *context, int32_t id, uint32_t w, uint32_t h, ColorSpace cs) noexcept
Sets the drawing target for rasterization.
static GlCanvas * gen(EngineOption op=EngineOption::Default) noexcept
Creates a new OpenGL/ES Canvas object with optional rendering engine settings.
Describes the layout metrics of a glyph.
Definition thorvg.h:390
float advance
The advance distance along the baseline (inline) direction.
Definition thorvg.h:391
Point max
The maximum point of the glyph bounding box in local space.
Definition thorvg.h:394
Point min
The minimum point of the glyph bounding box in local space.
Definition thorvg.h:393
float bearing
The bearing from the origin to the glyph’s visible bound along the inline-start direction.
Definition thorvg.h:392
A class that enables initialization and termination of the TVG engines.
Definition thorvg.h:2496
static Result init(uint32_t threads=0) noexcept
Initializes the ThorVG engine runtime.
A class representing the linear gradient fill of the Shape object.
Definition thorvg.h:1030
static LinearGradient * gen() noexcept
Creates a new LinearGradient object.
Result linear(float *x1, float *y1, float *x2, float *y2) const noexcept
Gets the linear gradient bounds.
Result linear(float x1, float y1, float x2, float y2) noexcept
Sets the linear gradient bounds.
A data structure representing a three-dimensional matrix.
Definition thorvg.h:347
An abstract class for managing graphical elements.
Definition thorvg.h:408
const Paint * parent() const noexcept
Retrieves the parent paint object.
A class representing an image read in one of the supported formats: raw, svg, png,...
Definition thorvg.h:1588
Result load(const char *filename) noexcept
Loads a picture data directly from a file.
Result load(const char *data, uint32_t size, const char *mimeType, const char *rpath=nullptr, bool copy=false) noexcept
Loads a picture data from a memory block of a given size.
A data structure representing a point in two-dimensional space.
Definition thorvg.h:333
float y
The y-coordinate of the point.
Definition thorvg.h:335
float x
The x-coordinate of the point.
Definition thorvg.h:334
A class representing the radial gradient fill of the Shape object.
Definition thorvg.h:1092
Result radial(float cx, float cy, float r, float fx, float fy, float fr) noexcept
Sets the radial gradient attributes.
Result radial(float *cx, float *cy, float *r, float *fx=nullptr, float *fy=nullptr, float *fr=nullptr) const noexcept
Gets the radial gradient attributes.
A class for exporting a paint object into a specified file, from which to recover the paint data late...
Definition thorvg.h:2687
Result background(Paint *paint) noexcept
Sets the base background content for the saved image.
Result save(Paint *paint, const char *filename, uint32_t quality=100) noexcept
Exports the given paint data to the given path.
A class to composite children paints.
Definition thorvg.h:1816
Result add(Paint *target, Paint *at=nullptr) noexcept
Adds a paint object to the scene.
A class representing two-dimensional figures and their properties.
Definition thorvg.h:1171
Result reset() noexcept
Resets the shape path.
A class for the rendering graphical elements with a software raster engine.
Definition thorvg.h:2292
static SwCanvas * gen(EngineOption op=EngineOption::Default) noexcept
Creates a new SwCanvas object with optional rendering engine settings.
Result target(uint32_t *buffer, uint32_t stride, uint32_t w, uint32_t h, ColorSpace cs) noexcept
Sets the drawing target for the rasterization.
Describes the font metrics of a text object.
Definition thorvg.h:364
float advance
The total vertical advance between lines of text: ascent - descent + linegap (i.e....
Definition thorvg.h:368
float ascent
Distance from the baseline to the top of the highest glyph (usually positive).
Definition thorvg.h:365
float descent
Distance from the baseline to the bottom of the lowest glyph (usually negative, as in TTF).
Definition thorvg.h:366
float linegap
Additional spacing recommended between lines (leading).
Definition thorvg.h:367
A class to represent text objects in a graphical context, allowing for rendering and manipulation of ...
Definition thorvg.h:1933
const char * text() const noexcept
Returns the currently assigned unicode text.
Result font(const char *name) noexcept
Sets the font family for the text.
Result size(float size) noexcept
Sets the font size for the text.
Result text(const char *text) noexcept
Assigns the given unicode text to be rendered.
Encapsulates the WebGPU context required for rendering.
Definition thorvg.h:2418
A class for the rendering graphic elements with a WebGPU raster engine.
Definition thorvg.h:2407
Result target(void *device, void *instance, void *target, uint32_t w, uint32_t h, ColorSpace cs, int type=0) noexcept
Sets the drawing target for the rasterization.