Hi everyone,
to become familiar with Castle Engine on Lazarus I started working with images, sprites and spritesheet.
At the end a pretty nice program came out.
It may be useful for beginners like me to study the first steps of an engine so extensive.
At present it is possible to do this:
Load the necessary images and create the spritesheet directly from within Lazarus without using the command line. It use ShellExecute.
Flip and resize individual images (with or without constraints of proportions). It might be useful for creating spritesheets in the opposite directions). It use TCastleImage and TGLImage in TCastleControl.
For resizing it is possible to set the interpolation mode in those proposed in TResizeInterpolation.
Finally you can load a spritesheet and see the animation. Frame sizes are automatically calculated based on the number of frames and columns. It is possible to change frames per second during the animation. It use TSprite.
It is not anything special but you can find useful ideas to start understanding CGE.
I posted application and sources on GitHub, https://github.com/valterb/spritesheet-utility
If you try it let me know of any bugs.
This is very cool! Thanks for making this application. I will make a news post about it soon.
2 comments about running applications:
Instead of ShellExecute (which is Windows-only), you can use RunCommand or ExecuteProcess (simple) or TProcess class (complicated, but very flexible). Their details are documented on http://wiki.freepascal.org/Executing_External_Programs . They are cross-platform, i.e. will work on Linux, macOS etc. too.
Thanks for the suggestions, Michalis. Done. I thought it was not right to use your code directly in my program. Now the program no longer uses ShellExecute and also automatically inserts the correct value for Padding so it will be necessary to enter only the number of columns desired.
The changes have already been posted on GitHub.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi everyone,
to become familiar with Castle Engine on Lazarus I started working with images, sprites and spritesheet.
At the end a pretty nice program came out.
It may be useful for beginners like me to study the first steps of an engine so extensive.
At present it is possible to do this:
Load the necessary images and create the spritesheet directly from within Lazarus without using the command line. It use ShellExecute.
Flip and resize individual images (with or without constraints of proportions). It might be useful for creating spritesheets in the opposite directions). It use TCastleImage and TGLImage in TCastleControl.
For resizing it is possible to set the interpolation mode in those proposed in TResizeInterpolation.
Finally you can load a spritesheet and see the animation. Frame sizes are automatically calculated based on the number of frames and columns. It is possible to change frames per second during the animation. It use TSprite.
It is not anything special but you can find useful ideas to start understanding CGE.
I posted application and sources on GitHub, https://github.com/valterb/spritesheet-utility
If you try it let me know of any bugs.
This is very cool! Thanks for making this application. I will make a news post about it soon.
2 comments about running applications:
Instead of ShellExecute (which is Windows-only), you can use
RunCommandorExecuteProcess(simple) orTProcessclass (complicated, but very flexible). Their details are documented on http://wiki.freepascal.org/Executing_External_Programs . They are cross-platform, i.e. will work on Linux, macOS etc. too.In case of this application, I would actually encourage you to take the
combine_images_into_sprite_sheet.lprsources ( https://github.com/castle-engine/castle-engine/blob/master/examples/sprite_sheets/combine_images_into_sprite_sheet/combine_images_into_sprite_sheet.lpr ), and just turn it into a regular Pascal procedure (or method) inside your application. This way you will not have to execute any external process to achieve this. As combine_images_into_sprite_sheet is so simple application, I would not worry about code duplication here :)(It is also legally OK. Your https://github.com/valterb/spritesheet-utility is on GPL license, and so you can legally copy anything you want from CGE code, https://github.com/castle-engine/castle-engine/blob/master/COPYING.md .)
Thanks for the suggestions, Michalis. Done. I thought it was not right to use your code directly in my program. Now the program no longer uses ShellExecute and also automatically inserts the correct value for Padding so it will be necessary to enter only the number of columns desired.
The changes have already been posted on GitHub.