Recent

Author Topic: ThorVG - test (lightweight vector graphics engine)  (Read 3998 times)

ALLIGATOR

  • Sr. Member
  • ****
  • Posts: 404
  • I use FPC [main] 💪🐯💪
ThorVG - test (lightweight vector graphics engine)
« on: February 08, 2026, 11:35:27 am »
https://www.thorvg.org/

I tried this library on Windows x64 - it looks pretty good

I loaded a Lottie animation, rendering (in this case) on the CPU

It doesn't seem to slow down, but it can be significantly accelerated (on Windows), IMHO, since most of the load is currently due to Lazarus abstraction layers, IMHO

I didn't test it on Linux (although I really wanted to), because the library needs to be compiled. I just took the ready-made one from GitHub, where there was a compiled binary for Windows x64, but not for Linux

As for compiling it myself, I don't feel like messing with C++ and its compilation systems at the moment
I may seem rude - please don't take it personally

ALLIGATOR

  • Sr. Member
  • ****
  • Posts: 404
  • I use FPC [main] 💪🐯💪
Re: ThorVG - test (lightweight vector graphics engine)
« Reply #1 on: February 08, 2026, 11:35:53 am »
animation
I may seem rude - please don't take it personally

LeP

  • Full Member
  • ***
  • Posts: 204
Re: ThorVG - test (lightweight vector graphics engine)
« Reply #2 on: February 08, 2026, 02:43:17 pm »
I try it with little modifications to view SVG files.

The colours are not aligned (try with different viewer that give the same results, except in thorvg) ... look at attached image.

In many case, where the SVG is more complex it throw an math exception (divide by zero). To resolve this you have to add:

Code: Pascal  [Select][+][-]
  1. SetExceptionMask(GetExceptionMask + [exOverflow,exZeroDivide,exInvalidOp]);

this is normally when you have to do with C Microsoft Dll.

But, except for colours, seems to be good with very complex svg images too ... better then Skia.

P.S.: Colours not aligned, I meant the colours are not right, some kind is right others not (it's like the typical inversion of the plane R,G,B that affects also PNG sometimes).
« Last Edit: February 08, 2026, 02:55:08 pm by LeP »

ALLIGATOR

  • Sr. Member
  • ****
  • Posts: 404
  • I use FPC [main] 💪🐯💪
Re: ThorVG - test (lightweight vector graphics engine)
« Reply #3 on: February 08, 2026, 03:05:34 pm »
I meant the colours are not right, some kind is right others not
It looks like some kind of alpha channel mix-up
You need to make the background the same for the shape and the tool you used to get the second image

And you can also play around with the modes, where you can choose different RGB8888 settings
« Last Edit: February 08, 2026, 03:10:42 pm by ALLIGATOR »
I may seem rude - please don't take it personally

ALLIGATOR

  • Sr. Member
  • ****
  • Posts: 404
  • I use FPC [main] 💪🐯💪
Re: ThorVG - test (lightweight vector graphics engine)
« Reply #4 on: February 08, 2026, 03:07:20 pm »
But in general, I tested very limitedly, as soon as I made sure that Lottie animations worked, and slightly removed Lazarus overhead for working with image data - I immediately loaded the result
I may seem rude - please don't take it personally

LeP

  • Full Member
  • ***
  • Posts: 204
Re: ThorVG - test (lightweight vector graphics engine)
« Reply #5 on: February 08, 2026, 03:10:14 pm »
I meant the colours are not right, some kind is right others not
It looks like some kind of alpha channel mix-up
You need to make the background the same for the shape and the tool you used to get the second image
What background ? The "orginal" image is viewer with Firefox (the "original" image attached), Edge or others tools without setting nothing.

ALLIGATOR

  • Sr. Member
  • ****
  • Posts: 404
  • I use FPC [main] 💪🐯💪
Re: ThorVG - test (lightweight vector graphics engine)
« Reply #6 on: February 08, 2026, 03:12:19 pm »
What background ? The "orginal" image is viewer with Firefox (the "original" image attached), Edge or others tools without setting nothing.
I corrected the message
But you'd better send the svg file then  :)
I may seem rude - please don't take it personally

LeP

  • Full Member
  • ***
  • Posts: 204
Re: ThorVG - test (lightweight vector graphics engine)
« Reply #7 on: February 08, 2026, 03:16:13 pm »
What background ? The "orginal" image is viewer with Firefox (the "original" image attached), Edge or others tools without setting nothing.
I corrected the message
But you'd better send the svg file then  :)

Code: Text  [Select][+][-]
  1. <svg width="120" height="120" viewBox="0 0 240 120"
  2.    xmlns="http://www.w3.org/2000/svg">
  3.   <defs>
  4.     <radialGradient id="exampleGradient">
  5.       <stop offset="10%" stop-color="gold"/>
  6.       <stop offset="95%" stop-color="green"/>
  7.     </radialGradient>
  8.     <radialGradient spreadMethod="reflect"
  9.                     cx="50%"
  10.                     cy="50%"
  11.                     r="50%"
  12.                     fx="25%"
  13.                     fy="75%"
  14.                     fr="10%"
  15.                    id="flameGradient">
  16.       <stop offset="0%" stop-color="white"/>
  17.       <stop offset="10%" stop-color="yellow"/>
  18.       <stop offset="95%" stop-color="red"/>
  19.     </radialGradient>
  20.   </defs>
  21.   <circle fill="url(#exampleGradient)" cx="60" cy="60" r="50"/>
  22.   <circle fill="url(#flameGradient)" cx="180" cy="60" r="50"/>
  23. </svg>

ALLIGATOR

  • Sr. Member
  • ****
  • Posts: 404
  • I use FPC [main] 💪🐯💪
Re: ThorVG - test (lightweight vector graphics engine)
« Reply #8 on: February 08, 2026, 03:34:30 pm »
Code: Text  [Select][+][-]
  1. <svg>

Code: Diff  [Select][+][-]
  1. -   tvg_swcanvas_set_target(tvgCanvas, PUInt32(b.RawImage.Data), PaintBox1.Width, PaintBox1.Width, PaintBox1.Height, TVG_COLORSPACE_ABGR8888S);
  2. +   tvg_swcanvas_set_target(tvgCanvas, PUInt32(b.RawImage.Data), PaintBox1.Width, PaintBox1.Width, PaintBox1.Height, TVG_COLORSPACE_ARGB8888S);

And everything will be OK
I may seem rude - please don't take it personally

ALLIGATOR

  • Sr. Member
  • ****
  • Posts: 404
  • I use FPC [main] 💪🐯💪
Re: ThorVG - test (lightweight vector graphics engine)
« Reply #9 on: February 08, 2026, 03:36:29 pm »
seems to be good with very complex svg images too ... better then Skia
Especially the size of the library! Just look how tiny it is, and if you link it statically, it will be even smaller!
I may seem rude - please don't take it personally

LeP

  • Full Member
  • ***
  • Posts: 204
Re: ThorVG - test (lightweight vector graphics engine)
« Reply #10 on: February 08, 2026, 04:00:06 pm »
Code: Diff  [Select][+][-]
  1. -   tvg_swcanvas_set_target(tvgCanvas, PUInt32(b.RawImage.Data), PaintBox1.Width, PaintBox1.Width, PaintBox1.Height, TVG_COLORSPACE_ABGR8888S);
  2. +   tvg_swcanvas_set_target(tvgCanvas, PUInt32(b.RawImage.Data), PaintBox1.Width, PaintBox1.Width, PaintBox1.Height, TVG_COLORSPACE_ARGB8888S);
And everything will be OK

OK

Especially the size of the library! Just look how tiny it is, and if you link it statically, it will be even smaller!

Yes, but I use Delphi and SKIA or Image32 are integrated in pure Pascal without any external DLL.
Other thing is that I need the DLL signed or I should compile the DLL myself (in simple way without python, perl, php, etc ...).
All my software are signed.

hermet

  • Newbie
  • Posts: 3
Re: ThorVG - test (lightweight vector graphics engine)
« Reply #11 on: February 09, 2026, 05:47:10 am »
Yes, but I use Delphi and SKIA or Image32 are integrated in pure Pascal without any external DLL.
Other thing is that I need the DLL signed or I should compile the DLL myself (in simple way without python, perl, php, etc ...).
All my software are signed.

Why not use the static library of ThorVG? 🙂

ALLIGATOR

  • Sr. Member
  • ****
  • Posts: 404
  • I use FPC [main] 💪🐯💪
Re: ThorVG - test (lightweight vector graphics engine)
« Reply #12 on: February 09, 2026, 06:15:16 am »
Why not use the static library of ThorVG? 🙂
What???? :o The author of the library is here? On the FreePascal forum? :o No way! :-X
I may seem rude - please don't take it personally

Roland57

  • Hero Member
  • *****
  • Posts: 587
    • msegui.net
Re: ThorVG - test (lightweight vector graphics engine)
« Reply #13 on: February 09, 2026, 08:26:51 am »
I didn't test it on Linux (although I really wanted to), because the library needs to be compiled. I just took the ready-made one from GitHub, where there was a compiled binary for Windows x64, but not for Linux

Hello! Thank you for sharing. I could compile easily the library under Linux:

Code: Bash  [Select][+][-]
  1. meson setup builddir
  2. ninja -C builddir install

I could also compile the Lazarus project, but when I start the program, I get a violation access, then a blank window, and then the window of the application, with the word "Cat".
My projects are on Codeberg.

ALLIGATOR

  • Sr. Member
  • ****
  • Posts: 404
  • I use FPC [main] 💪🐯💪
Re: ThorVG - test (lightweight vector graphics engine)
« Reply #14 on: February 09, 2026, 08:44:10 am »
I could compile easily the library under Linux
Share the *.so file (I may not be able to use it due to some incompatibility with system libraries, but I'll give it a try)

Also, maybe this advice can help you?

In many case, where the SVG is more complex it throw an math exception (divide by zero). To resolve this you have to add:
Code: Pascal  [Select][+][-]
  1. SetExceptionMask(GetExceptionMask + [exOverflow,exZeroDivide,exInvalidOp]);
this is normally when you have to do with C Microsoft Dll
I may seem rude - please don't take it personally

 

TinyPortal © 2005-2018