I am playing around with FireMonkey simply to test out a couple of things. One of which is implement "very simple" drawing on a canvas. eg Line, Rectangle etc...
First question is, is there an equivalent of the graphex demo supplied for VCL for FireMonkey?
Otherwise, for the purposes of the exercise, I'm trying to replicate that demo in FireMonkey and just now, the line drawing. I can get the line drawing working in so much as when I move the mouse around the line draws where expected. Unfortunately I can't get it to automatically erase the old line that was drawn at the previous point where the mouse was. This seems to be taken care of by the TPenMode property of the TPen property which is - so much as I can tell - a TStroke property in FireMonkey. ie setting the property to pmXor while drawing (moving the mouse) and then setting it to pmCopy when complete.
How would I do something similar with FireMonkey?
Here's the routine that's called during a MouseMove event of a TImage:
FDrawSurface.Bitmap.Canvas.BeginScene;
try
case FShapeToDraw of
doLine:
begin
FDrawSurface.Bitmap.Canvas.DrawLine(PointF(TopLeft.X, TopLeft.Y), PointF(BottomRight.X, BottomRight.Y), 100);
end;
end;
finally
FDrawSurface.Bitmap.Canvas.EndScene;
FDrawSurface.Bitmap.BitmapChanged;
end;
FDrawSurface is a TImage. TopLeft is a TPoint which contains the X and Y of where the mouse was as capture in an OnMouseDown event of the TImaeg and BottomRight is the current X and Y coords from the OnMouseMove event.
So every time I move a mouse, I get "addtional" lines on my image.
Thanks