ThorVG  v0.14
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 };
170 
171 
181 enum class BlendMethod : uint8_t
182 {
183  Normal = 0,
184  Add,
185  Screen,
186  Multiply,
187  Overlay,
188  Difference,
189  Exclusion,
190  SrcOver,
191  Darken,
192  Lighten,
193  ColorDodge,
194  ColorBurn,
195  HardLight,
196  SoftLight
197 };
198 
199 
203 enum class CanvasEngine
204 {
205  Sw = (1 << 1),
206  Gl = (1 << 2),
207  Wg = (1 << 3),
208 };
209 
210 
214 struct Point
215 {
216  float x, y;
217 };
218 
219 
227 struct Matrix
228 {
229  float e11, e12, e13;
230  float e21, e22, e23;
231  float e31, e32, e33;
232 };
233 
234 
243 struct Vertex
244 {
245  Point pt;
246  Point uv;
247 };
248 
249 
257 struct Polygon
258 {
259  Vertex vertex[3];
260 };
261 
262 
272 class TVG_API Paint
273 {
274 public:
275  virtual ~Paint();
276 
285  Result rotate(float degree) noexcept;
286 
292  Result scale(float factor) noexcept;
293 
303  Result translate(float x, float y) noexcept;
304 
312  Result transform(const Matrix& m) noexcept;
313 
324  Matrix transform() noexcept;
325 
334  Result opacity(uint8_t o) noexcept;
335 
342  Result composite(std::unique_ptr<Paint> target, CompositeMethod method) noexcept;
343 
355  Result blend(BlendMethod method) const noexcept;
356 
360  TVG_DEPRECATED Result bounds(float* x, float* y, float* w, float* h) const noexcept;
361 
375  Result bounds(float* x, float* y, float* w, float* h, bool transformed) const noexcept;
376 
384  Paint* duplicate() const noexcept;
385 
391  uint8_t opacity() const noexcept;
392 
402  CompositeMethod composite(const Paint** target) const noexcept;
403 
411  BlendMethod blend() const noexcept;
412 
420  uint32_t identifier() const noexcept;
421 
422  _TVG_DECLARE_PRIVATE(Paint);
423 };
424 
425 
437 class TVG_API Fill
438 {
439 public:
443  struct ColorStop
444  {
445  float offset;
446  uint8_t r;
447  uint8_t g;
448  uint8_t b;
449  uint8_t a;
450  };
451 
452  virtual ~Fill();
453 
460  Result colorStops(const ColorStop* colorStops, uint32_t cnt) noexcept;
461 
467  Result spread(FillSpread s) noexcept;
468 
476  Result transform(const Matrix& m) noexcept;
477 
485  uint32_t colorStops(const ColorStop** colorStops) const noexcept;
486 
492  FillSpread spread() const noexcept;
493 
501  Matrix transform() const noexcept;
502 
510  Fill* duplicate() const noexcept;
511 
519  uint32_t identifier() const noexcept;
520 
521  _TVG_DECLARE_PRIVATE(Fill);
522 };
523 
524 
535 class TVG_API Canvas
536 {
537 public:
538  Canvas(RenderMethod*);
539  virtual ~Canvas();
540 
541  TVG_DEPRECATED Result reserve(uint32_t n) noexcept;
542 
553  std::list<Paint*>& paints() noexcept;
554 
569  virtual Result push(std::unique_ptr<Paint> paint) noexcept;
570 
584  virtual Result clear(bool free = true) noexcept;
585 
596  virtual Result update(Paint* paint = nullptr) noexcept;
597 
604  virtual Result draw() noexcept;
605 
626  virtual Result viewport(int32_t x, int32_t y, int32_t w, int32_t h) noexcept;
627 
636  virtual Result sync() noexcept;
637 
638  _TVG_DECLARE_PRIVATE(Canvas);
639 };
640 
641 
650 class TVG_API LinearGradient final : public Fill
651 {
652 public:
653  ~LinearGradient();
654 
669  Result linear(float x1, float y1, float x2, float y2) noexcept;
670 
683  Result linear(float* x1, float* y1, float* x2, float* y2) const noexcept;
684 
690  static std::unique_ptr<LinearGradient> gen() noexcept;
691 
699  static uint32_t identifier() noexcept;
700 
701  _TVG_DECLARE_PRIVATE(LinearGradient);
702 };
703 
704 
711 class TVG_API RadialGradient final : public Fill
712 {
713 public:
714  ~RadialGradient();
715 
727  Result radial(float cx, float cy, float radius) noexcept;
728 
739  Result radial(float* cx, float* cy, float* radius) const noexcept;
740 
746  static std::unique_ptr<RadialGradient> gen() noexcept;
747 
755  static uint32_t identifier() noexcept;
756 
757  _TVG_DECLARE_PRIVATE(RadialGradient);
758 };
759 
760 
773 class TVG_API Shape final : public Paint
774 {
775 public:
776  ~Shape();
777 
785  Result reset() noexcept;
786 
795  Result moveTo(float x, float y) noexcept;
796 
807  Result lineTo(float x, float y) noexcept;
808 
824  Result cubicTo(float cx1, float cy1, float cx2, float cy2, float x, float y) noexcept;
825 
833  Result close() noexcept;
834 
857  Result appendRect(float x, float y, float w, float h, float rx = 0, float ry = 0) noexcept;
858 
874  Result appendCircle(float cx, float cy, float rx, float ry) noexcept;
875 
891  Result appendArc(float cx, float cy, float radius, float startAngle, float sweep, bool pie) noexcept;
892 
907  Result appendPath(const PathCommand* cmds, uint32_t cmdCnt, const Point* pts, uint32_t ptsCnt) noexcept;
908 
915  Result stroke(float width) noexcept;
916 
926  Result stroke(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255) noexcept;
927 
935  Result stroke(std::unique_ptr<Fill> f) noexcept;
936 
948  Result stroke(const float* dashPattern, uint32_t cnt) noexcept;
949 
956  Result stroke(StrokeCap cap) noexcept;
957 
966  Result stroke(StrokeJoin join) noexcept;
967 
977  Result strokeMiterlimit(float miterlimit) noexcept;
978 
991  Result strokeTrim(float begin, float end, bool simultaneous = true) noexcept;
992 
1006  Result fill(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255) noexcept;
1007 
1017  Result fill(std::unique_ptr<Fill> f) noexcept;
1018 
1024  Result fill(FillRule r) noexcept;
1025 
1033  Result order(bool strokeFirst) noexcept;
1034 
1042  uint32_t pathCommands(const PathCommand** cmds) const noexcept;
1043 
1051  uint32_t pathCoords(const Point** pts) const noexcept;
1052 
1058  const Fill* fill() const noexcept;
1059 
1070  Result fillColor(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a = nullptr) const noexcept;
1071 
1077  FillRule fillRule() const noexcept;
1078 
1084  float strokeWidth() const noexcept;
1085 
1095  Result strokeColor(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a = nullptr) const noexcept;
1096 
1102  const Fill* strokeFill() const noexcept;
1103 
1111  uint32_t strokeDash(const float** dashPattern) const noexcept;
1112 
1118  StrokeCap strokeCap() const noexcept;
1119 
1125  StrokeJoin strokeJoin() const noexcept;
1126 
1134  float strokeMiterlimit() const noexcept;
1135 
1146  bool strokeTrim(float* begin, float* end) const noexcept;
1147 
1153  static std::unique_ptr<Shape> gen() noexcept;
1154 
1162  static uint32_t identifier() noexcept;
1163 
1164  _TVG_DECLARE_PRIVATE(Shape);
1165 };
1166 
1167 
1177 class TVG_API Picture final : public Paint
1178 {
1179 public:
1180  ~Picture();
1181 
1197  Result load(const std::string& path) noexcept;
1198 
1202  TVG_DEPRECATED Result load(const char* data, uint32_t size, bool copy = false) noexcept;
1203 
1224  Result load(const char* data, uint32_t size, const std::string& mimeType, bool copy = false) noexcept;
1225 
1236  Result size(float w, float h) noexcept;
1237 
1245  Result size(float* w, float* h) const noexcept;
1246 
1262  Result load(uint32_t* data, uint32_t w, uint32_t h, bool copy) noexcept;
1263 
1283  Result mesh(const Polygon* triangles, uint32_t triangleCnt) noexcept;
1284 
1297  uint32_t mesh(const Polygon** triangles) const noexcept;
1298 
1304  static std::unique_ptr<Picture> gen() noexcept;
1305 
1313  static uint32_t identifier() noexcept;
1314 
1315  _TVG_DECLARE_ACCESSOR(Animation);
1316  _TVG_DECLARE_PRIVATE(Picture);
1317 };
1318 
1319 
1331 class TVG_API Scene final : public Paint
1332 {
1333 public:
1334  ~Scene();
1335 
1348  Result push(std::unique_ptr<Paint> paint) noexcept;
1349 
1350  TVG_DEPRECATED Result reserve(uint32_t size) noexcept;
1351 
1364  std::list<Paint*>& paints() noexcept;
1365 
1376  Result clear(bool free = true) noexcept;
1377 
1383  static std::unique_ptr<Scene> gen() noexcept;
1384 
1392  static uint32_t identifier() noexcept;
1393 
1394  _TVG_DECLARE_PRIVATE(Scene);
1395 };
1396 
1397 
1405 class TVG_API Text final : public Paint
1406 {
1407 public:
1408  ~Text();
1409 
1425  Result font(const char* name, float size, const char* style = nullptr) noexcept;
1426 
1437  Result text(const char* text) noexcept;
1438 
1452  Result fill(uint8_t r, uint8_t g, uint8_t b) noexcept;
1453 
1468  Result fill(std::unique_ptr<Fill> f) noexcept;
1469 
1486  static Result load(const std::string& path) noexcept;
1487 
1513  static Result load(const char* name, const char* data, uint32_t size, const std::string& mimeType = "ttf", bool copy = false) noexcept;
1514 
1529  static Result unload(const std::string& path) noexcept;
1530 
1538  static std::unique_ptr<Text> gen() noexcept;
1539 
1547  static uint32_t identifier() noexcept;
1548 
1549  _TVG_DECLARE_PRIVATE(Text);
1550 };
1551 
1552 
1558 class TVG_API SwCanvas final : public Canvas
1559 {
1560 public:
1561  ~SwCanvas();
1562 
1567  {
1568  ABGR8888 = 0,
1572  };
1573 
1579  {
1580  Default = 0,
1582  Individual
1583  };
1584 
1605  Result target(uint32_t* buffer, uint32_t stride, uint32_t w, uint32_t h, Colorspace cs) noexcept;
1606 
1629  Result mempool(MempoolPolicy policy) noexcept;
1630 
1635  static std::unique_ptr<SwCanvas> gen() noexcept;
1636 
1637  _TVG_DECLARE_PRIVATE(SwCanvas);
1638 };
1639 
1640 
1650 class TVG_API GlCanvas final : public Canvas
1651 {
1652 public:
1653  ~GlCanvas();
1654 
1674  Result target(int32_t id, uint32_t w, uint32_t h) noexcept;
1675 
1683  static std::unique_ptr<GlCanvas> gen() noexcept;
1684 
1685  _TVG_DECLARE_PRIVATE(GlCanvas);
1686 };
1687 
1688 
1698 class TVG_API WgCanvas final : public Canvas
1699 {
1700 public:
1701  ~WgCanvas();
1702 
1719  Result target(void* instance, void* surface, uint32_t w, uint32_t h) noexcept;
1720 
1728  static std::unique_ptr<WgCanvas> gen() noexcept;
1729 
1730  _TVG_DECLARE_PRIVATE(WgCanvas);
1731 };
1732 
1733 
1739 class TVG_API Initializer final
1740 {
1741 public:
1758  static Result init(CanvasEngine engine, uint32_t threads) noexcept;
1759 
1771  static Result term(CanvasEngine engine) noexcept;
1772 
1773  _TVG_DISABLE_CTOR(Initializer);
1774 };
1775 
1776 
1787 class TVG_API Animation
1788 {
1789 public:
1790  ~Animation();
1791 
1807  Result frame(float no) noexcept;
1808 
1821  Picture* picture() const noexcept;
1822 
1834  float curFrame() const noexcept;
1835 
1845  float totalFrame() const noexcept;
1846 
1855  float duration() const noexcept;
1856 
1876  Result segment(float begin, float end) noexcept;
1877 
1889  Result segment(float* begin, float* end = nullptr) noexcept;
1890 
1897  static std::unique_ptr<Animation> gen() noexcept;
1898 
1899  _TVG_DECLARE_PRIVATE(Animation);
1900 };
1901 
1902 
1920 class TVG_API Saver final
1921 {
1922 public:
1923  ~Saver();
1924 
1932  Result background(std::unique_ptr<Paint> paint) noexcept;
1933 
1954  Result save(std::unique_ptr<Paint> paint, const std::string& path, bool compress = true) noexcept;
1955 
1977  Result save(std::unique_ptr<Animation> animation, const std::string& path, uint32_t quality = 100, uint32_t fps = 0) noexcept;
1978 
1991  Result sync() noexcept;
1992 
2000  static std::unique_ptr<Saver> gen() noexcept;
2001 
2002  _TVG_DECLARE_PRIVATE(Saver);
2003 };
2004 
2005 
2017 class TVG_API Accessor final
2018 {
2019 public:
2020  ~Accessor();
2021 
2032  std::unique_ptr<Picture> set(std::unique_ptr<Picture> picture, std::function<bool(const Paint* paint)> func) noexcept;
2033 
2039  static std::unique_ptr<Accessor> gen() noexcept;
2040 
2041  _TVG_DECLARE_PRIVATE(Accessor);
2042 };
2043 
2044 
2049 template<typename T = tvg::Paint>
2050 std::unique_ptr<T> cast(Paint* paint)
2051 {
2052  return std::unique_ptr<T>(static_cast<T*>(paint));
2053 }
2054 
2055 
2060 template<typename T = tvg::Fill>
2061 std::unique_ptr<T> cast(Fill* fill)
2062 {
2063  return std::unique_ptr<T>(static_cast<T*>(fill));
2064 }
2065 
2066 
2069 } //namespace
2070 
2071 #endif //_THORVG_H_
The Accessor is a utility class to debug the Scene structure by traversing the scene-tree.
Definition: thorvg.h:2018
std::unique_ptr< Picture > set(std::unique_ptr< Picture > picture, std::function< bool(const Paint *paint)> func) 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:1788
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:536
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:438
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:1651
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:1740
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:651
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:273
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:1178
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:712
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:1921
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:1332
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:774
Result reset() noexcept
Resets the properties of the shape path.
A class for the rendering graphical elements with a software raster engine.
Definition: thorvg.h:1559
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:1567
@ ARGB8888S
The channels are joined in the order: alpha, red, green, blue. Colors are un-alpha-premultiplied.
Definition: thorvg.h:1571
@ ABGR8888S
The channels are joined in the order: alpha, blue, green, red. Colors are un-alpha-premultiplied.
Definition: thorvg.h:1570
@ ARGB8888
The channels are joined in the order: alpha, red, green, blue. Colors are alpha-premultiplied....
Definition: thorvg.h:1569
MempoolPolicy
Enumeration specifying the methods of Memory Pool behavior policy.
Definition: thorvg.h:1579
@ Shareable
Memory Pool is shared among the SwCanvases.
Definition: thorvg.h:1581
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:1406
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:1699
Result target(void *instance, void *surface, uint32_t w, uint32_t h) noexcept
Sets the drawing target for the rasterization.
static std::unique_ptr< WgCanvas > gen() noexcept
Creates a new WgCanvas object.
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:2061
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:204
BlendMethod
Enumeration indicates the method used for blending paint. Please refer to the respective formulas for...
Definition: thorvg.h:182
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
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. (Experimental API)
@ 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...
@ Screen
The values of the pixels in the two layers are inverted, multiplied, and then inverted again....
@ 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.
@ SrcOver
Replace the bottom layer with the top layer.
@ ColorBurn
Divides the inverted bottom layer by the top layer, and then inverts the result. 255 - (255 - D) / S.
@ 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....
@ 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...
@ 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.
@ 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...
@ 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:444
uint8_t g
Definition: thorvg.h:447
float offset
Definition: thorvg.h:445
uint8_t b
Definition: thorvg.h:448
uint8_t r
Definition: thorvg.h:446
uint8_t a
Definition: thorvg.h:449
A data structure representing a three-dimensional matrix.
Definition: thorvg.h:228
A data structure representing a point in two-dimensional space.
Definition: thorvg.h:215
A data structure representing a triange in a texture mesh.
Definition: thorvg.h:258
A data structure representing a texture mesh vertex.
Definition: thorvg.h:244