ThorVG v1.0
Loading...
Searching...
No Matches
ThorVG

ThorVG classes and enumerations providing C++ APIs. More...

Classes

struct  Point
 A data structure representing a point in two-dimensional space. More...
 
struct  Matrix
 A data structure representing a three-dimensional matrix. More...
 
class  Paint
 An abstract class for managing graphical elements. More...
 
class  Fill
 An abstract class representing the gradient fill of the Shape object. More...
 
class  Canvas
 An abstract class for drawing graphical elements. More...
 
class  LinearGradient
 A class representing the linear gradient fill of the Shape object. More...
 
class  RadialGradient
 A class representing the radial gradient fill of the Shape object. More...
 
class  Shape
 A class representing two-dimensional figures and their properties. More...
 
class  Picture
 A class representing an image read in one of the supported formats: raw, svg, png, jpg, lot and etc. Besides the methods inherited from the Paint, it provides methods to load & draw images on the canvas. More...
 
class  Scene
 A class to composite children paints. More...
 
class  Text
 A class to represent text objects in a graphical context, allowing for rendering and manipulation of unicode text. More...
 
class  SwCanvas
 A class for the rendering graphical elements with a software raster engine. More...
 
class  GlCanvas
 A class for the rendering graphic elements with a GL raster engine. More...
 
class  WgCanvas
 A class for the rendering graphic elements with a WebGPU raster engine. More...
 
class  Initializer
 A class that enables initialization and termination of the TVG engines. More...
 
class  Animation
 The Animation class enables manipulation of animatable images. More...
 
class  Saver
 A class for exporting a paint object into a specified file, from which to recover the paint data later. More...
 
class  Accessor
 The Accessor is a utility class to debug the Scene structure by traversing the scene-tree. More...
 

Enumerations

enum struct  Result {
  Success = 0 , InvalidArguments , InsufficientCondition , FailedAllocation ,
  MemoryCorruption , NonSupport , Unknown = 255
}
 Enumeration specifying the result from the APIs. More...
 
enum struct  ColorSpace : uint8_t {
  ABGR8888 = 0 , ARGB8888 , ABGR8888S , ARGB8888S ,
  Grayscale8 , Unknown = 255
}
 Enumeration specifying the methods of combining the 8-bit color channels into 32-bit color. More...
 
enum struct  EngineOption : uint8_t { None = 0 , Default = 1 << 0 , SmartRender = 1 << 1 }
 Enumeration to specify rendering engine behavior. More...
 
enum struct  PathCommand : uint8_t { Close = 0 , MoveTo , LineTo , CubicTo }
 Enumeration specifying the values of the path commands accepted by ThorVG. More...
 
enum struct  StrokeCap : uint8_t { Butt = 0 , Round , Square }
 Enumeration determining the ending type of a stroke in the open sub-paths. More...
 
enum struct  StrokeJoin : uint8_t { Miter = 0 , Round , Bevel }
 Enumeration determining the style used at the corners of joined stroked path segments. More...
 
enum struct  FillSpread : uint8_t { Pad = 0 , Reflect , Repeat }
 Enumeration specifying how to fill the area outside the gradient bounds. More...
 
enum struct  FillRule : uint8_t { NonZero = 0 , EvenOdd }
 Enumeration specifying the algorithm used to establish which parts of the shape are treated as the inside of the shape. More...
 
enum struct  MaskMethod : uint8_t {
  None = 0 , Alpha , InvAlpha , Luma ,
  InvLuma , Add , Subtract , Intersect ,
  Difference , Lighten , Darken
}
 Enumeration indicating the method used in the mask of two objects - the target and the source. More...
 
enum struct  BlendMethod : uint8_t {
  Normal = 0 , Multiply , Screen , Overlay ,
  Darken , Lighten , ColorDodge , ColorBurn ,
  HardLight , SoftLight , Difference , Exclusion ,
  Hue , Saturation , Color , Luminosity ,
  Add , Composition = 255
}
 Enumeration indicates the method used for blending paint. Please refer to the respective formulas for each method. More...
 
enum struct  SceneEffect : uint8_t {
  ClearAll = 0 , GaussianBlur , DropShadow , Fill ,
  Tint , Tritone
}
 Enumeration that defines methods used for Scene Effects. More...
 
enum struct  TextWrap : uint8_t {
  None = 0 , Character , Word , Smart ,
  Ellipsis
}
 Enumeration that defines methods used for wrapping text. More...
 
enum struct  Type : uint8_t {
  Undefined = 0 , Shape , Scene , Picture ,
  Text , LinearGradient = 10 , RadialGradient
}
 Enumeration specifying the ThorVG class type value. More...
 

Detailed Description

ThorVG classes and enumerations providing C++ APIs.

Enumeration Type Documentation

◆ BlendMethod

enum struct BlendMethod : uint8_t
strong

Enumeration indicates the method used for blending paint. Please refer to the respective formulas for each method.

Notation: S(source paint as the top layer), D(destination as the bottom layer), Sa(source paint alpha), Da(destination alpha)

See also
Paint::blend()
Since
0.15
Enumerator
Normal 

Perform the alpha blending(default). S if (Sa == 255), otherwise (Sa * S) + (255 - Sa) * D.

Multiply 

Takes the RGB channel values from 0 to 255 of each pixel in the top layer and multiples them with the values for the corresponding pixel from the bottom layer. (S * D)

Screen 

The values of the pixels in the two layers are inverted, multiplied, and then inverted again. (S + D) - (S * D)

Overlay 

Combines Multiply and Screen blend modes. (2 * S * D) if (D < 128), otherwise 255 - 2 * (255 - S) * (255 - D)

Darken 

Creates a pixel that retains the smallest components of the top and bottom layer pixels. min(S, D)

Lighten 

Only has the opposite action of Darken Only. max(S, D)

ColorDodge 

Divides the bottom layer by the inverted top layer. D / (255 - S)

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 < 128), otherwise 255 - 2 * (255 - S) * (255 - D)

SoftLight 

The same as Overlay but with applying pure black or white does not result in pure black or white. (255 - 2 * S) * (D * D) + (2 * S * D)

Difference 

Subtracts the bottom layer from the top layer or the other way around, to always get a non-negative value. (S - D) if (S > D), otherwise (D - S)

Exclusion 

The result is twice the product of the top and bottom layers, subtracted from their sum. S + D - (2 * S * D)

Hue 

Combine with HSL(Sh + Ds + Dl) then convert it to RGB.

Since
1.0
Saturation 

Combine with HSL(Dh + Ss + Dl) then convert it to RGB.

Since
1.0
Color 

Combine with HSL(Sh + Ss + Dl) then convert it to RGB.

Since
1.0
Luminosity 

Combine with HSL(Dh + Ds + Sl) then convert it to RGB.

Since
1.0
Add 

Simply adds pixel values of one layer with the other. (S + D)

Composition 

For intermediate composition layers; suitable for use with Scene or Picture.

Since
1.0

◆ ColorSpace

enum struct ColorSpace : uint8_t
strong

Enumeration specifying the methods of combining the 8-bit color channels into 32-bit color.

Enumerator
ABGR8888 

The channels are joined in the order: alpha, blue, green, red. Colors are alpha-premultiplied.

ARGB8888 

The channels are joined in the order: alpha, red, green, blue. Colors are alpha-premultiplied.

ABGR8888S 

The channels are joined in the order: alpha, blue, green, red. Colors are un-alpha-premultiplied.

Since
0.12
ARGB8888S 

The channels are joined in the order: alpha, red, green, blue. Colors are un-alpha-premultiplied.

Since
0.12
Grayscale8 

One single channel data.

Unknown 

Unknown channel data. This is reserved for an initial ColorSpace value.

Since
1.0

◆ EngineOption

enum struct EngineOption : uint8_t
strong

Enumeration to specify rendering engine behavior.

Note
The availability or behavior of SmartRender may vary depending on platform or backend support. It attempts to optimize rendering performance by updating only the regions of the canvas that have changed between frames (partial redraw). This can be highly effective in scenarios where most of the canvas remains static and only small portions are updated—such as simple animations or GUI interactions. However, in complex scenes where a large portion of the canvas changes frequently (e.g., full-screen animations or heavy object movements), the overhead of tracking changes and managing update regions may outweigh the benefits, resulting in decreased performance compared to the default rendering mode. Thus, it is recommended to benchmark both modes in your specific use case to determine the optimal setting.
Since
1.0
Enumerator
None 

No engine options are enabled. This may be used to explicitly disable all optional behaviors.

Default 

Uses the default rendering mode.

SmartRender 

Enables automatic partial (smart) rendering optimizations.

◆ FillRule

enum struct FillRule : uint8_t
strong

Enumeration specifying the algorithm used to establish which parts of the shape are treated as the inside of the shape.

Enumerator
NonZero 

A line from the point to a location outside the shape is drawn. The intersections of the line with the path segment of the shape are counted. Starting from zero, if the path segment of the shape crosses the line clockwise, one is added, otherwise one is subtracted. If the resulting sum is non zero, the point is inside the shape.

EvenOdd 

A line from the point to a location outside the shape is drawn and its intersections with the path segments of the shape are counted. If the number of intersections is an odd number, the point is inside the shape.

◆ FillSpread

enum struct FillSpread : uint8_t
strong

Enumeration specifying how to fill the area outside the gradient bounds.

Enumerator
Pad 

The remaining area is filled with the closest stop color.

Reflect 

The gradient pattern is reflected outside the gradient area until the expected region is filled.

Repeat 

The gradient pattern is repeated continuously beyond the gradient area until the expected region is filled.

◆ MaskMethod

enum struct MaskMethod : uint8_t
strong

Enumeration indicating the method used in the mask of two objects - the target and the source.

Notation: S(Source), T(Target), SA(Source Alpha), TA(Target Alpha)

See also
Paint::mask()
Enumerator
None 

No Masking is applied.

Alpha 

Alpha Masking using the masking target's pixels as an alpha value.

InvAlpha 

Alpha Masking using the complement to the masking target's pixels as an alpha value.

Luma 

Alpha Masking using the grayscale (0.2126R + 0.7152G + 0.0722*B) of the masking target's pixels.

Since
0.9
InvLuma 

Alpha Masking using the grayscale (0.2126R + 0.7152G + 0.0722*B) of the complement to the masking target's pixels.

Since
0.11
Add 

Combines the target and source objects pixels using target alpha. (T * TA) + (S * (255 - TA))

Since
1.0
Subtract 

Subtracts the source color from the target color while considering their respective target alpha. (T * TA) - (S * (255 - TA))

Since
1.0
Intersect 

Computes the result by taking the minimum value between the target alpha and the source alpha and multiplies it with the target color. (T * min(TA, SA))

Since
1.0
Difference 

Calculates the absolute difference between the target color and the source color multiplied by the complement of the target alpha. abs(T - S * (255 - TA))

Since
1.0
Lighten 

Where multiple masks intersect, the highest transparency value is used.

Since
1.0
Darken 

Where multiple masks intersect, the lowest transparency value is used.

Since
1.0

◆ PathCommand

enum struct PathCommand : uint8_t
strong

Enumeration specifying the values of the path commands accepted by ThorVG.

Enumerator
Close 

Ends the current sub-path and connects it with its initial point. This command doesn't expect any points.

MoveTo 

Sets a new initial point of the sub-path and a new current point. This command expects 1 point: the starting position.

LineTo 

Draws a line from the current point to the given point and sets a new value of the current point. This command expects 1 point: the end-position of the line.

CubicTo 

Draws a cubic Bezier curve from the current point to the given point using two given control points and sets a new value of the current point. This command expects 3 points: the 1st control-point, the 2nd control-point, the end-point of the curve.

◆ Result

enum struct Result
strong

Enumeration specifying the result from the APIs.

All ThorVG APIs could potentially return one of the values in the list. Please note that some APIs may additionally specify the reasons that trigger their return values.

Enumerator
Success 

The value returned in case of a correct request execution.

InvalidArguments 

The value returned in the event of a problem with the arguments given to the API - e.g. empty paths or null pointers.

InsufficientCondition 

The value returned in case the request cannot be processed - e.g. asking for properties of an object, which does not exist.

FailedAllocation 

The value returned in case of unsuccessful memory allocation.

MemoryCorruption 

The value returned in the event of bad memory handling - e.g. failing in pointer releasing or casting.

NonSupport 

The value returned in case of choosing unsupported engine features(options).

Unknown 

The value returned in all other cases.

◆ SceneEffect

enum struct SceneEffect : uint8_t
strong

Enumeration that defines methods used for Scene Effects.

This enum provides options to apply various post-processing effects to a scene. Scene effects are typically applied to modify the final appearance of a rendered scene, such as blurring.

See also
Scene::push(SceneEffect effect, ...)
Since
1.0
Enumerator
ClearAll 

Reset all previously applied scene effects, restoring the scene to its original state.

GaussianBlur 

Apply a blur effect with a Gaussian filter. Param(4) = {sigma(double)[> 0], direction(int)[both: 0 / horizontal: 1 / vertical: 2], border(int)[duplicate: 0 / wrap: 1], quality(int)[0 - 100]}.

DropShadow 

Apply a drop shadow effect with a Gaussian Blur filter. Param(8) = {color_R(int)[0 - 255], color_G(int)[0 - 255], color_B(int)[0 - 255], opacity(int)[0 - 255], angle(double)[0 - 360], distance(double), blur_sigma(double)[> 0], quality(int)[0 - 100]}.

Fill 

Override the scene content color with a given fill information. Param(4) = {color_R(int)[0 - 255], color_G(int)[0 - 255], color_B(int)[0 - 255], opacity(int)[0 - 255]}.

Tint 

Tinting the current scene color with a given black, white color parameters. Param(7) = {black_R(int)[0 - 255], black_G(int)[0 - 255], black_B(int)[0 - 255], white_R(int)[0 - 255], white_G(int)[0 - 255], white_B(int)[0 - 255], intensity(double)[0 - 100]}.

Tritone 

Apply a tritone color effect to the scene using three color parameters for shadows, midtones, and highlights. A blending factor determines the mix between the original color and the tritone colors. Param(9) = {Shadow_R(int)[0 - 255], Shadow_G(int)[0 - 255], Shadow_B(int)[0 - 255], Midtone_R(int)[0 - 255], Midtone_G(int)[0 - 255], Midtone_B(int)[0 - 255], Highlight_R(int)[0 - 255], Highlight_G(int)[0 - 255], Highlight_B(int)[0 - 255], Blend(int)[0 - 255]}.

◆ StrokeCap

enum struct StrokeCap : uint8_t
strong

Enumeration determining the ending type of a stroke in the open sub-paths.

Enumerator
Butt 

The stroke ends exactly at each of the two end-points of a sub-path. For zero length sub-paths no stroke is rendered.

Round 

The stroke is extended in both end-points of a sub-path by a half circle, with a radius equal to the half of a stroke width. For zero length sub-paths a full circle is rendered.

Square 

The stroke is extended in both end-points of a sub-path by a rectangle, with the width equal to the stroke width and the length equal to the half of the stroke width. For zero length sub-paths the square is rendered with the size of the stroke width.

◆ StrokeJoin

enum struct StrokeJoin : uint8_t
strong

Enumeration determining the style used at the corners of joined stroked path segments.

Enumerator
Miter 

The outer corner of the joined path segments is spiked. The spike is created by extension beyond the join point of the outer edges of the stroke until they intersect. In case the extension goes beyond the limit, the join style is converted to the Bevel style.

Round 

The outer corner of the joined path segments is rounded. The circular region is centered at the join point.

Bevel 

The outer corner of the joined path segments is bevelled at the join point. The triangular region of the corner is enclosed by a straight line between the outer corners of each stroke.

◆ TextWrap

enum struct TextWrap : uint8_t
strong

Enumeration that defines methods used for wrapping text.

This enum provides options to control how text is wrapped when it exceeds the available space. Wrapping affects the layout and flow of text in the rendering area.

See also
Text::wrap(TextWrap mode)
Since
1.0
Enumerator
None 

Do not wrap text. Text is rendered on a single line and may overflow the bounding area.

Character 

Wrap at the character level. If a word cannot fit, it is broken into individual characters to fit the line.

Word 

Wrap at the word level. Words that do not fit are moved to the next line.

Smart 

Smart choose wrapping method: word wrap first, falling back to character wrap if a word does not fit.

Ellipsis 

Truncate overflowing text and append an ellipsis ("...") at the end. Typically used for single-line labels.

◆ Type

enum struct Type : uint8_t
strong

Enumeration specifying the ThorVG class type value.

ThorVG's drawing objects can return class type values, allowing you to identify the specific class of each object.

See also
Paint::type()
Fill::type()
Since
1.0
Enumerator
Undefined 

Unknown class.

Shape 

Shape class.

Scene 

Scene class.

Picture 

Picture class.

Text 

Text class.

LinearGradient 

LinearGradient class.

RadialGradient 

RadialGradient class.