SVG in FreePascal, or state of the art in 2D graphics lazarus / 39-Graphics ---------------------------------------------------------------------- yay · 2024-03-14 10:05 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 · 2024-03-14 10:19 BGRABitmap supports svg files: https://bgrabitmap.github.io/ ---------------------------------------------------------------------- yay · 2024-03-14 10:32 Quote from: paweld on March 14, 2024, 11:19:33 amBGRABitmap supports svg files: https://bgrabitmap.github.io/ Looks good at first blush. I will check it out. Dziękuje. ---------------------------------------------------------------------- Handoko · 2024-03-14 10:49 Additional information that you may need: https://wiki.freepascal.org/BGRABitmap_tutorial https://forum.lazarus.freepascal.org/index.php/topic,36910.msg246497.h tml#msg246497 https://forum.lazarus.freepascal.org/index.php/topic,65457.msg498723.h tml#msg498723 ---------------------------------------------------------------------- yay · 2024-03-14 11:14 Quote from: Handoko on March 14, 2024, 11:49:51 amAdditional information that you may need: https://wiki.freepascal.org/BGRABitmap_tutorial Code in very first tutorial displays nothing lol. Thanks just the same. ---------------------------------------------------------------------- dseligo · 2024-03-14 11:32 Quote from: yay on March 14, 2024, 12:14:11 pmQuote from: Handoko on March 14, 2024, 11:49:51 amAdditional 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 · 2024-03-14 11:36 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 ---------------------------------------------------------------------- yay · 2024-03-14 11:50 Quote from: dseligo on March 14, 2024, 12:32:14 pmI 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). ---------------------------------------------------------------------- circular · 2024-03-14 12:16 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? ---------------------------------------------------------------------- yay · 2024-03-14 12:26 Quote from: circular on March 14, 2024, 01:16:14 pmHmm, 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 · 2024-03-14 12:55 Quotethere is a `…` button that does that, whereas double-clicking has no effectActually you can either double click on the empty box next to your desired event or just click once on the dotted box ---------------------------------------------------------------------- Handoko · 2024-03-14 13:14 Quote from: yay on March 14, 2024, 01:26:32 pmBy 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. ---------------------------------------------------------------------- yay · 2024-03-14 16:19 Quote from: Handoko on March 14, 2024, 02:14:53 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)`? ---------------------------------------------------------------------- Handoko · 2024-03-14 16:49 Quote from: yay on March 14, 2024, 05:19:36 pmThank 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. Quote from: yay on March 14, 2024, 05:19:36 pmHow 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 ---------------------------------------------------------------------- yay · 2024-03-14 16:56 Quote from: Handoko on March 14, 2024, 05:49:17 pmLazarus 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. ---------------------------------------------------------------------- Handoko · 2024-03-14 17:03 Basically you don't need to modify any of those files directly. Lazarus as a visual editor, will handle them behind the scene for you. If you want to learn about those files' extensions: https://wiki.freepascal.org/file_types ---------------------------------------------------------------------- yay · 2024-03-14 17:05 Even if I don't need to modify them, I still want to be able to see them. ---------------------------------------------------------------------- Handoko · 2024-03-14 17:14 I am a Linux user, I can't do it. But for Windows users, you can right-click to open the folder by right clicking the line of file path near the bottom-right corner of your Source Editor: ---------------------------------------------------------------------- yay · 2024-03-14 17:25 I'm on Linux and that works for me. Still, is there really no way to just have them visible in the Project Inspector? ---------------------------------------------------------------------- Handoko · 2024-03-14 17:59 You can make a feature request. But I don't think much developers will be interested to implement the feature. Not because that is not useful but because Lazarus has very limited manpower. The request will be in low priority or ignored. ---------------------------------------------------------------------- wp · 2024-03-14 18:02 Quote from: yay on March 14, 2024, 06:25:04 pmStill, is there really no way to just have them visible in the Project Inspector? It's good that files which are not needed by the user directly or written by the IDE are not visible normally. In a large project, the IDE will already be overflowing with your "real" source files (.pas, .pp). Having them visible in the project inspector would mean that a double- click can open them in the editor and they will be ready for change. This will be very confusing because the user is not supposed to edit them, and if he does the changes can be ignored or even can damage the project. ---------------------------------------------------------------------- dseligo · 2024-03-14 18:08 Quote from: yay on March 14, 2024, 06:25:04 pmStill, is there really no way to just have them visible in the Project Inspector? Go to Project Inspector, click button 'Add', then 'Add ...' and choose file you want. Only I don't see a point. If you use Lazarus you use it because it is RAD IDE. If I need to open file directly, I open it through file manager. If you want to see form source: right click on form and choose View Source (*.lfm). ---------------------------------------------------------------------- cdbc · 2024-03-14 19:07 Hi Take it on good advice..., there are reasons, that none of us wants to fiddle with those files: 1) The IDE does A LOT OF BOOKKEEPING! 2) The risks of messing things up to a FUBAR scale are simply to high. If you must, use the IDE as much as you can, but be duely warned....  Dolphin, Kate & KWrite are good too, but again -> be warned. Regards Benny ---------------------------------------------------------------------- yay · 2024-03-15 06:35 I can appreciate the "Here be dragons" idea, and can even sympathize with the decision that they should be invisible by default, but to have no option (aside from individually adding them manually as per dseligo's suggestion) whatsoever for viewing them within the context of the IDE is just strange to me, especially for a language that seems otherwise proud of being so close to the metal. Trust me, I will find exciting new ways to fubar my project no matter how many files you hide from me.  I thought the IDE kept regular backups by default, so I fail even harder to see what the big deal is? Having less access to dragon files than Java was not something I was expecting. ---------------------------------------------------------------------- yay · 2024-03-15 10:19 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i stretched := image.Resample(ClientWidth, ClientHeight, rmSimpleStretch) as TBGRABitmap;  Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i image.ResampleFilter := rfMitchell;stretched := image.Resample(ClientWidth, ClientHeight) as TBGRABitmap;  These lines at the bottom of the second tutorial yield the errors `Error: Identifier not found "rmSimpleStretch"` and `Error: Identifier not found "rfMitchell"`, respectively. ---------------------------------------------------------------------- cdbc · 2024-03-15 10:48 Hi Perhaps you need to include "BGRABitmapTypes" & maybe "BGRAResample" in your uses clause... I seem always to need the types, when I use BGRABitmap. ...Oh and don't forget the function BGRAReplace(), very nifty little gem  Regards Benny ---------------------------------------------------------------------- Handoko · 2024-03-15 10:50 If he read that tutorial carefully, he will see BGRABitmapTypes is in the uses clause. ---------------------------------------------------------------------- yay · 2024-03-15 11:36 Ugh