
I had this drawing demo application built for use in another project. I am releasing it here to demonstrate how to do various drawing functions in Firemonkey. It works on both Android and IOS. There is a bug with the ellipse tool. In any event it features a Pen tool, a Line tool, a Rectangle tool, an Ellipse tool, a Fill tool, and a bitmap stamping tool (select image from file). Additionally, you can adjust the line width, the line color, and the fill color. It uses a custom TPaintBox component to take care of the drawing. It uses one set of drawing code for Windows and a second set of drawing code for Android and IOS. This was a workaround for a bug that happens when the thickness of the line is larger than 1 on mobile devices.
Download the updated version of the Delphi Firemonkey Drawing App Demo
Update:Â Download an updated version of this demo for Delphi 10 Berlin.
Hello
I am using this example very well in my application iOS and Android.
I wonder if there is some form of adptar this code a function to undo the last action or actions last .
I thank you
One way to do Undo may be to store each command in a TStringList and then to do an undo you delete the last command from the TStringList. Clear the paintbox and re-apply all of the commands again.
They could advise me on the best event to put the command stringlist
http://delphi.xcjc.net/viewthread.php?tid=47592
in Java’s Swing you had Undoable actions if I remember well. So for each action you’d define an other that knows how to Undo it or you’d have the same action know how to undo itself. For vector graphics that’s easy, but for bitmaps you’d have to keep a part of the image, the one that the action affected. This can cost in memory (plus fill commands can affect the whole image area) so if the history of user actions isn’t expected to go very deep, maybe it’s worth considering the other suggestion, to clear the image and apply all commands from the start up to the undo point