ThorVG v1.0
Loading...
Searching...
No Matches
thorvg.h
1#ifndef _THORVG_H_
2#define _THORVG_H_
3
4#include <cstdint>
5#include <functional>
6#include <list>
7#include <cstdarg>
8
9#define TVG_VERSION_MAJOR 1 // for compile-time checks
10#define TVG_VERSION_MINOR 0 // for compile-time checks
11#define TVG_VERSION_MICRO 0 // for compile-time checks
12
13#ifdef TVG_API
14 #undef TVG_API
15#endif
16
17#ifndef TVG_STATIC
18 #ifdef _WIN32
19 #if TVG_BUILD
20 #define TVG_API __declspec(dllexport)
21 #else
22 #define TVG_API __declspec(dllimport)
23 #endif
24 #elif (defined(__SUNPRO_C) || defined(__SUNPRO_CC))
25 #define TVG_API __global
26 #else
27 #if (defined(__GNUC__) && __GNUC__ >= 4) || defined(__INTEL_COMPILER)
28 #define TVG_API __attribute__ ((visibility("default")))
29 #else
30 #define TVG_API
31 #endif
32 #endif
33#else
34 #define TVG_API
35#endif
36
37#ifdef TVG_DEPRECATED
38 #undef TVG_DEPRECATED
39#endif
40
41#ifdef _WIN32
42 #define TVG_DEPRECATED __declspec(deprecated)
43#elif __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
44 #define TVG_DEPRECATED __attribute__ ((__deprecated__))
45#else
46 #define TVG_DEPRECATED
47#endif
48
49#define _TVG_DECLARE_PRIVATE(A) \
50protected: \
51 A(const A&) = delete; \
52 const A& operator=(const A&) = delete; \
53 A()
54
55#define _TVG_DECLARE_PRIVATE_BASE(A) \
56 _TVG_DECLARE_PRIVATE(A); \
57public: \
58 struct Impl; \
59 Impl* pImpl
60
61#define _TVG_DECLARE_PRIVATE_DERIVE(A) \
62 _TVG_DECLARE_PRIVATE(A); \
63protected: \
64 ~A() {}
65
66#define _TVG_DISABLE_CTOR(A) \
67 A() = delete; \
68 ~A() = delete
69
70#define _TVG_DECLARE_ACCESSOR(A) \
71 friend A
72
73namespace tvg
74{
75
76struct RenderMethod;
77struct Animation;
78struct Shape;
79
94enum struct Result
95{
96 Success = 0,
101 NonSupport,
102 Unknown = 255
103};
104
105
109enum struct ColorSpace : uint8_t
110{
111 ABGR8888 = 0,
112 ARGB8888,
113 ABGR8888S,
114 ARGB8888S,
115 Grayscale8,
116 Unknown = 255
117};
118
119
134enum struct EngineOption : uint8_t
135{
136 None = 0,
137 Default = 1 << 0,
138 SmartRender = 1 << 1
139};
140
141
145enum struct PathCommand : uint8_t
146{
147 Close = 0,
148 MoveTo,
149 LineTo,
150 CubicTo
151};
152
153
157enum struct StrokeCap : uint8_t
158{
159 Butt = 0,
160 Round,
161 Square
162};
163
164
168enum struct StrokeJoin : uint8_t
169{
170 Miter = 0,
171 Round,
172 Bevel
173};
174
175
179enum struct FillSpread : uint8_t
180{
181 Pad = 0,
182 Reflect,
183 Repeat
184};
185
186
190enum struct FillRule : uint8_t
191{
192 NonZero = 0,
193 EvenOdd
194};
195
196
204enum struct MaskMethod : uint8_t
205{
206 None = 0,
207 Alpha,
208 InvAlpha,
209 Luma,
210 InvLuma,
211 Add,
212 Subtract,
213 Intersect,
214 Difference,
215 Lighten,
216 Darken
217};
218
219
229enum struct BlendMethod : uint8_t
230{
231 Normal = 0,
232 Multiply,
233 Screen,
234 Overlay,
235 Darken,
236 Lighten,
237 ColorDodge,
238 ColorBurn,
239 HardLight,
240 SoftLight,
241 Difference,
242 Exclusion,
243 Hue,
244 Saturation,
245 Color,
246 Luminosity,
247 Add,
248 Composition = 255
249};
250
251
262enum struct SceneEffect : uint8_t
263{
264 ClearAll = 0,
266 DropShadow,
267 Fill,
268 Tint,
269 Tritone
270};
271
272
283enum struct TextWrap : uint8_t
284{
285 None = 0,
286 Character,
287 Word,
288 Smart,
289 Ellipsis
290};
291
292
303enum struct Type : uint8_t
304{
305 Undefined = 0,
306 Shape,
307 Scene,
308 Picture,
309 Text,
310 LinearGradient = 10,
312};
313
314
321struct Point
322{
323 float x;
324 float y;
325};
326
327
335struct Matrix
336{
337 float e11, e12, e13;
338 float e21, e22, e23;
339 float e31, e32, e33;
340};
341
342
352struct TVG_API Paint
353{
367 const Paint* parent() const noexcept;
368
388 Result visible(bool on) noexcept;
389
401 Result rotate(float degree) noexcept;
402
411 Result scale(float factor) noexcept;
412
425 Result translate(float x, float y) noexcept;
426
434 Result transform(const Matrix& m) noexcept;
435
446 Matrix& transform() noexcept;
447
455 Result opacity(uint8_t o) noexcept;
456
466 Result mask(Paint* target, MaskMethod method) noexcept;
467
481 Result clip(Shape* clipper) noexcept;
482
494 Result blend(BlendMethod method) noexcept;
495
515 Result bounds(Point* pt4) noexcept;
516
536 Result bounds(float* x, float* y, float* w, float* h) noexcept;
537
563 bool intersects(int32_t x, int32_t y, int32_t w = 1, int32_t h = 1) noexcept;
564
572 Paint* duplicate() const noexcept;
573
579 uint8_t opacity() const noexcept;
580
590 MaskMethod mask(const Paint** target) const noexcept;
591
603 Shape* clip() const noexcept;
604
615 bool visible() const noexcept;
616
631 uint16_t ref() noexcept;
632
648 uint16_t unref(bool free = true) noexcept;
649
662 uint16_t refCnt() const noexcept;
663
673 virtual Type type() const noexcept = 0;
674
682 uint32_t id = 0;
683
694 static void rel(Paint* paint) noexcept;
695
696protected:
697 virtual ~Paint();
698
699 _TVG_DECLARE_PRIVATE_BASE(Paint);
700};
701
702
714struct TVG_API Fill
715{
720 {
721 float offset;
722 uint8_t r;
723 uint8_t g;
724 uint8_t b;
725 uint8_t a;
726 };
727
728 virtual ~Fill();
729
736 Result colorStops(const ColorStop* colorStops, uint32_t cnt) noexcept;
737
744
752 Result transform(const Matrix& m) noexcept;
753
761 uint32_t colorStops(const ColorStop** colorStops) const noexcept;
762
768 FillSpread spread() const noexcept;
769
777 Matrix& transform() const noexcept;
778
786 Fill* duplicate() const noexcept;
787
797 virtual Type type() const noexcept = 0;
798
799 _TVG_DECLARE_PRIVATE_BASE(Fill);
800};
801
802
813struct TVG_API Canvas
814{
815 virtual ~Canvas();
816
829 const std::list<Paint*>& paints() const noexcept;
830
851 Result push(Paint* target, Paint* at = nullptr) noexcept;
852
868 Result remove(Paint* paint = nullptr) noexcept;
869
885 Result update() noexcept;
886
905 Result draw(bool clear = false) noexcept;
906
933 Result viewport(int32_t x, int32_t y, int32_t w, int32_t h) noexcept;
934
943 Result sync() noexcept;
944
945 _TVG_DECLARE_PRIVATE_BASE(Canvas);
946};
947
948
959struct TVG_API LinearGradient : Fill
960{
976 Result linear(float x1, float y1, float x2, float y2) noexcept;
977
990 Result linear(float* x1, float* y1, float* x2, float* y2) const noexcept;
991
997 static LinearGradient* gen() noexcept;
998
1008 Type type() const noexcept override;
1009
1010 _TVG_DECLARE_PRIVATE(LinearGradient);
1011};
1012
1013
1021struct TVG_API RadialGradient : Fill
1022{
1048 Result radial(float cx, float cy, float r, float fx, float fy, float fr) noexcept;
1049
1062 Result radial(float* cx, float* cy, float* r, float* fx = nullptr, float* fy = nullptr, float* fr = nullptr) const noexcept;
1063
1069 static RadialGradient* gen() noexcept;
1070
1080 Type type() const noexcept override;
1081
1082 _TVG_DECLARE_PRIVATE(RadialGradient);
1083};
1084
1085
1100struct TVG_API Shape : Paint
1101{
1109 Result reset() noexcept;
1110
1119 Result moveTo(float x, float y) noexcept;
1120
1131 Result lineTo(float x, float y) noexcept;
1132
1148 Result cubicTo(float cx1, float cy1, float cx2, float cy2, float x, float y) noexcept;
1149
1157 Result close() noexcept;
1158
1182 Result appendRect(float x, float y, float w, float h, float rx = 0, float ry = 0, bool cw = true) noexcept;
1183
1200 Result appendCircle(float cx, float cy, float rx, float ry, bool cw = true) noexcept;
1201
1216 Result appendPath(const PathCommand* cmds, uint32_t cmdCnt, const Point* pts, uint32_t ptsCnt) noexcept;
1217
1231 Result strokeWidth(float width) noexcept;
1232
1251 Result strokeFill(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255) noexcept;
1252
1265 Result strokeFill(Fill* f) noexcept;
1266
1284 Result strokeDash(const float* dashPattern, uint32_t cnt, float offset = 0.0f) noexcept;
1285
1292 Result strokeCap(StrokeCap cap) noexcept;
1293
1302 Result strokeJoin(StrokeJoin join) noexcept;
1303
1313 Result strokeMiterlimit(float miterlimit) noexcept;
1314
1327 Result trimpath(float begin, float end, bool simultaneous = true) noexcept;
1328
1341 Result fill(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255) noexcept;
1342
1352 Result fill(Fill* f) noexcept;
1353
1362 Result fillRule(FillRule r) noexcept;
1363
1371 Result order(bool strokeFirst) noexcept;
1372
1388 Result path(const PathCommand** cmds, uint32_t* cmdsCnt, const Point** pts, uint32_t* ptsCnt) const noexcept;
1389
1395 const Fill* fill() const noexcept;
1396
1406 Result fill(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a = nullptr) const noexcept;
1407
1417 FillRule fillRule() const noexcept;
1418
1424 float strokeWidth() const noexcept;
1425
1435 Result strokeFill(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a = nullptr) const noexcept;
1436
1442 const Fill* strokeFill() const noexcept;
1443
1454 uint32_t strokeDash(const float** dashPattern, float* offset = nullptr) const noexcept;
1455
1461 StrokeCap strokeCap() const noexcept;
1462
1468 StrokeJoin strokeJoin() const noexcept;
1469
1477 float strokeMiterlimit() const noexcept;
1478
1489 static Shape* gen() noexcept;
1490
1500 Type type() const noexcept override;
1501
1502 _TVG_DECLARE_PRIVATE_DERIVE(Shape);
1503};
1504
1505
1517struct TVG_API Picture : Paint
1518{
1534 Result load(const char* filename) noexcept;
1535
1557 Result load(const char* data, uint32_t size, const char* mimeType, const char* rpath = nullptr, bool copy = false) noexcept;
1558
1569 Result size(float w, float h) noexcept;
1570
1578 Result size(float* w, float* h) const noexcept;
1579
1608 Result origin(float x, float y) noexcept;
1609
1622 Result origin(float* x, float* y) const noexcept;
1623
1640 Result load(const uint32_t* data, uint32_t w, uint32_t h, ColorSpace cs, bool copy = false) noexcept;
1641
1662 Result resolver(std::function<bool(Paint* paint, const char* src, void* data)> func, void* data) noexcept;
1663
1677 const Paint* paint(uint32_t id) noexcept;
1678
1689 static Picture* gen() noexcept;
1690
1700 Type type() const noexcept override;
1701
1702 _TVG_DECLARE_ACCESSOR(Animation);
1703 _TVG_DECLARE_PRIVATE_DERIVE(Picture);
1704};
1705
1706
1720struct TVG_API Scene : Paint
1721{
1741 Result push(Paint* target, Paint* at = nullptr) noexcept;
1742
1754 const std::list<Paint*>& paints() const noexcept;
1755
1771 Result remove(Paint* paint = nullptr) noexcept;
1772
1786 Result push(SceneEffect effect, ...) noexcept;
1787
1798 static Scene* gen() noexcept;
1799
1809 Type type() const noexcept override;
1810
1811 _TVG_DECLARE_PRIVATE_DERIVE(Scene);
1812};
1813
1814
1824struct TVG_API Text : Paint
1825{
1844 Result font(const char* name) noexcept;
1845
1864 Result size(float size) noexcept;
1865
1876 Result text(const char* text) noexcept;
1877
1892 Result align(float x, float y) noexcept;
1893
1910 Result layout(float w, float h) noexcept;
1911
1924 Result wrap(TextWrap mode) noexcept;
1925
1946 Result italic(float shear = 0.18f) noexcept;
1947
1964 Result outline(float width, uint8_t r, uint8_t g, uint8_t b) noexcept;
1965
1978 Result fill(uint8_t r, uint8_t g, uint8_t b) noexcept;
1979
1992 Result fill(Fill* f) noexcept;
1993
2014 Result spacing(float letter, float line) noexcept;
2015
2032 static Result load(const char* filename) noexcept;
2033
2059 static Result load(const char* name, const char* data, uint32_t size, const char* mimeType = "ttf", bool copy = false) noexcept;
2060
2075 static Result unload(const char* filename) noexcept;
2076
2089 static Text* gen() noexcept;
2090
2100 Type type() const noexcept override;
2101
2102 _TVG_DECLARE_PRIVATE_DERIVE(Text);
2103};
2104
2105
2111struct TVG_API SwCanvas final : Canvas
2112{
2113 ~SwCanvas() override;
2114
2135 Result target(uint32_t* buffer, uint32_t stride, uint32_t w, uint32_t h, ColorSpace cs) noexcept;
2136
2149 static SwCanvas* gen(EngineOption op = EngineOption::Default) noexcept;
2150
2151 _TVG_DECLARE_PRIVATE(SwCanvas);
2152};
2153
2154
2162struct TVG_API GlCanvas final : Canvas
2163{
2164 ~GlCanvas() override;
2165
2191 Result target(void* display, void* surface, void* context, int32_t id, uint32_t w, uint32_t h, ColorSpace cs) noexcept;
2192
2200 static GlCanvas* gen() noexcept;
2201
2202 _TVG_DECLARE_PRIVATE(GlCanvas);
2203};
2204
2205
2215struct TVG_API WgCanvas final : Canvas
2216{
2217 ~WgCanvas() override;
2218
2238 Result target(void* device, void* instance, void* target, uint32_t w, uint32_t h, ColorSpace cs, int type = 0) noexcept;
2239
2247 static WgCanvas* gen() noexcept;
2248
2249 _TVG_DECLARE_PRIVATE(WgCanvas);
2250};
2251
2252
2258struct TVG_API Initializer final
2259{
2278 static Result init(uint32_t threads = 0) noexcept;
2279
2291 static Result term() noexcept;
2292
2304 static const char* version(uint32_t* major, uint32_t* minor, uint32_t* micro) noexcept;
2305
2306 _TVG_DISABLE_CTOR(Initializer);
2307};
2308
2309
2319struct TVG_API Animation
2320{
2321 virtual ~Animation();
2322
2337 Result frame(float no) noexcept;
2338
2350 Picture* picture() const noexcept;
2351
2362 float curFrame() const noexcept;
2363
2372 float totalFrame() const noexcept;
2373
2381 float duration() const noexcept;
2382
2406 Result segment(float begin, float end) noexcept;
2407
2419 Result segment(float* begin, float* end = nullptr) noexcept;
2420
2426 static Animation* gen() noexcept;
2427
2428 _TVG_DECLARE_PRIVATE_BASE(Animation);
2429};
2430
2431
2449struct TVG_API Saver final
2450{
2451 ~Saver();
2452
2460 Result background(Paint* paint) noexcept;
2461
2482 Result save(Paint* paint, const char* filename, uint32_t quality = 100) noexcept;
2483
2505 Result save(Animation* animation, const char* filename, uint32_t quality = 100, uint32_t fps = 0) noexcept;
2506
2519 Result sync() noexcept;
2520
2528 static Saver* gen() noexcept;
2529
2530 _TVG_DECLARE_PRIVATE_BASE(Saver);
2531};
2532
2533
2545struct TVG_API Accessor final
2546{
2547 ~Accessor();
2548
2560 Result set(Paint* paint, std::function<bool(const Paint* paint, void* data)> func, void* data) noexcept;
2561
2576 static uint32_t id(const char* name) noexcept;
2577
2583 static Accessor* gen() noexcept;
2584
2585 _TVG_DECLARE_PRIVATE_BASE(Accessor);
2586};
2587
2590} //namespace
2591
2592#endif //_THORVG_H_
TextWrap
Enumeration that defines methods used for wrapping text.
Definition thorvg.h:284
EngineOption
Enumeration to specify rendering engine behavior.
Definition thorvg.h:135
StrokeJoin
Enumeration determining the style used at the corners of joined stroked path segments.
Definition thorvg.h:169
Result
Enumeration specifying the result from the APIs.
Definition thorvg.h:95
BlendMethod
Enumeration indicates the method used for blending paint. Please refer to the respective formulas for...
Definition thorvg.h:230
Type
Enumeration specifying the ThorVG class type value.
Definition thorvg.h:304
SceneEffect
Enumeration that defines methods used for Scene Effects.
Definition thorvg.h:263
FillSpread
Enumeration specifying how to fill the area outside the gradient bounds.
Definition thorvg.h:180
ColorSpace
Enumeration specifying the methods of combining the 8-bit color channels into 32-bit color.
Definition thorvg.h:110
MaskMethod
Enumeration indicating the method used in the mask of two objects - the target and the source.
Definition thorvg.h:205
StrokeCap
Enumeration determining the ending type of a stroke in the open sub-paths.
Definition thorvg.h:158
PathCommand
Enumeration specifying the values of the path commands accepted by ThorVG.
Definition thorvg.h:146
FillRule
Enumeration specifying the algorithm used to establish which parts of the shape are treated as the in...
Definition thorvg.h:191
@ Word
Wrap at the word level. Words that do not fit are moved to the next line.
@ Character
Wrap at the character level. If a word cannot fit, it is broken into individual characters to fit the...
@ Ellipsis
Truncate overflowing text and append an ellipsis ("...") at the end. Typically used for single-line l...
@ Smart
Smart choose wrapping method: word wrap first, falling back to character wrap if a word does not fit.
@ Bevel
The outer corner of the joined path segments is bevelled at the join point. The triangular region of ...
@ Miter
The outer corner of the joined path segments is spiked. The spike is created by extension beyond the ...
@ InsufficientCondition
The value returned in case the request cannot be processed - e.g. asking for properties of an object,...
@ Success
The value returned in case of a correct request execution.
@ Unknown
The value returned in all other cases.
@ NonSupport
The value returned in case of choosing unsupported engine features(options).
@ FailedAllocation
The value returned in case of unsuccessful memory allocation.
@ InvalidArguments
The value returned in the event of a problem with the arguments given to the API - e....
@ MemoryCorruption
The value returned in the event of bad memory handling - e.g. failing in pointer releasing or casting...
@ SoftLight
The same as Overlay but with applying pure black or white does not result in pure black or white....
@ Exclusion
The result is twice the product of the top and bottom layers, subtracted from their sum....
@ Saturation
Combine with HSL(Dh + Ss + Dl) then convert it to RGB.
@ Screen
The values of the pixels in the two layers are inverted, multiplied, and then inverted again....
@ Luminosity
Combine with HSL(Dh + Ds + Sl) then convert it to RGB.
@ Composition
For intermediate composition layers; suitable for use with Scene or Picture.
@ Overlay
Combines Multiply and Screen blend modes. (2 * S * D) if (D < 128), otherwise 255 - 2 * (255 - S) * (...
@ Normal
Perform the alpha blending(default). S if (Sa == 255), otherwise (Sa * S) + (255 - Sa) * D.
@ ColorBurn
Divides the inverted bottom layer by the top layer, and then inverts the result. 255 - (255 - D) / S.
@ Color
Combine with HSL(Sh + Ss + Dl) then convert it to RGB.
@ HardLight
The same as Overlay but with the color roles reversed. (2 * S * D) if (S < 128), otherwise 255 - 2 * ...
@ Multiply
Takes the RGB channel values from 0 to 255 of each pixel in the top layer and multiples them with the...
@ ColorDodge
Divides the bottom layer by the inverted top layer. D / (255 - S)
@ Hue
Combine with HSL(Sh + Ds + Dl) then convert it to RGB.
@ Shape
Shape class.
@ Undefined
Unknown class.
@ Tritone
Apply a tritone color effect to the scene using three color parameters for shadows,...
@ Tint
Tinting the current scene color with a given black, white color parameters. Param(7) = {black_R(int)[...
@ GaussianBlur
Apply a blur effect with a Gaussian filter. Param(4) = {sigma(double)[> 0], direction(int)[both: 0 / ...
@ DropShadow
Apply a drop shadow effect with a Gaussian Blur filter. Param(8) = {color_R(int)[0 - 255],...
@ ClearAll
Reset all previously applied scene effects, restoring the scene to its original state.
@ Repeat
The gradient pattern is repeated continuously beyond the gradient area until the expected region is f...
@ Reflect
The gradient pattern is reflected outside the gradient area until the expected region is filled.
@ Pad
The remaining area is filled with the closest stop color.
@ ARGB8888S
The channels are joined in the order: alpha, red, green, blue. Colors are un-alpha-premultiplied.
@ ARGB8888
The channels are joined in the order: alpha, red, green, blue. Colors are alpha-premultiplied.
@ ABGR8888
The channels are joined in the order: alpha, blue, green, red. Colors are alpha-premultiplied.
@ Grayscale8
One single channel data.
@ ABGR8888S
The channels are joined in the order: alpha, blue, green, red. Colors are un-alpha-premultiplied.
@ Lighten
Where multiple masks intersect, the highest transparency value is used.
@ Subtract
Subtracts the source color from the target color while considering their respective target alpha....
@ InvAlpha
Alpha Masking using the complement to the masking target's pixels as an alpha value.
@ Difference
Calculates the absolute difference between the target color and the source color multiplied by the co...
@ InvLuma
Alpha Masking using the grayscale (0.2126R + 0.7152G + 0.0722*B) of the complement to the masking tar...
@ Alpha
Alpha Masking using the masking target's pixels as an alpha value.
@ Intersect
Computes the result by taking the minimum value between the target alpha and the source alpha and mul...
@ Luma
Alpha Masking using the grayscale (0.2126R + 0.7152G + 0.0722*B) of the masking target's pixels.
@ Add
Combines the target and source objects pixels using target alpha. (T * TA) + (S * (255 - TA))
@ Darken
Where multiple masks intersect, the lowest transparency value is used.
@ Butt
The stroke ends exactly at each of the two end-points of a sub-path. For zero length sub-paths no str...
@ Round
The stroke is extended in both end-points of a sub-path by a half circle, with a radius equal to the ...
@ Square
The stroke is extended in both end-points of a sub-path by a rectangle, with the width equal to the s...
@ LineTo
Draws a line from the current point to the given point and sets a new value of the current point....
@ CubicTo
Draws a cubic Bezier curve from the current point to the given point using two given control points a...
@ Close
Ends the current sub-path and connects it with its initial point. This command doesn't expect any poi...
@ MoveTo
Sets a new initial point of the sub-path and a new current point. This command expects 1 point: the s...
@ NonZero
A line from the point to a location outside the shape is drawn. The intersections of the line with th...
@ EvenOdd
A line from the point to a location outside the shape is drawn and its intersections with the path se...
The Accessor is a utility class to debug the Scene structure by traversing the scene-tree.
Definition thorvg.h:2546
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 Accessor * gen() noexcept
Creates a new Accessor object.
The Animation class enables manipulation of animatable images.
Definition thorvg.h:2320
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:814
const std::list< Paint * > & paints() const noexcept
Returns the list of paints currently held by the Canvas.
A data structure storing the information about the color and its relative position inside the gradien...
Definition thorvg.h:720
uint8_t g
Definition thorvg.h:723
float offset
Definition thorvg.h:721
uint8_t b
Definition thorvg.h:724
uint8_t r
Definition thorvg.h:722
uint8_t a
Definition thorvg.h:725
An abstract class representing the gradient fill of the Shape object.
Definition thorvg.h:715
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:2163
Result target(void *display, void *surface, void *context, int32_t id, uint32_t w, uint32_t h, ColorSpace cs) noexcept
Sets the drawing target for rasterization.
static GlCanvas * gen() noexcept
Creates a new GlCanvas object.
A class that enables initialization and termination of the TVG engines.
Definition thorvg.h:2259
static Result init(uint32_t threads=0) noexcept
Initializes the ThorVG engine runtime.
A class representing the linear gradient fill of the Shape object.
Definition thorvg.h:960
static LinearGradient * gen() noexcept
Creates a new LinearGradient object.
Result linear(float *x1, float *y1, float *x2, float *y2) const noexcept
Gets the linear gradient bounds.
Result linear(float x1, float y1, float x2, float y2) noexcept
Sets the linear gradient bounds.
A data structure representing a three-dimensional matrix.
Definition thorvg.h:336
An abstract class for managing graphical elements.
Definition thorvg.h:353
const Paint * parent() const noexcept
Retrieves the parent paint object.
A class representing an image read in one of the supported formats: raw, svg, png,...
Definition thorvg.h:1518
Result load(const char *filename) noexcept
Loads a picture data directly from a file.
Result load(const char *data, uint32_t size, const char *mimeType, const char *rpath=nullptr, bool copy=false) noexcept
Loads a picture data from a memory block of a given size.
A data structure representing a point in two-dimensional space.
Definition thorvg.h:322
float y
The y-coordinate of the point.
Definition thorvg.h:324
float x
The x-coordinate of the point.
Definition thorvg.h:323
A class representing the radial gradient fill of the Shape object.
Definition thorvg.h:1022
Result radial(float cx, float cy, float r, float fx, float fy, float fr) noexcept
Sets the radial gradient attributes.
Result radial(float *cx, float *cy, float *r, float *fx=nullptr, float *fy=nullptr, float *fr=nullptr) const noexcept
Gets the radial gradient attributes.
A class for exporting a paint object into a specified file, from which to recover the paint data late...
Definition thorvg.h:2450
Result background(Paint *paint) noexcept
Sets the base background content for the saved image.
Result save(Paint *paint, const char *filename, uint32_t quality=100) noexcept
Exports the given paint data to the given path.
A class to composite children paints.
Definition thorvg.h:1721
Result push(Paint *target, Paint *at=nullptr) noexcept
Inserts a paint object to the scene.
A class representing two-dimensional figures and their properties.
Definition thorvg.h:1101
Result reset() noexcept
Resets the shape path.
A class for the rendering graphical elements with a software raster engine.
Definition thorvg.h:2112
static SwCanvas * gen(EngineOption op=EngineOption::Default) noexcept
Creates a new SwCanvas object with optional rendering engine settings.
Result target(uint32_t *buffer, uint32_t stride, uint32_t w, uint32_t h, ColorSpace cs) noexcept
Sets the drawing target for the rasterization.
A class to represent text objects in a graphical context, allowing for rendering and manipulation of ...
Definition thorvg.h:1825
Result align(float x, float y) noexcept
Sets text alignment or anchor per axis.
Result layout(float w, float h) noexcept
Sets the virtual layout box (constraints) for the text.
Result wrap(TextWrap mode) noexcept
Sets the text wrapping mode for this text object.
Result font(const char *name) noexcept
Sets the font family for the text.
Result size(float size) noexcept
Sets the font size for the text.
Result text(const char *text) noexcept
Assigns the given unicode text to be rendered.
Result italic(float shear=0.18f) noexcept
Apply an italic (slant) transformation to the text.
A class for the rendering graphic elements with a WebGPU raster engine.
Definition thorvg.h:2216
Result target(void *device, void *instance, void *target, uint32_t w, uint32_t h, ColorSpace cs, int type=0) noexcept
Sets the drawing target for the rasterization.