About ThorVG

ThorVG is a free-software graphics library for drawing vector-based scenes and animations. "Simpler is better" is the philosophy of the ThorVG project - it provides simple and user-friendly interfaces while keeping a small size and minimal software complexity.

The following list shows primitives that are supported by ThorVG:

 

  • Shapes: Line, Arc, Curve, Path, Polygon, ...

  • Filling: Solid, Linear and Radial Gradient

  • Scene Graph & Affine Transformation (translation, rotation, scale, ...)

  • Stroking: Width, Join, Cap, Dash

  • Composition: Blending, Masking, Path Clipping, ...

  • Pictures: TVG, SVG, JPG, PNG, Bitmap, ...

example_primitives.png

Anti-aliased Shapes

Gradient Filling

Stroking

Path-Clipping

SVG Picture

Maskings

Composition

Texturing

Basic Strategy

If your program has the main renderer, your program could call ThorVG APIs while switching drawing contexts between the main renderer and ThorVG. During the API calls, ThorVG serializes drawing commands among the volatile paints' nodes, then performs synchronous/asynchronous rendering using it's backend raster engines. ThorVG supports vector images such as SVG and can be expanded to support other popular formats on demand. During the rendering, it could spawn intermediate frame-buffers for compositing scenes, but only when it's necessary. The next figure shows you a brief strategy on how to use ThorVG on your system.

example_flow.png

Threading

ThorVG has the threading mechanism so that it tries to acquire the next scenes without delay. It runs its own fine-tuned task-scheduler built on threading pools, encapsulates all the jobs such as encoding, decoding, updating, rendering with tasks. As a result, all the tasks could run on multi-processing. The task scheduler is readied for hiding complexity, easier integration and user convenience. Thus the policy is optional, users can select it by their demands.

thorvg_threading.png

SVG Support

ThorVG supports SVG (Scalable Vector Graphics) rendering through its SVG interpreter. It satisfies the SVG Tiny Specification to keep it lightweight, so it's useful for the embedded systems. Among the SVG Tiny specs, yet unsupported features in the ThorVG are the following:

  • Animation

  • Fonts & Text

  • Interactivity

  • Multimedia

  • Scripting

512px-Ghostscript_Tiger.svg.png

Ghostscript Tiger using ThorVG

TVG Picture

ThorVG provides the designated vector data format which is called TVG Picture. TVG Picture stores a list of properties of the Paint nodes of a scene in binary form. The data saved in a TVG Picture is optimized beforehand, keeping the resulting file small and the data loading process fast and efficient.

 

To save data in a TVG Picture format, ThorVG uses a dedicated module - TVG Saver. It is responsible for optimizing the data of all the scene-tree nodes and saving them in binary format. In the optimization process, the TVG Saver filters out unused information, removing the duplicated properties, merges the overlapping shapes and compresses the data if possible, but keeping the TVG Pictures compatible with the later version of ThorVG libraries. In case of compression, it uses Lempel-Ziv-Welchi data compression algorithm.

The final data size is smaller in comparison to any other text-based vector data format, such as SVG, which in turn decreases the required application resources. This helps not only reduce the number of I/O operations but also reduces the memory bandwidth while loading the data. Thus this is effective if your program uses a big amount of the vector resources.

Additionally, TVG Picture helps to reduce the resource loading tasks since it can skip interpreting the data stage. That brings the reduced amount of the required runtime memory and rendering tasks that increases the performance.

Utilizing the TVG Picture allows you to reduce the data size and loading time by more than 30%, on average (See More). Note that the charge in the performance rate depends on the resource size and its complexity.

tvg_pictures.png

86,486 -> 54,568

(50,622)

8,950 -> 1,737

(1,341)

37,319 -> 6,575

(6,234)

340,873 -> 68,910

(58,017)

Comparison of the file sizes: SVG -> TVG (Compressed)

While TVG Saver exports the scene-tree to the TVG Picture data files(TVG), the TVG Loader imports and restores it to the programmable instances. You can quickly use the ThorVG Viewer to convert files from SVG to TVG.

tvg_format.png

ThorVG Viewer

ThorVG provides the resource verification tool for the ThorVG Engine. It does immediate rendering via web browser running on the ThorVG web-assembly binary, allowing real-time editing of the vector elements on it. It doesn't upload your resources to any external server while allowing to export to supported formats such as TVG, so the designer resource copyright is protected.

Practices

Tizen

ThorVG is integrated into the Tizen platform as the vector graphics engine. It's used for vector primitive drawings and scalable image contents such as SVG and Lottie Animation in the Tizen powered products.

example_tizen.png

Rive

We're also building a Rive port that supports Rive Animation running through the ThorVG backend. Rive is a brand new animation platform that supports fancy, user interactive vector animations. For more details see Rive-Tizen on Github.

example_rive.gif