Rapid SVG Mapping

Developed or developing a new product in PureBasic? Tell the world about it.
User avatar
JHPJHP
Addict
Addict
Posts: 2263
Joined: Sat Oct 09, 2010 3:47 am

Rapid SVG Mapping

Post by JHPJHP »

Hi All,

Some time ago, AAT and I collaborated on an OpenCV example for my project, PureBasic Interface to OpenCV. Years later, another forum member developed a RAD SVG tool, which reminded me of the example AAT and I had worked on. With only a few minor modifications, literally just a dozen new lines of code, a promising new SVG tool began to take shape.

When I initially shared my results as an animated GIF, the response appeared limited, so I decided to set the example aside.

I don’t necessarily expect significant interest this time either, but revisiting OpenCV was enjoyable. It was great to see that, even though the version is somewhat dated, the algorithms remain highly relevant today.

Back when I first posted this in 2020, my thought was that it could serve as an add-on to any future SVG tools, essentially adding the Rapid to RAD.
• Useful for mapping complex shapes, animating sprite-sheet images, and more.

See the following video: Vector Drawing
1. Two JPG images are displayed for the demonstration.
2. The original 2020 example is copied into the main OpenCV folder.
3. The code executes, deriving x/y points from the image contours.
4. These points are drawn onto a copy of the selected image.
5. The SVG library uses the x/y points to render the results onto a CanvasGadget.
6. Various other SVG rendering options are also demonstrated.
Last edited by JHPJHP on Mon Oct 20, 2025 2:55 am, edited 3 times in total.

If you're not investing in yourself, you're falling behind.

My PureBasic StuffFREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
User avatar
Caronte3D
Addict
Addict
Posts: 1369
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

Re: Rapid SVG

Post by Caronte3D »

Excellent work as always! :wink:
miso
Enthusiast
Enthusiast
Posts: 491
Joined: Sat Oct 21, 2023 4:06 pm
Location: Hungary

Re: Rapid SVG

Post by miso »

That's cool, good job.
User avatar
SPH
Enthusiast
Enthusiast
Posts: 588
Joined: Tue Jan 04, 2011 6:21 pm

Re: Rapid SVG

Post by SPH »

Did I understand correctly? :
Does this code define the points around a shape?
In OpenGL, the instruction that creates polygons only creates convex polygons. Is there a way to "slice" any shape into convex polygons? (If so, that would be great for me.)
Thanks

!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Portable LENOVO ideapad 110-17ACL 64 bits
Version de PB : 6.12LTS - 64 bits
User avatar
JHPJHP
Addict
Addict
Posts: 2263
Joined: Sat Oct 09, 2010 3:47 am

Re: Rapid SVG Mapping

Post by JHPJHP »

Hi Caronte3D, miso,

Thank you for your positive comments.

------------

Hi SPH,
SPH wrote:Does this code define the points around a shape?
Yes, it has been part of the PureBasic Interface to OpenCV for over ten years, and it’s just one of many examples that can map points to objects.
• The two examples shown in the videos were quick modifications of an existing example.

------------

As I mentioned in my previous post, animations are a no-brainer...

See the following video: Vector Animation
.. MP4 video was created using my Video Snipping Tool.
.. Used my GIF Toolkit to convert a GIF animation to a sprite sheet.
1. The generated sprite sheet is displayed for the demonstration.
2. In a loop the sprite sheet is broken-down into regions of interest.
3. X/Y points are derived from the image contours.
4. These points are drawn onto a copy of the selected image.
5. The x/y points are used to render the results onto a CanvasGadget at 2x the scale.
Last edited by JHPJHP on Mon Oct 20, 2025 2:56 am, edited 1 time in total.

If you're not investing in yourself, you're falling behind.

My PureBasic StuffFREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
BarryG
Addict
Addict
Posts: 4214
Joined: Thu Apr 18, 2019 8:17 am

Re: Rapid SVG

Post by BarryG »

JHPJHP wrote: Sat Oct 18, 2025 7:20 pmWhen I initially shared my results as an animated GIF, the response appeared limited, so I decided to set the example aside.
I read almost every post on this forum but don't always respond to them. Like this topic: I have no idea what SVG is and have no need for it, but I read it anyway without any plan to respond to it. But your quote made me write this reply to remind you that your work is actually seen and appreciated, even if I don't use it personally. Thumbs up! :)
User avatar
JHPJHP
Addict
Addict
Posts: 2263
Joined: Sat Oct 09, 2010 3:47 am

Re: Rapid SVG Mapping

Post by JHPJHP »

Hi BarryG,
BarryG wrote:I have no idea what SVG is and have no need for it
That’s a bit of a paradox: How can you be sure you don’t need it if you don’t know what it is :P
• For reference, SVG stands for Scalable Vector Graphics; see PureBasic - VectorDrawing.
BarryG wrote:your quote made me write this reply to remind you that your work is actually seen and appreciated
That was kind of you but really not necessary. I was just having a bit of fun. The code has been available for over ten years, so anyone who works with SVG and still finds themselves manually mapping coordinates around objects, my point should be fairly obvious :)

There are countless uses; one example is my Old-Skool Fire Effect.

If you're not investing in yourself, you're falling behind.

My PureBasic StuffFREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
Post Reply