9#define TVG_VERSION_MAJOR 1
10#define TVG_VERSION_MINOR 0
11#define TVG_VERSION_MICRO 0
20 #define TVG_API __declspec(dllexport)
22 #define TVG_API __declspec(dllimport)
24 #elif (defined(__SUNPRO_C) || defined(__SUNPRO_CC))
25 #define TVG_API __global
27 #if (defined(__GNUC__) && __GNUC__ >= 4) || defined(__INTEL_COMPILER)
28 #define TVG_API __attribute__ ((visibility("default")))
42 #define TVG_DEPRECATED __declspec(deprecated)
43#elif __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
44 #define TVG_DEPRECATED __attribute__ ((__deprecated__))
46 #define TVG_DEPRECATED
49#define _TVG_DECLARE_PRIVATE(A) \
51 A(const A&) = delete; \
52 const A& operator=(const A&) = delete; \
55#define _TVG_DECLARE_PRIVATE_BASE(A) \
56 _TVG_DECLARE_PRIVATE(A); \
61#define _TVG_DECLARE_PRIVATE_DERIVE(A) \
62 _TVG_DECLARE_PRIVATE(A); \
66#define _TVG_DISABLE_CTOR(A) \
70#define _TVG_DECLARE_ACCESSOR(A) \
425 Result translate(
float x,
float y) noexcept;
536 Result bounds(
float* x,
float* y,
float* w,
float* h) noexcept;
563 bool intersects(int32_t x, int32_t y, int32_t w = 1, int32_t h = 1) noexcept;
579 uint8_t opacity() const noexcept;
615 bool visible() const noexcept;
631 uint16_t ref() noexcept;
648 uint16_t unref(
bool free = true) noexcept;
662 uint16_t refCnt() const noexcept;
673 virtual
Type type() const noexcept = 0;
694 static
void rel(
Paint* paint) noexcept;
699 _TVG_DECLARE_PRIVATE_BASE(
Paint);
786 Fill* duplicate() const noexcept;
797 virtual
Type type() const noexcept = 0;
799 _TVG_DECLARE_PRIVATE_BASE(
Fill);
829 const std::list<Paint*>&
paints() const noexcept;
905 Result draw(
bool clear = false) noexcept;
933 Result viewport(int32_t x, int32_t y, int32_t w, int32_t h) noexcept;
945 _TVG_DECLARE_PRIVATE_BASE(
Canvas);
990 Result linear(
float* x1,
float* y1,
float* x2,
float* y2)
const noexcept;
1008 Type type() const noexcept override;
1048 Result radial(
float cx,
float cy,
float r,
float fx,
float fy,
float fr)
noexcept;
1062 Result radial(
float* cx,
float* cy,
float* r,
float* fx =
nullptr,
float* fy =
nullptr,
float* fr =
nullptr) const noexcept;
1080 Type type() const noexcept override;
1148 Result cubicTo(
float cx1,
float cy1,
float cx2,
float cy2,
float x,
float y) noexcept;
1182 Result appendRect(
float x,
float y,
float w,
float h,
float rx = 0,
float ry = 0,
bool cw = true) noexcept;
1200 Result appendCircle(
float cx,
float cy,
float rx,
float ry,
bool cw = true) noexcept;
1251 Result strokeFill(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255) noexcept;
1284 Result strokeDash(const
float* dashPattern, uint32_t cnt,
float offset = 0.0f) noexcept;
1313 Result strokeMiterlimit(
float miterlimit) noexcept;
1327 Result trimpath(
float begin,
float end,
bool simultaneous = true) noexcept;
1341 Result fill(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255) noexcept;
1406 Result fill(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a =
nullptr) const noexcept;
1424 float strokeWidth() const noexcept;
1435 Result strokeFill(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a =
nullptr) const noexcept;
1442 const
Fill* strokeFill() const noexcept;
1454 uint32_t strokeDash(const
float** dashPattern,
float* offset =
nullptr) const noexcept;
1477 float strokeMiterlimit() const noexcept;
1500 Type type() const noexcept override;
1502 _TVG_DECLARE_PRIVATE_DERIVE(
Shape);
1557 Result load(
const char* data, uint32_t size,
const char* mimeType,
const char* rpath =
nullptr,
bool copy =
false) noexcept;
1578 Result size(
float* w,
float* h) const noexcept;
1622 Result origin(
float* x,
float* y) const noexcept;
1640 Result load(const uint32_t* data, uint32_t w, uint32_t h,
ColorSpace cs,
bool copy = false) noexcept;
1662 Result resolver(std::function<
bool(
Paint* paint, const
char* src,
void* data)> func,
void* data) noexcept;
1677 const
Paint* paint(uint32_t
id) noexcept;
1700 Type type() const noexcept override;
1703 _TVG_DECLARE_PRIVATE_DERIVE(
Picture);
1754 const std::list<
Paint*>& paints() const noexcept;
1809 Type type() const noexcept override;
1811 _TVG_DECLARE_PRIVATE_DERIVE(
Scene);
1964 Result outline(
float width, uint8_t r, uint8_t g, uint8_t b) noexcept;
1978 Result fill(uint8_t r, uint8_t g, uint8_t b) noexcept;
2014 Result spacing(
float letter,
float line) noexcept;
2032 static
Result load(const
char* filename) noexcept;
2059 static
Result load(const
char* name, const
char* data, uint32_t size, const
char* mimeType = "ttf",
bool copy = false) noexcept;
2075 static
Result unload(const
char* filename) noexcept;
2100 Type type() const noexcept override;
2102 _TVG_DECLARE_PRIVATE_DERIVE(
Text);
2304 static const
char* version(uint32_t* major, uint32_t* minor, uint32_t* micro) noexcept;
2362 float curFrame() const noexcept;
2372 float totalFrame() const noexcept;
2381 float duration() const noexcept;
2406 Result segment(
float begin,
float end) noexcept;
2419 Result segment(
float* begin,
float* end =
nullptr) noexcept;
2505 Result save(
Animation* animation, const
char* filename, uint32_t quality = 100, uint32_t fps = 0) noexcept;
2530 _TVG_DECLARE_PRIVATE_BASE(
Saver);
2576 static uint32_t
id(
const char* name)
noexcept;
2585 _TVG_DECLARE_PRIVATE_BASE(
Accessor);
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.
@ 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.