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) \
480 Result translate(
float x,
float y) noexcept;
591 Result bounds(
float* x,
float* y,
float* w,
float* h) noexcept;
596 TVG_DEPRECATED
bool intersects(int32_t x, int32_t y, int32_t w = 1, int32_t h = 1) noexcept;
625 bool intersects(int32_t x, int32_t y, int32_t w, int32_t h,
bool visibleOnly) noexcept;
641 uint8_t opacity() const noexcept;
677 bool visible() const noexcept;
693 uint16_t ref() noexcept;
710 uint16_t unref(
bool free = true) noexcept;
724 uint16_t refCnt() const noexcept;
735 virtual
Type type() const noexcept = 0;
756 static
void rel(
Paint* paint) noexcept;
761 _TVG_DECLARE_PRIVATE_BASE(
Paint);
848 Fill* duplicate() const noexcept;
859 virtual
Type type() const noexcept = 0;
861 _TVG_DECLARE_PRIVATE_BASE(
Fill);
891 const std::list<Paint*>&
paints() const noexcept;
975 Result draw(
bool clear = false) noexcept;
1003 Result viewport(int32_t x, int32_t y, int32_t w, int32_t h) noexcept;
1015 _TVG_DECLARE_PRIVATE_BASE(
Canvas);
1078 Type type() const noexcept override;
1118 Result radial(
float cx,
float cy,
float r,
float fx,
float fy,
float fr)
noexcept;
1132 Result radial(
float* cx,
float* cy,
float* r,
float* fx =
nullptr,
float* fy =
nullptr,
float* fr =
nullptr) const noexcept;
1150 Type type() const noexcept override;
1218 Result cubicTo(
float cx1,
float cy1,
float cx2,
float cy2,
float x,
float y) noexcept;
1252 Result appendRect(
float x,
float y,
float w,
float h,
float rx = 0,
float ry = 0,
bool cw = true) noexcept;
1270 Result appendCircle(
float cx,
float cy,
float rx,
float ry,
bool cw = true) noexcept;
1321 Result strokeFill(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255) noexcept;
1354 Result strokeDash(const
float* dashPattern, uint32_t cnt,
float offset = 0.0f) noexcept;
1383 Result strokeMiterlimit(
float miterlimit) noexcept;
1397 Result trimpath(
float begin,
float end,
bool simultaneous = true) noexcept;
1411 Result fill(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255) noexcept;
1476 Result fill(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a =
nullptr) const noexcept;
1494 float strokeWidth() const noexcept;
1505 Result strokeFill(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a =
nullptr) const noexcept;
1512 const
Fill* strokeFill() const noexcept;
1524 uint32_t strokeDash(const
float** dashPattern,
float* offset =
nullptr) const noexcept;
1547 float strokeMiterlimit() const noexcept;
1570 Type type() const noexcept override;
1572 _TVG_DECLARE_PRIVATE_DERIVE(
Shape);
1628 Result load(
const char* data, uint32_t size,
const char* mimeType,
const char* rpath =
nullptr,
bool copy =
false) noexcept;
1649 Result size(
float* w,
float* h) const noexcept;
1693 Result origin(
float* x,
float* y) const noexcept;
1713 Result load(const uint32_t* data, uint32_t w, uint32_t h,
ColorSpace cs,
bool copy = false) noexcept;
1737 Result resolver(std::function<
bool(
Paint* paint, const
char* src,
void* data)> func,
void* data) noexcept;
1770 const
Paint* paint(uint32_t
id) noexcept;
1793 Type type() const noexcept override;
1795 bool accessible = false;
1798 _TVG_DECLARE_PRIVATE_DERIVE(
Picture);
1856 const std::list<
Paint*>& paints() const noexcept;
1917 Type type() const noexcept override;
1919 _TVG_DECLARE_PRIVATE_DERIVE(
Scene);
2061 uint32_t lines() noexcept;
2101 Result outline(
float width, uint8_t r, uint8_t g, uint8_t b) noexcept;
2115 Result fill(uint8_t r, uint8_t g, uint8_t b) noexcept;
2151 Result spacing(
float letter,
float line) noexcept;
2212 static
Result load(const
char* filename) noexcept;
2239 static
Result load(const
char* name, const
char* data, uint32_t size, const
char* mimeType = "ttf",
bool copy = false) noexcept;
2255 static
Result unload(const
char* filename) noexcept;
2280 Type type() const noexcept override;
2282 _TVG_DECLARE_PRIVATE_DERIVE(
Text);
2541 static const
char* version(uint32_t* major, uint32_t* minor, uint32_t* micro) noexcept;
2599 float curFrame() const noexcept;
2609 float totalFrame() const noexcept;
2618 float duration() const noexcept;
2643 Result segment(
float begin,
float end) noexcept;
2656 Result segment(
float* begin,
float* end =
nullptr) noexcept;
2742 Result save(
Animation* animation, const
char* filename, uint32_t quality = 100, uint32_t fps = 0) noexcept;
2767 _TVG_DECLARE_PRIVATE_BASE(
Saver);
2814 static uint32_t
id(
const char* name)
noexcept;
2836 const char*
name(uint32_t
id)
noexcept;
2845 _TVG_DECLARE_PRIVATE_BASE(
Accessor);
TextWrap
Enumeration that defines methods used for wrapping text.
Definition thorvg.h:295
EngineOption
Enumeration to specify rendering engine behavior.
Definition thorvg.h:134
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:241
Type
Enumeration specifying the ThorVG class type value.
Definition thorvg.h:315
SceneEffect
Enumeration that defines methods used for Scene Effects.
Definition thorvg.h:274
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:216
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
FilterMethod
Defines the image filtering method used during image scaling or transformation.
Definition thorvg.h:202
@ 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
Darkens or lightens the colors, depending on the source color value. If S <= 0.5: D - (1 - 2 * S) * D...
@ Exclusion
The result is twice the product of the top and bottom layers, subtracted from their sum....
@ Saturation
Uses the saturation of the source and the hue and luminosity of the destination.
@ Screen
The values of the pixels in the two layers are inverted, multiplied, and then inverted again....
@ Luminosity
Uses the luminosity of the source and the hue and saturation of the destination.
@ 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
Uses the hue and saturation of the source and the luminosity of the destination.
@ 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
Uses the hue of the source and the saturation and luminosity of the destination.
@ 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],...
@ Clear
Clear 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
Single channel, 1 byte per pixel 8-bit grayscale.
@ 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...
@ Nearest
Fast filtering using nearest-neighbor sampling.
@ Bilinear
Smooth interpolation using surrounding pixels for higher quality.
The Accessor is a utility class to debug the Scene structure by traversing the scene-tree.
Definition thorvg.h:2783
static uint32_t id(const char *name) noexcept
Generate a unique ID (hash key) from a given name.
const char * name(uint32_t id) noexcept
Retrieve the original name string from a given unique ID.
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:2557
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:876
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:782
uint8_t g
Definition thorvg.h:785
float offset
Definition thorvg.h:783
uint8_t b
Definition thorvg.h:786
uint8_t r
Definition thorvg.h:784
uint8_t a
Definition thorvg.h:787
An abstract class representing the gradient fill of the Shape object.
Definition thorvg.h:777
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:2345
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(EngineOption op=EngineOption::Default) noexcept
Creates a new OpenGL/ES Canvas object with optional rendering engine settings.
Describes the layout metrics of a glyph.
Definition thorvg.h:390
float advance
The advance distance along the baseline (inline) direction.
Definition thorvg.h:391
Point max
The maximum point of the glyph bounding box in local space.
Definition thorvg.h:394
Point min
The minimum point of the glyph bounding box in local space.
Definition thorvg.h:393
float bearing
The bearing from the origin to the glyph’s visible bound along the inline-start direction.
Definition thorvg.h:392
A class that enables initialization and termination of the TVG engines.
Definition thorvg.h:2496
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:1030
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:347
An abstract class for managing graphical elements.
Definition thorvg.h:408
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:1588
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:333
float y
The y-coordinate of the point.
Definition thorvg.h:335
float x
The x-coordinate of the point.
Definition thorvg.h:334
A class representing the radial gradient fill of the Shape object.
Definition thorvg.h:1092
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:2687
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:1816
Result add(Paint *target, Paint *at=nullptr) noexcept
Adds a paint object to the scene.
A class representing two-dimensional figures and their properties.
Definition thorvg.h:1171
Result reset() noexcept
Resets the shape path.
A class for the rendering graphical elements with a software raster engine.
Definition thorvg.h:2292
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.
Describes the font metrics of a text object.
Definition thorvg.h:364
float advance
The total vertical advance between lines of text: ascent - descent + linegap (i.e....
Definition thorvg.h:368
float ascent
Distance from the baseline to the top of the highest glyph (usually positive).
Definition thorvg.h:365
float descent
Distance from the baseline to the bottom of the lowest glyph (usually negative, as in TTF).
Definition thorvg.h:366
float linegap
Additional spacing recommended between lines (leading).
Definition thorvg.h:367
A class to represent text objects in a graphical context, allowing for rendering and manipulation of ...
Definition thorvg.h:1933
const char * text() const noexcept
Returns the currently assigned unicode text.
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.
Encapsulates the WebGPU context required for rendering.
Definition thorvg.h:2418
A class for the rendering graphic elements with a WebGPU raster engine.
Definition thorvg.h:2407
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.