ThorVG v0.15
Loading...
Searching...
No Matches
thorvg.h
1#ifndef _THORVG_H_
2#define _THORVG_H_
3
4#include <cstdint>
5#include <functional>
6#include <memory>
7#include <string>
8#include <list>
9
10#ifdef TVG_API
11 #undef TVG_API
12#endif
13
14#ifndef TVG_STATIC
15 #ifdef _WIN32
16 #if TVG_BUILD
17 #define TVG_API __declspec(dllexport)
18 #else
19 #define TVG_API __declspec(dllimport)
20 #endif
21 #elif (defined(__SUNPRO_C) || defined(__SUNPRO_CC))
22 #define TVG_API __global
23 #else
24 #if (defined(__GNUC__) && __GNUC__ >= 4) || defined(__INTEL_COMPILER)
25 #define TVG_API __attribute__ ((visibility("default")))
26 #else
27 #define TVG_API
28 #endif
29 #endif
30#else
31 #define TVG_API
32#endif
33
34#ifdef TVG_DEPRECATED
35 #undef TVG_DEPRECATED
36#endif
37
38#ifdef _WIN32
39 #define TVG_DEPRECATED __declspec(deprecated)
40#elif __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
41 #define TVG_DEPRECATED __attribute__ ((__deprecated__))
42#else
43 #define TVG_DEPRECATED
44#endif
45
46#define _TVG_DECLARE_PRIVATE(A) \
47 struct Impl; \
48 Impl* pImpl; \
49protected: \
50 A(const A&) = delete; \
51 const A& operator=(const A&) = delete; \
52 A()
53
54#define _TVG_DISABLE_CTOR(A) \
55 A() = delete; \
56 ~A() = delete
57
58#define _TVG_DECLARE_ACCESSOR(A) \
59 friend A
60
61namespace tvg
62{
63
64class RenderMethod;
65class Animation;
66
91
92
99enum class PathCommand
100{
101 Close = 0,
102 MoveTo,
103 LineTo,
104 CubicTo
105};
106
107
111enum class StrokeCap
112{
113 Square = 0,
114 Round,
115 Butt
116};
117
118
122enum class StrokeJoin
123{
124 Bevel = 0,
125 Round,
126 Miter
127};
128
129
133enum class FillSpread
134{
135 Pad = 0,
136 Reflect,
137 Repeat
138};
139
140
144enum class FillRule
145{
146 Winding = 0,
147 EvenOdd
148};
149
150
159{
160 None = 0,
161 ClipPath,
162 AlphaMask,
164 LumaMask,
166 AddMask,
172};
173
174
184enum class BlendMethod : uint8_t
185{
186 Normal = 0,
187 Multiply,
188 Screen,
189 Overlay,
190 Darken,
191 Lighten,
192 ColorDodge,
193 ColorBurn,
194 HardLight,
195 SoftLight,
196 Difference,
197 Exclusion,
198 Hue,
199 Saturation,
200 Color,
201 Luminosity,
202 Add,
203 HardMix
204};
205
206
217enum class SceneEffect : uint8_t
218{
219 ClearAll = 0,
221 DropShadow,
222 Fill,
223 Tint,
224 Tritone
225};
226
227
231enum class CanvasEngine
232{
233 Sw = (1 << 1),
234 Gl = (1 << 2),
235 Wg = (1 << 3),
236};
237
238
249enum class Type : uint8_t
250{
251 Undefined = 0,
252 Shape,
253 Scene,
254 Picture,
255 Text,
256 LinearGradient = 10,
258};
259
260
264struct Point
265{
266 float x, y;
267};
268
269
277struct Matrix
278{
279 float e11, e12, e13;
280 float e21, e22, e23;
281 float e31, e32, e33;
282};
283
284
294class TVG_API Paint
295{
296public:
297 virtual ~Paint();
298
310 Result rotate(float degree) noexcept;
311
320 Result scale(float factor) noexcept;
321
334 Result translate(float x, float y) noexcept;
335
343 Result transform(const Matrix& m) noexcept;
344
355 Matrix transform() noexcept;
356
364 Result opacity(uint8_t o) noexcept;
365
372 Result composite(std::unique_ptr<Paint> target, CompositeMethod method) noexcept;
373
386 Result clip(std::unique_ptr<Paint> clipper) noexcept;
387
399 Result blend(BlendMethod method) noexcept;
400
404 TVG_DEPRECATED Result bounds(float* x, float* y, float* w, float* h) const noexcept;
405
420 Result bounds(float* x, float* y, float* w, float* h, bool transformed) const noexcept;
421
429 Paint* duplicate() const noexcept;
430
436 uint8_t opacity() const noexcept;
437
447 CompositeMethod composite(const Paint** target) const noexcept;
448
458 virtual Type type() const noexcept = 0;
459
467 uint32_t id = 0;
468
472 TVG_DEPRECATED uint32_t identifier() const noexcept;
473
474 _TVG_DECLARE_PRIVATE(Paint);
475};
476
477
489class TVG_API Fill
490{
491public:
496 {
497 float offset;
498 uint8_t r;
499 uint8_t g;
500 uint8_t b;
501 uint8_t a;
502 };
503
504 virtual ~Fill();
505
512 Result colorStops(const ColorStop* colorStops, uint32_t cnt) noexcept;
513
520
528 Result transform(const Matrix& m) noexcept;
529
537 uint32_t colorStops(const ColorStop** colorStops) const noexcept;
538
544 FillSpread spread() const noexcept;
545
553 Matrix transform() const noexcept;
554
562 Fill* duplicate() const noexcept;
563
573 virtual Type type() const noexcept = 0;
574
578 TVG_DEPRECATED uint32_t identifier() const noexcept;
579
580 _TVG_DECLARE_PRIVATE(Fill);
581};
582
583
594class TVG_API Canvas
595{
596public:
597 Canvas(RenderMethod*);
598 virtual ~Canvas();
599
600 TVG_DEPRECATED Result reserve(uint32_t n) noexcept;
601
612 std::list<Paint*>& paints() noexcept;
613
628 virtual Result push(std::unique_ptr<Paint> paint) noexcept;
629
643 virtual Result clear(bool free = true) noexcept;
644
655 virtual Result update(Paint* paint = nullptr) noexcept;
656
663 virtual Result draw() noexcept;
664
685 virtual Result viewport(int32_t x, int32_t y, int32_t w, int32_t h) noexcept;
686
697 virtual Result sync() noexcept;
698
699 _TVG_DECLARE_PRIVATE(Canvas);
700};
701
702
711class TVG_API LinearGradient final : public Fill
712{
713public:
715
731 Result linear(float x1, float y1, float x2, float y2) noexcept;
732
745 Result linear(float* x1, float* y1, float* x2, float* y2) const noexcept;
746
752 static std::unique_ptr<LinearGradient> gen() noexcept;
753
763 Type type() const noexcept override;
764
768 TVG_DEPRECATED static uint32_t identifier() noexcept;
769
770 _TVG_DECLARE_PRIVATE(LinearGradient);
771};
772
773
780class TVG_API RadialGradient final : public Fill
781{
782public:
784
798 Result radial(float cx, float cy, float radius) noexcept;
799
810 Result radial(float* cx, float* cy, float* radius) const noexcept;
811
817 static std::unique_ptr<RadialGradient> gen() noexcept;
818
828 Type type() const noexcept override;
829
833 TVG_DEPRECATED static uint32_t identifier() noexcept;
834
835 _TVG_DECLARE_PRIVATE(RadialGradient);
836};
837
838
851class TVG_API Shape final : public Paint
852{
853public:
854 ~Shape();
855
863 Result reset() noexcept;
864
873 Result moveTo(float x, float y) noexcept;
874
885 Result lineTo(float x, float y) noexcept;
886
902 Result cubicTo(float cx1, float cy1, float cx2, float cy2, float x, float y) noexcept;
903
911 Result close() noexcept;
912
935 Result appendRect(float x, float y, float w, float h, float rx = 0, float ry = 0) noexcept;
936
952 Result appendCircle(float cx, float cy, float rx, float ry) noexcept;
953
969 TVG_DEPRECATED Result appendArc(float cx, float cy, float radius, float startAngle, float sweep, bool pie) noexcept;
970
985 Result appendPath(const PathCommand* cmds, uint32_t cmdCnt, const Point* pts, uint32_t ptsCnt) noexcept;
986
993 Result stroke(float width) noexcept;
994
1004 Result stroke(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255) noexcept;
1005
1013 Result stroke(std::unique_ptr<Fill> f) noexcept;
1014
1026 Result stroke(const float* dashPattern, uint32_t cnt) noexcept;
1027
1034 Result stroke(StrokeCap cap) noexcept;
1035
1044 Result stroke(StrokeJoin join) noexcept;
1045
1055 Result strokeMiterlimit(float miterlimit) noexcept;
1056
1069 Result strokeTrim(float begin, float end, bool simultaneous = true) noexcept;
1070
1083 Result fill(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255) noexcept;
1084
1094 Result fill(std::unique_ptr<Fill> f) noexcept;
1095
1101 Result fill(FillRule r) noexcept;
1102
1110 Result order(bool strokeFirst) noexcept;
1111
1119 uint32_t pathCommands(const PathCommand** cmds) const noexcept;
1120
1128 uint32_t pathCoords(const Point** pts) const noexcept;
1129
1135 const Fill* fill() const noexcept;
1136
1146 Result fillColor(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a = nullptr) const noexcept;
1147
1153 FillRule fillRule() const noexcept;
1154
1160 float strokeWidth() const noexcept;
1161
1171 Result strokeColor(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a = nullptr) const noexcept;
1172
1178 const Fill* strokeFill() const noexcept;
1179
1187 uint32_t strokeDash(const float** dashPattern) const noexcept;
1188
1194 StrokeCap strokeCap() const noexcept;
1195
1201 StrokeJoin strokeJoin() const noexcept;
1202
1210 float strokeMiterlimit() const noexcept;
1211
1217 static std::unique_ptr<Shape> gen() noexcept;
1218
1228 Type type() const noexcept override;
1229
1233 TVG_DEPRECATED static uint32_t identifier() noexcept;
1234
1235 _TVG_DECLARE_PRIVATE(Shape);
1236};
1237
1238
1248class TVG_API Picture final : public Paint
1249{
1250public:
1251 ~Picture();
1252
1268 Result load(const std::string& path) noexcept;
1269
1273 TVG_DEPRECATED Result load(const char* data, uint32_t size, bool copy = false) noexcept;
1274
1295 Result load(const char* data, uint32_t size, const std::string& mimeType, bool copy = false) noexcept;
1296
1307 Result size(float w, float h) noexcept;
1308
1316 Result size(float* w, float* h) const noexcept;
1317
1333 Result load(uint32_t* data, uint32_t w, uint32_t h, bool copy) noexcept;
1334
1348 const Paint* paint(uint32_t id) noexcept;
1349
1355 static std::unique_ptr<Picture> gen() noexcept;
1356
1366 Type type() const noexcept override;
1367
1371 TVG_DEPRECATED static uint32_t identifier() noexcept;
1372
1373 _TVG_DECLARE_ACCESSOR(Animation);
1374 _TVG_DECLARE_PRIVATE(Picture);
1375};
1376
1377
1389class TVG_API Scene final : public Paint
1390{
1391public:
1392 ~Scene();
1393
1406 Result push(std::unique_ptr<Paint> paint) noexcept;
1407
1408 TVG_DEPRECATED Result reserve(uint32_t size) noexcept;
1409
1422 std::list<Paint*>& paints() noexcept;
1423
1434 Result clear(bool free = true) noexcept;
1435
1448 Result push(SceneEffect effect, ...) noexcept;
1449
1455 static std::unique_ptr<Scene> gen() noexcept;
1456
1466 Type type() const noexcept override;
1467
1471 TVG_DEPRECATED static uint32_t identifier() noexcept;
1472
1473 _TVG_DECLARE_PRIVATE(Scene);
1474};
1475
1476
1484class TVG_API Text final : public Paint
1485{
1486public:
1487 ~Text();
1488
1504 Result font(const char* name, float size, const char* style = nullptr) noexcept;
1505
1516 Result text(const char* text) noexcept;
1517
1529 Result fill(uint8_t r, uint8_t g, uint8_t b) noexcept;
1530
1543 Result fill(std::unique_ptr<Fill> f) noexcept;
1544
1561 static Result load(const std::string& path) noexcept;
1562
1588 static Result load(const char* name, const char* data, uint32_t size, const std::string& mimeType = "ttf", bool copy = false) noexcept;
1589
1604 static Result unload(const std::string& path) noexcept;
1605
1613 static std::unique_ptr<Text> gen() noexcept;
1614
1624 Type type() const noexcept override;
1625
1626 _TVG_DECLARE_PRIVATE(Text);
1627};
1628
1629
1635class TVG_API SwCanvas final : public Canvas
1636{
1637public:
1638 ~SwCanvas();
1639
1644 {
1645 ABGR8888 = 0,
1649 };
1650
1656 {
1657 Default = 0,
1659 Individual
1661
1682 Result target(uint32_t* buffer, uint32_t stride, uint32_t w, uint32_t h, Colorspace cs) noexcept;
1683
1706 Result mempool(MempoolPolicy policy) noexcept;
1707
1712 static std::unique_ptr<SwCanvas> gen() noexcept;
1713
1714 _TVG_DECLARE_PRIVATE(SwCanvas);
1715};
1716
1717
1725class TVG_API GlCanvas final : public Canvas
1726{
1727public:
1728 ~GlCanvas();
1729
1749 Result target(int32_t id, uint32_t w, uint32_t h) noexcept;
1750
1758 static std::unique_ptr<GlCanvas> gen() noexcept;
1759
1760 _TVG_DECLARE_PRIVATE(GlCanvas);
1761};
1762
1763
1773class TVG_API WgCanvas final : public Canvas
1774{
1775public:
1776 ~WgCanvas();
1777
1795 Result target(void* instance, void* surface, uint32_t w, uint32_t h, void* device = nullptr) noexcept;
1796
1804 static std::unique_ptr<WgCanvas> gen() noexcept;
1805
1806 _TVG_DECLARE_PRIVATE(WgCanvas);
1807};
1808
1809
1815class TVG_API Initializer final
1816{
1817public:
1834 static Result init(CanvasEngine engine, uint32_t threads) noexcept;
1835
1847 static Result term(CanvasEngine engine) noexcept;
1848
1860 static const char* version(uint32_t* major, uint32_t* minor, uint32_t* micro) noexcept;
1861
1862 _TVG_DISABLE_CTOR(Initializer);
1863};
1864
1865
1876class TVG_API Animation
1877{
1878public:
1879 ~Animation();
1880
1896 Result frame(float no) noexcept;
1897
1910 Picture* picture() const noexcept;
1911
1923 float curFrame() const noexcept;
1924
1934 float totalFrame() const noexcept;
1935
1944 float duration() const noexcept;
1945
1966 Result segment(float begin, float end) noexcept;
1967
1979 Result segment(float* begin, float* end = nullptr) noexcept;
1980
1987 static std::unique_ptr<Animation> gen() noexcept;
1988
1989 _TVG_DECLARE_PRIVATE(Animation);
1990};
1991
1992
2010class TVG_API Saver final
2011{
2012public:
2013 ~Saver();
2014
2022 Result background(std::unique_ptr<Paint> paint) noexcept;
2023
2044 Result save(std::unique_ptr<Paint> paint, const std::string& path, bool compress = true) noexcept;
2045
2067 Result save(std::unique_ptr<Animation> animation, const std::string& path, uint32_t quality = 100, uint32_t fps = 0) noexcept;
2068
2081 Result sync() noexcept;
2082
2090 static std::unique_ptr<Saver> gen() noexcept;
2091
2092 _TVG_DECLARE_PRIVATE(Saver);
2093};
2094
2095
2107class TVG_API Accessor final
2108{
2109public:
2110 ~Accessor();
2111
2112 TVG_DEPRECATED std::unique_ptr<Picture> set(std::unique_ptr<Picture> picture, std::function<bool(const Paint* paint)> func) noexcept;
2113
2125 Result set(Paint* paint, std::function<bool(const Paint* paint, void* data)> func, void* data) noexcept;
2126
2141 static uint32_t id(const char* name) noexcept;
2142
2148 static std::unique_ptr<Accessor> gen() noexcept;
2149
2150 _TVG_DECLARE_PRIVATE(Accessor);
2151};
2152
2153
2158template<typename T = tvg::Paint>
2159std::unique_ptr<T> cast(Paint* paint)
2160{
2161 return std::unique_ptr<T>(static_cast<T*>(paint));
2162}
2163
2164
2169template<typename T = tvg::Fill>
2170std::unique_ptr<T> cast(Fill* fill)
2171{
2172 return std::unique_ptr<T>(static_cast<T*>(fill));
2173}
2174
2175
2178} //namespace
2179
2180#endif //_THORVG_H_
The Accessor is a utility class to debug the Scene structure by traversing the scene-tree.
Definition thorvg.h:2108
static uint32_t id(const char *name) noexcept
Generate a unique ID (hash key) from a given name.
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 std::unique_ptr< Accessor > gen() noexcept
Creates a new Accessor object.
The Animation class enables manipulation of animatable images.
Definition thorvg.h:1877
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:595
std::list< Paint * > & paints() noexcept
Returns the list of the paints that currently held by the Canvas.
An abstract class representing the gradient fill of the Shape object.
Definition thorvg.h:490
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:1726
Result target(int32_t id, uint32_t w, uint32_t h) noexcept
Sets the drawing target for rasterization.
static std::unique_ptr< GlCanvas > gen() noexcept
Creates a new GlCanvas object.
A class that enables initialization and termination of the TVG engines.
Definition thorvg.h:1816
static const char * version(uint32_t *major, uint32_t *minor, uint32_t *micro) noexcept
Retrieves the version of the TVG engine.
static Result term(CanvasEngine engine) noexcept
Terminates TVG engines.
static Result init(CanvasEngine engine, uint32_t threads) noexcept
Initializes TVG engines.
A class representing the linear gradient fill of the Shape object.
Definition thorvg.h:712
Result linear(float *x1, float *y1, float *x2, float *y2) const noexcept
Gets the linear gradient bounds.
static std::unique_ptr< LinearGradient > gen() noexcept
Creates a new LinearGradient object.
Result linear(float x1, float y1, float x2, float y2) noexcept
Sets the linear gradient bounds.
An abstract class for managing graphical elements.
Definition thorvg.h:295
Result scale(float factor) noexcept
Sets the scale value of the object.
Result rotate(float degree) noexcept
Sets the angle by which the object is rotated.
Result transform(const Matrix &m) noexcept
Sets the matrix of the affine transformation for the object.
Matrix transform() noexcept
Gets the matrix of the affine transformation of the object.
Result translate(float x, float y) noexcept
Sets the values by which the object is moved in a two-dimensional space.
A class representing an image read in one of the supported formats: raw, svg, png,...
Definition thorvg.h:1249
TVG_DEPRECATED Result load(const char *data, uint32_t size, bool copy=false) noexcept
Result load(const std::string &path) noexcept
Loads a picture data directly from a file.
A class representing the radial gradient fill of the Shape object.
Definition thorvg.h:781
Result radial(float cx, float cy, float radius) noexcept
Sets the radial gradient bounds.
Result radial(float *cx, float *cy, float *radius) const noexcept
Gets the radial gradient bounds.
static std::unique_ptr< RadialGradient > gen() noexcept
Creates a new RadialGradient object.
A class for exporting a paint object into a specified file, from which to recover the paint data late...
Definition thorvg.h:2011
Result background(std::unique_ptr< Paint > paint) noexcept
Sets the base background content for the saved image.
Result save(std::unique_ptr< Paint > paint, const std::string &path, bool compress=true) noexcept
Exports the given paint data to the given path.
A class to composite children paints.
Definition thorvg.h:1390
Result push(std::unique_ptr< Paint > paint) noexcept
Passes drawing elements to the Scene using Paint objects.
std::list< Paint * > & paints() noexcept
Returns the list of the paints that currently held by the Scene.
A class representing two-dimensional figures and their properties.
Definition thorvg.h:852
Result reset() noexcept
Resets the shape path.
A class for the rendering graphical elements with a software raster engine.
Definition thorvg.h:1636
Result target(uint32_t *buffer, uint32_t stride, uint32_t w, uint32_t h, Colorspace cs) noexcept
Sets the drawing target for the rasterization.
Result mempool(MempoolPolicy policy) noexcept
Set sw engine memory pool behavior policy.
Colorspace
Enumeration specifying the methods of combining the 8-bit color channels into 32-bit color.
Definition thorvg.h:1644
@ ARGB8888S
The channels are joined in the order: alpha, red, green, blue. Colors are un-alpha-premultiplied.
Definition thorvg.h:1648
@ ABGR8888S
The channels are joined in the order: alpha, blue, green, red. Colors are un-alpha-premultiplied.
Definition thorvg.h:1647
@ ARGB8888
The channels are joined in the order: alpha, red, green, blue. Colors are alpha-premultiplied....
Definition thorvg.h:1646
static std::unique_ptr< SwCanvas > gen() noexcept
Creates a new SwCanvas object.
MempoolPolicy
Enumeration specifying the methods of Memory Pool behavior policy.
Definition thorvg.h:1656
@ Shareable
Memory Pool is shared among the SwCanvases.
Definition thorvg.h:1658
A class to represent text objects in a graphical context, allowing for rendering and manipulation of ...
Definition thorvg.h:1485
Result font(const char *name, float size, const char *style=nullptr) noexcept
Sets the font properties for the text.
A class for the rendering graphic elements with a WebGPU raster engine.
Definition thorvg.h:1774
Result target(void *instance, void *surface, uint32_t w, uint32_t h, void *device=nullptr) noexcept
Sets the drawing target for the rasterization.
FillSpread
Enumeration specifying how to fill the area outside the gradient bounds.
Definition thorvg.h:134
Result
Enumeration specifying the result from the APIs.
Definition thorvg.h:82
CanvasEngine
Enumeration specifying the engine type used for the graphics backend. For multiple backends bitwise o...
Definition thorvg.h:232
BlendMethod
Enumeration indicates the method used for blending paint. Please refer to the respective formulas for...
Definition thorvg.h:185
Type
Enumeration specifying the ThorVG class type value.
Definition thorvg.h:250
StrokeCap
Enumeration determining the ending type of a stroke in the open sub-paths.
Definition thorvg.h:112
PathCommand
Enumeration specifying the values of the path commands accepted by TVG.
Definition thorvg.h:100
SceneEffect
Enumeration that defines methods used for Scene Effects.
Definition thorvg.h:218
std::unique_ptr< T > cast(Paint *paint)
The cast() function is a utility function used to cast a 'Paint' to type 'T'.
Definition thorvg.h:2159
FillRule
Enumeration specifying the algorithm used to establish which parts of the shape are treated as the in...
Definition thorvg.h:145
CompositeMethod
Enumeration indicating the method used in the composition of two objects - the target and the source.
Definition thorvg.h:159
StrokeJoin
Enumeration determining the style used at the corners of joined stroked path segments.
Definition thorvg.h:123
@ 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.
@ 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...
@ Gl
OpenGL rasterizer.
@ Sw
CPU rasterizer.
@ Wg
WebGPU rasterizer.
@ SoftLight
The same as Overlay but with applying pure black or white does not result in pure black or white....
@ Lighten
Only has the opposite action of Darken Only. max(S, D)
@ Exclusion
The result is twice the product of the top and bottom layers, subtracted from their sum....
@ Difference
Subtracts the bottom layer from the top layer or the other way around, to always get a non-negative v...
@ Saturation
Reserved. Not supported.
@ Screen
The values of the pixels in the two layers are inverted, multiplied, and then inverted again....
@ Luminosity
Reserved. Not supported.
@ Overlay
Combines Multiply and Screen blend modes. (2 * S * D) if (2 * D < Da), otherwise (Sa * Da) - 2 * (Da ...
@ 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
Reserved. Not supported.
@ HardLight
The same as Overlay but with the color roles reversed. (2 * S * D) if (S < Sa), otherwise (Sa * Da) -...
@ Multiply
Takes the RGB channel values from 0 to 255 of each pixel in the top layer and multiples them with the...
@ Add
Simply adds pixel values of one layer with the other. (S + D)
@ ColorDodge
Divides the bottom layer by the inverted top layer. D / (255 - S)
@ Darken
Creates a pixel that retains the smallest components of the top and bottom layer pixels....
@ Hue
Reserved. Not supported.
@ HardMix
Reserved. Not supported.
@ Shape
Shape class.
@ Picture
Picture class.
@ Text
Text class.
@ Scene
Scene class.
@ Undefined
Unkown class.
@ 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...
@ 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 paramters (Experimental API)....
@ GaussianBlur
Apply a blur effect with a Gaussian filter. Param(3) = {sigma(float)[> 0], direction(int)[both: 0 / h...
@ DropShadow
Apply a drop shadow effect with a Gaussian Blur filter. Param(8) = {color_R(int)[0 - 255],...
@ ClearAll
Reset all previously applied scene effects, restoring the scene to its original state.
@ Fill
Override the scene content color with a given fill information (Experimental API)....
@ Winding
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...
@ InvLumaMask
Alpha Masking using the grayscale (0.2125R + 0.7154G + 0.0721*B) of the complement to the compositing...
@ LumaMask
Alpha Masking using the grayscale (0.2125R + 0.7154G + 0.0721*B) of the compositing target's pixels.
@ InvAlphaMask
Alpha Masking using the complement to the compositing target's pixels as an alpha value.
@ ClipPath
The intersection of the source and the target is determined and only the resulting pixels from the so...
@ None
No composition is applied.
@ DarkenMask
Where multiple masks intersect, the lowest transparency value is used. (Experimental API)
@ DifferenceMask
Calculates the absolute difference between the target color and the source color multiplied by the co...
@ AddMask
Combines the target and source objects pixels using target alpha. (T * TA) + (S * (255 - TA)) (Experi...
@ SubtractMask
Subtracts the source color from the target color while considering their respective target alpha....
@ AlphaMask
Alpha Masking using the compositing target's pixels as an alpha value.
@ IntersectMask
Computes the result by taking the minimum value between the target alpha and the source alpha and mul...
@ LightenMask
Where multiple masks intersect, the highest transparency value is used. (Experimental API)
@ 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 ...
A data structure storing the information about the color and its relative position inside the gradien...
Definition thorvg.h:496
uint8_t g
Definition thorvg.h:499
float offset
Definition thorvg.h:497
uint8_t b
Definition thorvg.h:500
uint8_t r
Definition thorvg.h:498
uint8_t a
Definition thorvg.h:501
A data structure representing a three-dimensional matrix.
Definition thorvg.h:278
A data structure representing a point in two-dimensional space.
Definition thorvg.h:265