Recent

Author Topic: SVG in FreePascal, or state of the art in 2D graphics  (Read 3176 times)

yay

  • New Member
  • *
  • Posts: 24
SVG in FreePascal, or state of the art in 2D graphics
« on: March 14, 2024, 11:05:15 am »
Hello,

I am going about building a thing as a means of acquainting myself with the FreePascal language (Object Pascal, I guess? I still don't know the extent to which modes of "Modern Pascal" are (in)compatible with one another, it's a little confusing. Perhaps it bears mentioning that I am interested in ObjectPascal specifically, and specifically because I like OOP but hate C++).

The project I have in mind is a visualizer for SVG images, at first merely displaying them, and then ultimately animating them (more specifically, animating paths defined within an SVG file).

I would appreciate any suggestions to this end, as well as any explanation on the current state of (good) Pascal libraries, where to find them, and how to use them. I was drawn in by proponents of this language telling glorious tales of "write-once-run-anywhere" and "code-written-thirty-years-ago-still-runs", and while I should have dismissed it as evangelist hyperbole and saved myself some disappointment, in practice I have looked at AggPas and AggPasMod, both of which seem well past abandoned and neither of which seem to work out of the box as example executables nor as source code.

I will admit that I have limited patience for the arcana of coaxing software into playing nice, so if that means this is the wrong ecosystem for me (I quite like the language itself so far, it's like Ada but less tedious), I would very much appreciate being told that honestly, and perhaps even being directed toward an ecosystem in the same spirit with a less fiddly nature, if applicable.

Thank you very kindly in advance.

paweld

  • Hero Member
  • *****
  • Posts: 1360
Re: SVG in FreePascal, or state of the art in 2D graphics
« Reply #1 on: March 14, 2024, 11:19:33 am »
BGRABitmap supports svg files: https://bgrabitmap.github.io/
Best regards / Pozdrawiam
paweld

yay

  • New Member
  • *
  • Posts: 24
Re: SVG in FreePascal, or state of the art in 2D graphics
« Reply #2 on: March 14, 2024, 11:32:06 am »
BGRABitmap supports svg files: https://bgrabitmap.github.io/

Looks good at first blush. I will check it out.

Dziękuje.


yay

  • New Member
  • *
  • Posts: 24
Re: SVG in FreePascal, or state of the art in 2D graphics
« Reply #4 on: March 14, 2024, 12:14:11 pm »
Additional information that you may need:
https://wiki.freepascal.org/BGRABitmap_tutorial

Code in very first tutorial displays nothing lol.

Thanks just the same.

dseligo

  • Hero Member
  • *****
  • Posts: 1501
Re: SVG in FreePascal, or state of the art in 2D graphics
« Reply #5 on: March 14, 2024, 12:32:14 pm »
Additional information that you may need:
https://wiki.freepascal.org/BGRABitmap_tutorial

Code in very first tutorial displays nothing lol.

Thanks just the same.

I just tried code from Tutorial 1 (https://wiki.freepascal.org/BGRABitmap_tutorial_1) and it works as described. I tried under Windows and Debian.
I suggest you share your test project so someone can see what is wrong with it (menu Project, Publish project).

Eugene Loza

  • Hero Member
  • *****
  • Posts: 729
    • My games in Pascal
Re: SVG in FreePascal, or state of the art in 2D graphics
« Reply #6 on: March 14, 2024, 12:36:17 pm »
For a long time I wanted to have a closer look at https://wiki.freepascal.org/fpvectorial but didn't get to it yet, so simply exporting my SVGs into PNG format for now :) Vector graphics appeared much more "accessible" for an inartistic programmer like me than trying to make regular raster graphics :)
My FOSS games in FreePascal&CastleGameEngine: https://decoherence.itch.io/ (Sources: https://gitlab.com/EugeneLoza)

yay

  • New Member
  • *
  • Posts: 24
Re: SVG in FreePascal, or state of the art in 2D graphics
« Reply #7 on: March 14, 2024, 12:50:48 pm »
I just tried code from Tutorial 1 (https://wiki.freepascal.org/BGRABitmap_tutorial_1) and it works as described. I tried under Windows and Debian.
I suggest you share your test project so someone can see what is wrong with it (menu Project, Publish project).
« Last Edit: March 14, 2024, 12:52:26 pm by yay »

circular

  • Hero Member
  • *****
  • Posts: 4404
    • Personal webpage
Re: SVG in FreePascal, or state of the art in 2D graphics
« Reply #8 on: March 14, 2024, 01:16:14 pm »
Hmm, is the Paint event linked in the form events in the object inspector?

If you add a breakpoint on the first instruction in the FormPaint method, does it actually go there when running?

Conscience is the debugger of the mind

yay

  • New Member
  • *
  • Posts: 24
Re: SVG in FreePascal, or state of the art in 2D graphics
« Reply #9 on: March 14, 2024, 01:26:32 pm »
Hmm, is the Paint event linked in the form events in the object inspector?

If you add a breakpoint on the first instruction in the FormPaint method, does it actually go there when running?

Thank you, I see now where I skipped over that detail in the tutorial. It is working as expected now. I promise I will read tutorials more closely before posting in the future (though it does bear mentioning the tutorial says to double-click the line to add the procedure automatically, and, at least in my version of Lazarus, there is a `…` button that does that, whereas double-clicking has no effect).

By the way, where is the file where these connections get written? Automagic stuff is cool and all, but it fills me with disquiet that I can't see anything in writing connecting my form's objects with their procedures.

YiannisKam

  • Full Member
  • ***
  • Posts: 119
Re: SVG in FreePascal, or state of the art in 2D graphics
« Reply #10 on: March 14, 2024, 01:55:08 pm »
Quote
there is a `…` button that does that, whereas double-clicking has no effect
Actually you can either double click on the empty box next to your desired event or just click once on the dotted box
Windows 10 - 64bit
Lazarus version: 3.99
FPC       version: 3.3.1

Handoko

  • Hero Member
  • *****
  • Posts: 5412
  • My goal: build my own game engine using Lazarus
Re: SVG in FreePascal, or state of the art in 2D graphics
« Reply #11 on: March 14, 2024, 02:14:53 pm »
By the way, where is the file where these connections get written?

In the *.lfm files.

You should not edit the *.lfm files manually. I heard users messing up their code because they modified the *.lfm files directly.
« Last Edit: March 14, 2024, 02:18:26 pm by Handoko »

yay

  • New Member
  • *
  • Posts: 24
Re: SVG in FreePascal, or state of the art in 2D graphics
« Reply #12 on: March 14, 2024, 05:19:36 pm »
 

In the *.lfm files.

You should not edit the *.lfm files manually. I heard users messing up their code because they modified the *.lfm files directly.

Thank you, it looks like a fairly straightforward markup language to me. Not sure why it needs to be hidden away. What if one were developing an app without Lazarus?

Which raises another question:

How can I see *every* file relevant to my program in the Project Inspector? Call me weird, but I want to be able to at least look at any file within my project's directory. I find the fact that the Project Inspector is hiding files from me disconcerting. An LRS file is referenced in the code in that example, an LFM is referenced by the default application template, and I can't even see them in the Inspector.

Also, am I missing something about the name BGRABitmap? `BGRA(red, green, blue, alpha: byte)`, not `BGRA(blue, green, red, alpha: byte)`?
« Last Edit: March 14, 2024, 05:28:31 pm by yay »

Handoko

  • Hero Member
  • *****
  • Posts: 5412
  • My goal: build my own game engine using Lazarus
Re: SVG in FreePascal, or state of the art in 2D graphics
« Reply #13 on: March 14, 2024, 05:49:17 pm »
Thank you, it looks like a fairly straightforward markup language to me. Not sure why it needs to be hidden away.

That is necessary for preventing non-skilled users to edit it. If you understand how to modify it, just do it if you want. But remember, make backups.

How can I see *every* file relevant to my program in the Project Inspector?

Lazarus main menu > Project > Project Inspector

I'm sure will need this too:
Lazarus main menu > View > Code Browser



Lazarus has many 'hidden' tricks, if you want to know, see it here:
https://wiki.freepascal.org/New_IDE_features_since

You're not a beginner in programming. But here if you want to see some downloadable short demos:
https://wiki.freepascal.org/Portal:HowTo_Demos

And this list maybe useful to you:
https://wiki.freepascal.org/Lazarus_Documentation
« Last Edit: March 14, 2024, 05:54:37 pm by Handoko »

yay

  • New Member
  • *
  • Posts: 24
Re: SVG in FreePascal, or state of the art in 2D graphics
« Reply #14 on: March 14, 2024, 05:56:28 pm »
Lazarus main menu > Project > Project Inspector

Those files aren't present in the Project Inspector, and I don't see an option to make them visible.

Thank you for the other links, I will check them out.

 

TinyPortal © 2005-2018