ThorVG  v0.12
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 
76 enum class Result
77 {
78  Success = 0,
83  NonSupport,
84  Unknown
85 };
86 
87 
94 enum class PathCommand
95 {
96  Close = 0,
97  MoveTo,
98  LineTo,
99  CubicTo
100 };
101 
102 
106 enum class StrokeCap
107 {
108  Square = 0,
109  Round,
110  Butt
111 };
112 
113 
117 enum class StrokeJoin
118 {
119  Bevel = 0,
120  Round,
121  Miter
122 };
123 
124 
128 enum class FillSpread
129 {
130  Pad = 0,
131  Reflect,
132  Repeat
133 };
134 
135 
139 enum class FillRule
140 {
141  Winding = 0,
142  EvenOdd
143 };
144 
145 
153 enum class CompositeMethod
154 {
155  None = 0,
156  ClipPath,
157  AlphaMask,
158  InvAlphaMask,
159  LumaMask,
160  InvLumaMask,
161  AddMask,
162  SubtractMask,
163  IntersectMask,
165 };
166 
167 
177 enum class BlendMethod : uint8_t
178 {
179  Normal = 0,
180  Add,
181  Screen,
182  Multiply,
183  Overlay,
184  Difference,
185  Exclusion,
186  SrcOver,
187  Darken,
188  Lighten,
189  ColorDodge,
190  ColorBurn,
191  HardLight,
192  SoftLight
193 };
194 
195 
199 enum class CanvasEngine
200 {
201  Sw = (1 << 1),
202  Gl = (1 << 2),
203  Wg = (1 << 3),
204 };
205 
206 
210 struct Point
211 {
212  float x, y;
213 };
214 
215 
223 struct Matrix
224 {
225  float e11, e12, e13;
226  float e21, e22, e23;
227  float e31, e32, e33;
228 };
229 
230 
239 struct Vertex
240 {
241  Point pt;
242  Point uv;
243 };
244 
245 
253 struct Polygon
254 {
255  Vertex vertex[3];
256 };
257 
258 
268 class TVG_API Paint
269 {
270 public:
271  virtual ~Paint();
272 
283  Result rotate(float degree) noexcept;
284 
292  Result scale(float factor) noexcept;
293 
305  Result translate(float x, float y) noexcept;
306 
316  Result transform(const Matrix& m) noexcept;
317 
328  Matrix transform() noexcept;
329 
340  Result opacity(uint8_t o) noexcept;
341 
350  Result composite(std::unique_ptr<Paint> target, CompositeMethod method) noexcept;
351 
365  Result blend(BlendMethod method) const noexcept;
366 
381  TVG_DEPRECATED Result bounds(float* x, float* y, float* w, float* h) const noexcept;
382 
398  Result bounds(float* x, float* y, float* w, float* h, bool transformed) const noexcept;
399 
407  Paint* duplicate() const noexcept;
408 
414  uint8_t opacity() const noexcept;
415 
425  CompositeMethod composite(const Paint** target) const noexcept;
426 
434  BlendMethod blend() const noexcept;
435 
443  uint32_t identifier() const noexcept;
444 
445  _TVG_DECLARE_PRIVATE(Paint);
446 };
447 
448 
460 class TVG_API Fill
461 {
462 public:
466  struct ColorStop
467  {
468  float offset;
469  uint8_t r;
470  uint8_t g;
471  uint8_t b;
472  uint8_t a;
473  };
474 
475  virtual ~Fill();
476 
485  Result colorStops(const ColorStop* colorStops, uint32_t cnt) noexcept;
486 
494  Result spread(FillSpread s) noexcept;
495 
505  Result transform(const Matrix& m) noexcept;
506 
514  uint32_t colorStops(const ColorStop** colorStops) const noexcept;
515 
521  FillSpread spread() const noexcept;
522 
530  Matrix transform() const noexcept;
531 
539  Fill* duplicate() const noexcept;
540 
548  uint32_t identifier() const noexcept;
549 
550  _TVG_DECLARE_PRIVATE(Fill);
551 };
552 
553 
564 class TVG_API Canvas
565 {
566 public:
567  Canvas(RenderMethod*);
568  virtual ~Canvas();
569 
580  TVG_DEPRECATED Result reserve(uint32_t n) noexcept;
581 
592  std::list<Paint*>& paints() noexcept;
593 
610  virtual Result push(std::unique_ptr<Paint> paint) noexcept;
611 
626  virtual Result clear(bool free = true) noexcept;
627 
640  virtual Result update(Paint* paint = nullptr) noexcept;
641 
650  virtual Result draw() noexcept;
651 
661  virtual Result sync() noexcept;
662 
663  _TVG_DECLARE_PRIVATE(Canvas);
664 };
665 
666 
675 class TVG_API LinearGradient final : public Fill
676 {
677 public:
678  ~LinearGradient();
679 
696  Result linear(float x1, float y1, float x2, float y2) noexcept;
697 
712  Result linear(float* x1, float* y1, float* x2, float* y2) const noexcept;
713 
719  static std::unique_ptr<LinearGradient> gen() noexcept;
720 
728  static uint32_t identifier() noexcept;
729 
730  _TVG_DECLARE_PRIVATE(LinearGradient);
731 };
732 
733 
740 class TVG_API RadialGradient final : public Fill
741 {
742 public:
743  ~RadialGradient();
744 
756  Result radial(float cx, float cy, float radius) noexcept;
757 
769  Result radial(float* cx, float* cy, float* radius) const noexcept;
770 
776  static std::unique_ptr<RadialGradient> gen() noexcept;
777 
785  static uint32_t identifier() noexcept;
786 
787  _TVG_DECLARE_PRIVATE(RadialGradient);
788 };
789 
790 
803 class TVG_API Shape final : public Paint
804 {
805 public:
806  ~Shape();
807 
817  Result reset() noexcept;
818 
829  Result moveTo(float x, float y) noexcept;
830 
843  Result lineTo(float x, float y) noexcept;
844 
862  Result cubicTo(float cx1, float cy1, float cx2, float cy2, float x, float y) noexcept;
863 
873  Result close() noexcept;
874 
899  Result appendRect(float x, float y, float w, float h, float rx = 0, float ry = 0) noexcept;
900 
917  Result appendCircle(float cx, float cy, float rx, float ry) noexcept;
918 
936  Result appendArc(float cx, float cy, float radius, float startAngle, float sweep, bool pie) noexcept;
937 
954  Result appendPath(const PathCommand* cmds, uint32_t cmdCnt, const Point* pts, uint32_t ptsCnt) noexcept;
955 
963  Result stroke(float width) noexcept;
964 
975  Result stroke(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255) noexcept;
976 
986  Result stroke(std::unique_ptr<Fill> f) noexcept;
987 
1001  Result stroke(const float* dashPattern, uint32_t cnt) noexcept;
1002 
1010  Result stroke(StrokeCap cap) noexcept;
1011 
1021  Result stroke(StrokeJoin join) noexcept;
1022 
1023 
1033  Result strokeMiterlimit(float miterlimit) noexcept;
1034 
1050  Result fill(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255) noexcept;
1051 
1063  Result fill(std::unique_ptr<Fill> f) noexcept;
1064 
1072  Result fill(FillRule r) noexcept;
1073 
1074 
1084  Result order(bool strokeFirst) noexcept;
1085 
1086 
1094  uint32_t pathCommands(const PathCommand** cmds) const noexcept;
1095 
1103  uint32_t pathCoords(const Point** pts) const noexcept;
1104 
1110  const Fill* fill() const noexcept;
1111 
1122  Result fillColor(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a = nullptr) const noexcept;
1123 
1129  FillRule fillRule() const noexcept;
1130 
1136  float strokeWidth() const noexcept;
1137 
1148  Result strokeColor(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a = nullptr) const noexcept;
1149 
1155  const Fill* strokeFill() const noexcept;
1156 
1164  uint32_t strokeDash(const float** dashPattern) const noexcept;
1165 
1171  StrokeCap strokeCap() const noexcept;
1172 
1178  StrokeJoin strokeJoin() const noexcept;
1179 
1187  float strokeMiterlimit() const noexcept;
1188 
1194  static std::unique_ptr<Shape> gen() noexcept;
1195 
1203  static uint32_t identifier() noexcept;
1204 
1205  _TVG_DECLARE_PRIVATE(Shape);
1206 };
1207 
1208 
1218 class TVG_API Picture final : public Paint
1219 {
1220 public:
1221  ~Picture();
1222 
1236  Result load(const std::string& path) noexcept;
1237 
1254  TVG_DEPRECATED Result load(const char* data, uint32_t size, bool copy = false) noexcept;
1255 
1274  Result load(const char* data, uint32_t size, const std::string& mimeType, bool copy = false) noexcept;
1275 
1287  Result size(float w, float h) noexcept;
1288 
1297  Result size(float* w, float* h) const noexcept;
1298 
1314  Result load(uint32_t* data, uint32_t w, uint32_t h, bool copy) noexcept;
1315 
1338  Result mesh(const Polygon* triangles, uint32_t triangleCnt) noexcept;
1339 
1352  uint32_t mesh(const Polygon** triangles) const noexcept;
1353 
1359  static std::unique_ptr<Picture> gen() noexcept;
1360 
1368  static uint32_t identifier() noexcept;
1369 
1370  _TVG_DECLARE_ACCESSOR(Animation);
1371  _TVG_DECLARE_PRIVATE(Picture);
1372 };
1373 
1374 
1386 class TVG_API Scene final : public Paint
1387 {
1388 public:
1389  ~Scene();
1390 
1405  Result push(std::unique_ptr<Paint> paint) noexcept;
1406 
1417  TVG_DEPRECATED Result reserve(uint32_t size) noexcept;
1418 
1431  std::list<Paint*>& paints() noexcept;
1432 
1445  Result clear(bool free = true) noexcept;
1446 
1452  static std::unique_ptr<Scene> gen() noexcept;
1453 
1461  static uint32_t identifier() noexcept;
1462 
1463  _TVG_DECLARE_PRIVATE(Scene);
1464 };
1465 
1466 
1474 class TVG_API Text final : public Paint
1475 {
1476 public:
1477  ~Text();
1478 
1495  Result font(const char* name, float size, const char* style = nullptr) noexcept;
1496 
1509  Result text(const char* text) noexcept;
1510 
1525  Result fill(uint8_t r, uint8_t g, uint8_t b) noexcept;
1526 
1542  Result fill(std::unique_ptr<Fill> f) noexcept;
1543 
1558  static Result load(const std::string& path) noexcept;
1559 
1575  static Result unload(const std::string& path) noexcept;
1576 
1584  static std::unique_ptr<Text> gen() noexcept;
1585 
1593  static uint32_t identifier() noexcept;
1594 
1595  _TVG_DECLARE_PRIVATE(Text);
1596 };
1597 
1598 
1604 class TVG_API SwCanvas final : public Canvas
1605 {
1606 public:
1607  ~SwCanvas();
1608 
1613  {
1614  ABGR8888 = 0,
1618  };
1619 
1625  {
1626  Default = 0,
1628  Individual
1629  };
1630 
1649  Result target(uint32_t* buffer, uint32_t stride, uint32_t w, uint32_t h, Colorspace cs) noexcept;
1650 
1674  Result mempool(MempoolPolicy policy) noexcept;
1675 
1680  static std::unique_ptr<SwCanvas> gen() noexcept;
1681 
1682  _TVG_DECLARE_PRIVATE(SwCanvas);
1683 };
1684 
1685 
1695 class TVG_API GlCanvas final : public Canvas
1696 {
1697 public:
1698  ~GlCanvas();
1699 
1707  Result target(uint32_t* buffer, uint32_t stride, uint32_t w, uint32_t h) noexcept;
1708 
1716  static std::unique_ptr<GlCanvas> gen() noexcept;
1717 
1718  _TVG_DECLARE_PRIVATE(GlCanvas);
1719 };
1720 
1721 
1731 class TVG_API WgCanvas final : public Canvas
1732 {
1733 public:
1734  ~WgCanvas();
1735 
1743  Result target(void* window, uint32_t w, uint32_t h) noexcept;
1744 
1752  static std::unique_ptr<WgCanvas> gen() noexcept;
1753 
1754  _TVG_DECLARE_PRIVATE(WgCanvas);
1755 };
1756 
1757 
1763 class TVG_API Initializer final
1764 {
1765 public:
1786  static Result init(CanvasEngine engine, uint32_t threads) noexcept;
1787 
1802  static Result term(CanvasEngine engine) noexcept;
1803 
1804  _TVG_DISABLE_CTOR(Initializer);
1805 };
1806 
1807 
1818 class TVG_API Animation
1819 {
1820 public:
1821  ~Animation();
1822 
1836  Result frame(float no) noexcept;
1837 
1851  Picture* picture() const noexcept;
1852 
1865  float curFrame() const noexcept;
1866 
1877  float totalFrame() const noexcept;
1878 
1888  float duration() const noexcept;
1889 
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 
1956  Result save(std::unique_ptr<Paint> paint, const std::string& path, bool compress = true) noexcept;
1957 
1981  Result save(std::unique_ptr<Animation> animation, const std::string& path, uint32_t quality = 100, uint32_t fps = 0) noexcept;
1982 
1998  Result sync() noexcept;
1999 
2007  static std::unique_ptr<Saver> gen() noexcept;
2008 
2009  _TVG_DECLARE_PRIVATE(Saver);
2010 };
2011 
2012 
2024 class TVG_API Accessor final
2025 {
2026 public:
2027  ~Accessor();
2028 
2039  std::unique_ptr<Picture> set(std::unique_ptr<Picture> picture, std::function<bool(const Paint* paint)> func) noexcept;
2040 
2046  static std::unique_ptr<Accessor> gen() noexcept;
2047 
2048  _TVG_DECLARE_PRIVATE(Accessor);
2049 };
2050 
2051 
2056 template<typename T = tvg::Paint>
2057 std::unique_ptr<T> cast(Paint* paint)
2058 {
2059  return std::unique_ptr<T>(static_cast<T*>(paint));
2060 }
2061 
2062 
2067 template<typename T = tvg::Fill>
2068 std::unique_ptr<T> cast(Fill* fill)
2069 {
2070  return std::unique_ptr<T>(static_cast<T*>(fill));
2071 }
2072 
2073 
2076 } //namespace
2077 
2078 #endif //_THORVG_H_
The Accessor is a utility class to debug the Scene structure by traversing the scene-tree.
Definition: thorvg.h:2025
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:1819
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:565
TVG_DEPRECATED Result reserve(uint32_t n) noexcept
Sets the size of the container, where all the paints pushed into the Canvas are stored.
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:461
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:1696
Result target(uint32_t *buffer, uint32_t stride, uint32_t w, uint32_t h) noexcept
Sets the target buffer for the 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:1764
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:676
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:269
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:1219
TVG_DEPRECATED Result load(const char *data, uint32_t size, bool copy=false) noexcept
Loads a picture data from a memory block of a given size.
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:741
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:1387
Result push(std::unique_ptr< Paint > paint) noexcept
Passes drawing elements to the Scene using Paint objects.
TVG_DEPRECATED Result reserve(uint32_t size) noexcept
Sets the size of the container, where all the paints pushed into the Scene are stored.
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:804
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:1605
Result target(uint32_t *buffer, uint32_t stride, uint32_t w, uint32_t h, Colorspace cs) noexcept
Sets the target buffer 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:1613
@ ARGB8888S
The channels are joined in the order: alpha, red, green, blue. Colors are un-alpha-premultiplied.
Definition: thorvg.h:1617
@ ABGR8888S
The channels are joined in the order: alpha, blue, green, red. Colors are un-alpha-premultiplied.
Definition: thorvg.h:1616
@ ARGB8888
The channels are joined in the order: alpha, red, green, blue. Colors are alpha-premultiplied....
Definition: thorvg.h:1615
MempoolPolicy
Enumeration specifying the methods of Memory Pool behavior policy.
Definition: thorvg.h:1625
@ Shareable
Memory Pool is shared among the SwCanvases.
Definition: thorvg.h:1627
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:1475
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:1732
Result target(void *window, uint32_t w, uint32_t h) noexcept
Sets the target window 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:129
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:2068
Result
Enumeration specifying the result from the APIs.
Definition: thorvg.h:77
CanvasEngine
Enumeration specifying the engine type used for the graphics backend. For multiple backends bitwise o...
Definition: thorvg.h:200
BlendMethod
Enumeration indicates the method used for blending paint. Please refer to the respective formulas for...
Definition: thorvg.h:178
StrokeCap
Enumeration determining the ending type of a stroke in the open sub-paths.
Definition: thorvg.h:107
PathCommand
Enumeration specifying the values of the path commands accepted by TVG.
Definition: thorvg.h:95
FillRule
Enumeration specifying the algorithm used to establish which parts of the shape are treated as the in...
Definition: thorvg.h:140
CompositeMethod
Enumeration indicating the method used in the composition of two objects - the target and the source.
Definition: thorvg.h:154
StrokeJoin
Enumeration determining the style used at the corners of joined stroked path segments.
Definition: thorvg.h:118
@ 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 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:467
uint8_t g
Definition: thorvg.h:470
float offset
Definition: thorvg.h:468
uint8_t b
Definition: thorvg.h:471
uint8_t r
Definition: thorvg.h:469
uint8_t a
Definition: thorvg.h:472
A data structure representing a three-dimensional matrix.
Definition: thorvg.h:224
A data structure representing a point in two-dimensional space.
Definition: thorvg.h:211
A data structure representing a triange in a texture mesh.
Definition: thorvg.h:254
A data structure representing a texture mesh vertex.
Definition: thorvg.h:240