ThorVG  v0.15
thorvg.h
1 #ifndef _THORVG_H_
2 #define _THORVG_H_
3 
4 #include <functional>
5 #include <memory>
6 #include <string>
7 #include <list>
8 
9 #ifdef TVG_API
10  #undef TVG_API
11 #endif
12 
13 #ifndef TVG_STATIC
14  #ifdef _WIN32
15  #if TVG_BUILD
16  #define TVG_API __declspec(dllexport)
17  #else
18  #define TVG_API __declspec(dllimport)
19  #endif
20  #elif (defined(__SUNPRO_C) || defined(__SUNPRO_CC))
21  #define TVG_API __global
22  #else
23  #if (defined(__GNUC__) && __GNUC__ >= 4) || defined(__INTEL_COMPILER)
24  #define TVG_API __attribute__ ((visibility("default")))
25  #else
26  #define TVG_API
27  #endif
28  #endif
29 #else
30  #define TVG_API
31 #endif
32 
33 #ifdef TVG_DEPRECATED
34  #undef TVG_DEPRECATED
35 #endif
36 
37 #ifdef _WIN32
38  #define TVG_DEPRECATED __declspec(deprecated)
39 #elif __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
40  #define TVG_DEPRECATED __attribute__ ((__deprecated__))
41 #else
42  #define TVG_DEPRECATED
43 #endif
44 
45 #define _TVG_DECLARE_PRIVATE(A) \
46  struct Impl; \
47  Impl* pImpl; \
48 protected: \
49  A(const A&) = delete; \
50  const A& operator=(const A&) = delete; \
51  A()
52 
53 #define _TVG_DISABLE_CTOR(A) \
54  A() = delete; \
55  ~A() = delete
56 
57 #define _TVG_DECLARE_ACCESSOR(A) \
58  friend A
59 
60 namespace tvg
61 {
62 
63 class RenderMethod;
64 class Animation;
65 
80 enum class Result
81 {
82  Success = 0,
87  NonSupport,
88  Unknown
89 };
90 
91 
98 enum class PathCommand
99 {
100  Close = 0,
101  MoveTo,
102  LineTo,
103  CubicTo
104 };
105 
106 
110 enum class StrokeCap
111 {
112  Square = 0,
113  Round,
114  Butt
115 };
116 
117 
121 enum class StrokeJoin
122 {
123  Bevel = 0,
124  Round,
125  Miter
126 };
127 
128 
132 enum class FillSpread
133 {
134  Pad = 0,
135  Reflect,
136  Repeat
137 };
138 
139 
143 enum class FillRule
144 {
145  Winding = 0,
146  EvenOdd
147 };
148 
149 
157 enum class CompositeMethod
158 {
159  None = 0,
160  ClipPath,
161  AlphaMask,
162  InvAlphaMask,
163  LumaMask,
164  InvLumaMask,
165  AddMask,
166  SubtractMask,
167  IntersectMask,
169  LightenMask,
170  DarkenMask
171 };
172 
173 
183 enum class BlendMethod : uint8_t
184 {
185  Normal = 0,
186  Multiply,
187  Screen,
188  Overlay,
189  Darken,
190  Lighten,
191  ColorDodge,
192  ColorBurn,
193  HardLight,
194  SoftLight,
195  Difference,
196  Exclusion,
197  Hue,
198  Saturation,
199  Color,
200  Luminosity,
201  Add,
202  HardMix
203 };
204 
205 
216 enum class SceneEffect : uint8_t
217 {
218  ClearAll = 0,
219  GaussianBlur
220 };
221 
222 
226 enum class CanvasEngine
227 {
228  Sw = (1 << 1),
229  Gl = (1 << 2),
230  Wg = (1 << 3),
231 };
232 
233 
244 enum class Type : uint8_t
245 {
246  Undefined = 0,
247  Shape,
248  Scene,
249  Picture,
250  Text,
251  LinearGradient = 10,
253 };
254 
255 
259 struct Point
260 {
261  float x, y;
262 };
263 
264 
272 struct Matrix
273 {
274  float e11, e12, e13;
275  float e21, e22, e23;
276  float e31, e32, e33;
277 };
278 
279 
289 class TVG_API Paint
290 {
291 public:
292  virtual ~Paint();
293 
305  Result rotate(float degree) noexcept;
306 
315  Result scale(float factor) noexcept;
316 
329  Result translate(float x, float y) noexcept;
330 
338  Result transform(const Matrix& m) noexcept;
339 
350  Matrix transform() noexcept;
351 
359  Result opacity(uint8_t o) noexcept;
360 
367  Result composite(std::unique_ptr<Paint> target, CompositeMethod method) noexcept;
368 
381  Result clip(std::unique_ptr<Paint> clipper) noexcept;
382 
394  Result blend(BlendMethod method) noexcept;
395 
399  TVG_DEPRECATED Result bounds(float* x, float* y, float* w, float* h) const noexcept;
400 
415  Result bounds(float* x, float* y, float* w, float* h, bool transformed) const noexcept;
416 
424  Paint* duplicate() const noexcept;
425 
431  uint8_t opacity() const noexcept;
432 
442  CompositeMethod composite(const Paint** target) const noexcept;
443 
453  virtual Type type() const noexcept = 0;
454 
462  uint32_t id = 0;
463 
467  TVG_DEPRECATED uint32_t identifier() const noexcept;
468 
469  _TVG_DECLARE_PRIVATE(Paint);
470 };
471 
472 
484 class TVG_API Fill
485 {
486 public:
490  struct ColorStop
491  {
492  float offset;
493  uint8_t r;
494  uint8_t g;
495  uint8_t b;
496  uint8_t a;
497  };
498 
499  virtual ~Fill();
500 
507  Result colorStops(const ColorStop* colorStops, uint32_t cnt) noexcept;
508 
514  Result spread(FillSpread s) noexcept;
515 
523  Result transform(const Matrix& m) noexcept;
524 
532  uint32_t colorStops(const ColorStop** colorStops) const noexcept;
533 
539  FillSpread spread() const noexcept;
540 
548  Matrix transform() const noexcept;
549 
557  Fill* duplicate() const noexcept;
558 
568  virtual Type type() const noexcept = 0;
569 
573  TVG_DEPRECATED uint32_t identifier() const noexcept;
574 
575  _TVG_DECLARE_PRIVATE(Fill);
576 };
577 
578 
589 class TVG_API Canvas
590 {
591 public:
592  Canvas(RenderMethod*);
593  virtual ~Canvas();
594 
595  TVG_DEPRECATED Result reserve(uint32_t n) noexcept;
596 
607  std::list<Paint*>& paints() noexcept;
608 
623  virtual Result push(std::unique_ptr<Paint> paint) noexcept;
624 
638  virtual Result clear(bool free = true) noexcept;
639 
650  virtual Result update(Paint* paint = nullptr) noexcept;
651 
658  virtual Result draw() noexcept;
659 
680  virtual Result viewport(int32_t x, int32_t y, int32_t w, int32_t h) noexcept;
681 
692  virtual Result sync() noexcept;
693 
694  _TVG_DECLARE_PRIVATE(Canvas);
695 };
696 
697 
706 class TVG_API LinearGradient final : public Fill
707 {
708 public:
709  ~LinearGradient();
710 
726  Result linear(float x1, float y1, float x2, float y2) noexcept;
727 
740  Result linear(float* x1, float* y1, float* x2, float* y2) const noexcept;
741 
747  static std::unique_ptr<LinearGradient> gen() noexcept;
748 
758  Type type() const noexcept override;
759 
763  TVG_DEPRECATED static uint32_t identifier() noexcept;
764 
765  _TVG_DECLARE_PRIVATE(LinearGradient);
766 };
767 
768 
775 class TVG_API RadialGradient final : public Fill
776 {
777 public:
778  ~RadialGradient();
779 
793  Result radial(float cx, float cy, float radius) noexcept;
794 
805  Result radial(float* cx, float* cy, float* radius) const noexcept;
806 
812  static std::unique_ptr<RadialGradient> gen() noexcept;
813 
823  Type type() const noexcept override;
824 
828  TVG_DEPRECATED static uint32_t identifier() noexcept;
829 
830  _TVG_DECLARE_PRIVATE(RadialGradient);
831 };
832 
833 
846 class TVG_API Shape final : public Paint
847 {
848 public:
849  ~Shape();
850 
858  Result reset() noexcept;
859 
868  Result moveTo(float x, float y) noexcept;
869 
880  Result lineTo(float x, float y) noexcept;
881 
897  Result cubicTo(float cx1, float cy1, float cx2, float cy2, float x, float y) noexcept;
898 
906  Result close() noexcept;
907 
930  Result appendRect(float x, float y, float w, float h, float rx = 0, float ry = 0) noexcept;
931 
947  Result appendCircle(float cx, float cy, float rx, float ry) noexcept;
948 
964  TVG_DEPRECATED Result appendArc(float cx, float cy, float radius, float startAngle, float sweep, bool pie) noexcept;
965 
980  Result appendPath(const PathCommand* cmds, uint32_t cmdCnt, const Point* pts, uint32_t ptsCnt) noexcept;
981 
988  Result stroke(float width) noexcept;
989 
999  Result stroke(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255) noexcept;
1000 
1008  Result stroke(std::unique_ptr<Fill> f) noexcept;
1009 
1021  Result stroke(const float* dashPattern, uint32_t cnt) noexcept;
1022 
1029  Result stroke(StrokeCap cap) noexcept;
1030 
1039  Result stroke(StrokeJoin join) noexcept;
1040 
1050  Result strokeMiterlimit(float miterlimit) noexcept;
1051 
1064  Result strokeTrim(float begin, float end, bool simultaneous = true) noexcept;
1065 
1078  Result fill(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255) noexcept;
1079 
1089  Result fill(std::unique_ptr<Fill> f) noexcept;
1090 
1096  Result fill(FillRule r) noexcept;
1097 
1105  Result order(bool strokeFirst) noexcept;
1106 
1114  uint32_t pathCommands(const PathCommand** cmds) const noexcept;
1115 
1123  uint32_t pathCoords(const Point** pts) const noexcept;
1124 
1130  const Fill* fill() const noexcept;
1131 
1141  Result fillColor(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a = nullptr) const noexcept;
1142 
1148  FillRule fillRule() const noexcept;
1149 
1155  float strokeWidth() const noexcept;
1156 
1166  Result strokeColor(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a = nullptr) const noexcept;
1167 
1173  const Fill* strokeFill() const noexcept;
1174 
1182  uint32_t strokeDash(const float** dashPattern) const noexcept;
1183 
1189  StrokeCap strokeCap() const noexcept;
1190 
1196  StrokeJoin strokeJoin() const noexcept;
1197 
1205  float strokeMiterlimit() const noexcept;
1206 
1212  static std::unique_ptr<Shape> gen() noexcept;
1213 
1223  Type type() const noexcept override;
1224 
1228  TVG_DEPRECATED static uint32_t identifier() noexcept;
1229 
1230  _TVG_DECLARE_PRIVATE(Shape);
1231 };
1232 
1233 
1243 class TVG_API Picture final : public Paint
1244 {
1245 public:
1246  ~Picture();
1247 
1263  Result load(const std::string& path) noexcept;
1264 
1268  TVG_DEPRECATED Result load(const char* data, uint32_t size, bool copy = false) noexcept;
1269 
1290  Result load(const char* data, uint32_t size, const std::string& mimeType, bool copy = false) noexcept;
1291 
1302  Result size(float w, float h) noexcept;
1303 
1311  Result size(float* w, float* h) const noexcept;
1312 
1328  Result load(uint32_t* data, uint32_t w, uint32_t h, bool copy) noexcept;
1329 
1343  const Paint* paint(uint32_t id) noexcept;
1344 
1350  static std::unique_ptr<Picture> gen() noexcept;
1351 
1361  Type type() const noexcept override;
1362 
1366  TVG_DEPRECATED static uint32_t identifier() noexcept;
1367 
1368  _TVG_DECLARE_ACCESSOR(Animation);
1369  _TVG_DECLARE_PRIVATE(Picture);
1370 };
1371 
1372 
1384 class TVG_API Scene final : public Paint
1385 {
1386 public:
1387  ~Scene();
1388 
1401  Result push(std::unique_ptr<Paint> paint) noexcept;
1402 
1403  TVG_DEPRECATED Result reserve(uint32_t size) noexcept;
1404 
1417  std::list<Paint*>& paints() noexcept;
1418 
1429  Result clear(bool free = true) noexcept;
1430 
1443  Result push(SceneEffect effect, ...) noexcept;
1444 
1450  static std::unique_ptr<Scene> gen() noexcept;
1451 
1461  Type type() const noexcept override;
1462 
1466  TVG_DEPRECATED static uint32_t identifier() noexcept;
1467 
1468  _TVG_DECLARE_PRIVATE(Scene);
1469 };
1470 
1471 
1479 class TVG_API Text final : public Paint
1480 {
1481 public:
1482  ~Text();
1483 
1499  Result font(const char* name, float size, const char* style = nullptr) noexcept;
1500 
1511  Result text(const char* text) noexcept;
1512 
1524  Result fill(uint8_t r, uint8_t g, uint8_t b) noexcept;
1525 
1538  Result fill(std::unique_ptr<Fill> f) noexcept;
1539 
1556  static Result load(const std::string& path) noexcept;
1557 
1583  static Result load(const char* name, const char* data, uint32_t size, const std::string& mimeType = "ttf", bool copy = false) noexcept;
1584 
1599  static Result unload(const std::string& path) noexcept;
1600 
1608  static std::unique_ptr<Text> gen() noexcept;
1609 
1619  Type type() const noexcept override;
1620 
1621  _TVG_DECLARE_PRIVATE(Text);
1622 };
1623 
1624 
1630 class TVG_API SwCanvas final : public Canvas
1631 {
1632 public:
1633  ~SwCanvas();
1634 
1639  {
1640  ABGR8888 = 0,
1644  };
1645 
1651  {
1652  Default = 0,
1654  Individual
1655  };
1656 
1677  Result target(uint32_t* buffer, uint32_t stride, uint32_t w, uint32_t h, Colorspace cs) noexcept;
1678 
1701  Result mempool(MempoolPolicy policy) noexcept;
1702 
1707  static std::unique_ptr<SwCanvas> gen() noexcept;
1708 
1709  _TVG_DECLARE_PRIVATE(SwCanvas);
1710 };
1711 
1712 
1720 class TVG_API GlCanvas final : public Canvas
1721 {
1722 public:
1723  ~GlCanvas();
1724 
1744  Result target(int32_t id, uint32_t w, uint32_t h) noexcept;
1745 
1753  static std::unique_ptr<GlCanvas> gen() noexcept;
1754 
1755  _TVG_DECLARE_PRIVATE(GlCanvas);
1756 };
1757 
1758 
1768 class TVG_API WgCanvas final : public Canvas
1769 {
1770 public:
1771  ~WgCanvas();
1772 
1790  Result target(void* instance, void* surface, uint32_t w, uint32_t h, void* device = nullptr) noexcept;
1791 
1799  static std::unique_ptr<WgCanvas> gen() noexcept;
1800 
1801  _TVG_DECLARE_PRIVATE(WgCanvas);
1802 };
1803 
1804 
1810 class TVG_API Initializer final
1811 {
1812 public:
1829  static Result init(CanvasEngine engine, uint32_t threads) noexcept;
1830 
1842  static Result term(CanvasEngine engine) noexcept;
1843 
1855  static const char* version(uint32_t* major, uint32_t* minor, uint32_t* micro) noexcept;
1856 
1857  _TVG_DISABLE_CTOR(Initializer);
1858 };
1859 
1860 
1871 class TVG_API Animation
1872 {
1873 public:
1874  ~Animation();
1875 
1891  Result frame(float no) noexcept;
1892 
1905  Picture* picture() const noexcept;
1906 
1918  float curFrame() const noexcept;
1919 
1929  float totalFrame() const noexcept;
1930 
1939  float duration() const noexcept;
1940 
1961  Result segment(float begin, float end) noexcept;
1962 
1974  Result segment(float* begin, float* end = nullptr) noexcept;
1975 
1982  static std::unique_ptr<Animation> gen() noexcept;
1983 
1984  _TVG_DECLARE_PRIVATE(Animation);
1985 };
1986 
1987 
2005 class TVG_API Saver final
2006 {
2007 public:
2008  ~Saver();
2009 
2017  Result background(std::unique_ptr<Paint> paint) noexcept;
2018 
2039  Result save(std::unique_ptr<Paint> paint, const std::string& path, bool compress = true) noexcept;
2040 
2062  Result save(std::unique_ptr<Animation> animation, const std::string& path, uint32_t quality = 100, uint32_t fps = 0) noexcept;
2063 
2076  Result sync() noexcept;
2077 
2085  static std::unique_ptr<Saver> gen() noexcept;
2086 
2087  _TVG_DECLARE_PRIVATE(Saver);
2088 };
2089 
2090 
2102 class TVG_API Accessor final
2103 {
2104 public:
2105  ~Accessor();
2106 
2107  TVG_DEPRECATED std::unique_ptr<Picture> set(std::unique_ptr<Picture> picture, std::function<bool(const Paint* paint)> func) noexcept;
2108 
2120  Result set(const Picture* picture, std::function<bool(const Paint* paint, void* data)> func, void* data) noexcept;
2121 
2136  static uint32_t id(const char* name) noexcept;
2137 
2143  static std::unique_ptr<Accessor> gen() noexcept;
2144 
2145  _TVG_DECLARE_PRIVATE(Accessor);
2146 };
2147 
2148 
2153 template<typename T = tvg::Paint>
2154 std::unique_ptr<T> cast(Paint* paint)
2155 {
2156  return std::unique_ptr<T>(static_cast<T*>(paint));
2157 }
2158 
2159 
2164 template<typename T = tvg::Fill>
2165 std::unique_ptr<T> cast(Fill* fill)
2166 {
2167  return std::unique_ptr<T>(static_cast<T*>(fill));
2168 }
2169 
2170 
2173 } //namespace
2174 
2175 #endif //_THORVG_H_
The Accessor is a utility class to debug the Scene structure by traversing the scene-tree.
Definition: thorvg.h:2103
Result set(const Picture *picture, std::function< bool(const Paint *paint, void *data)> func, void *data) noexcept
Set the access function for traversing the Picture scene tree nodes.
static uint32_t id(const char *name) noexcept
Generate a unique ID (hash key) from a given name.
static std::unique_ptr< Accessor > gen() noexcept
Creates a new Accessor object.
The Animation class enables manipulation of animatable images.
Definition: thorvg.h:1872
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:590
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:485
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:1721
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:1811
static Result term(CanvasEngine engine) noexcept
Terminates TVG engines.
static Result init(CanvasEngine engine, uint32_t threads) noexcept
Initializes TVG engines.
static const char * version(uint32_t *major, uint32_t *minor, uint32_t *micro) noexcept
Retrieves the version of the TVG engine.
A class representing the linear gradient fill of the Shape object.
Definition: thorvg.h:707
static std::unique_ptr< 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.
An abstract class for managing graphical elements.
Definition: thorvg.h:290
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:1244
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:776
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:2006
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:1385
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:847
Result reset() noexcept
Resets the shape path.
A class for the rendering graphical elements with a software raster engine.
Definition: thorvg.h:1631
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:1639
@ ARGB8888S
The channels are joined in the order: alpha, red, green, blue. Colors are un-alpha-premultiplied.
Definition: thorvg.h:1643
@ ABGR8888S
The channels are joined in the order: alpha, blue, green, red. Colors are un-alpha-premultiplied.
Definition: thorvg.h:1642
@ ARGB8888
The channels are joined in the order: alpha, red, green, blue. Colors are alpha-premultiplied....
Definition: thorvg.h:1641
MempoolPolicy
Enumeration specifying the methods of Memory Pool behavior policy.
Definition: thorvg.h:1651
@ Shareable
Memory Pool is shared among the SwCanvases.
Definition: thorvg.h:1653
static std::unique_ptr< SwCanvas > gen() noexcept
Creates a new SwCanvas object.
A class to represent text objects in a graphical context, allowing for rendering and manipulation of ...
Definition: thorvg.h:1480
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:1769
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:133
std::unique_ptr< T > cast(Fill *fill)
The cast() function is a utility function used to cast a 'Fill' to type 'T'.
Definition: thorvg.h:2165
Result
Enumeration specifying the result from the APIs.
Definition: thorvg.h:81
CanvasEngine
Enumeration specifying the engine type used for the graphics backend. For multiple backends bitwise o...
Definition: thorvg.h:227
BlendMethod
Enumeration indicates the method used for blending paint. Please refer to the respective formulas for...
Definition: thorvg.h:184
Type
Enumeration specifying the ThorVG class type value.
Definition: thorvg.h:245
StrokeCap
Enumeration determining the ending type of a stroke in the open sub-paths.
Definition: thorvg.h:111
PathCommand
Enumeration specifying the values of the path commands accepted by TVG.
Definition: thorvg.h:99
SceneEffect
Enumeration that defines methods used for Scene Effects.
Definition: thorvg.h:217
FillRule
Enumeration specifying the algorithm used to establish which parts of the shape are treated as the in...
Definition: thorvg.h:144
CompositeMethod
Enumeration indicating the method used in the composition of two objects - the target and the source.
Definition: thorvg.h:158
StrokeJoin
Enumeration determining the style used at the corners of joined stroked path segments.
Definition: thorvg.h:122
@ 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...
@ GaussianBlur
Apply a blur effect with a Gaussian filter. Param(3) = {sigma(float)[> 0], direction(int)[both: 0 / h...
@ ClearAll
Reset all previously applied scene effects, restoring the scene to its original state.
@ 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 ...
@ Round
The outer corner of the joined path segments is rounded. The circular region is centered at the join ...
@ 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:491
uint8_t g
Definition: thorvg.h:494
float offset
Definition: thorvg.h:492
uint8_t b
Definition: thorvg.h:495
uint8_t r
Definition: thorvg.h:493
uint8_t a
Definition: thorvg.h:496
A data structure representing a three-dimensional matrix.
Definition: thorvg.h:273
A data structure representing a point in two-dimensional space.
Definition: thorvg.h:260