In a Windows Firemonkey application, when I issue the following for a rectangle, in the middle of a form:
rect.Canvas.BeginScene;
rect.Canvas.Clear(TAlphaColorRec.White);
rect.Canvas.EndScene
the entire form is painted white.
Was not the case in XE2. Is the case in Delphi 10.
What's the new paradigm I have overlooked?
The canvas of the primitive (e.g TPaintBox
and all TShape
descendants) controls, is the canvas of the form. The controls draw directly on this canvas. Therefore a call to Control.Canvas.Clear()
clears the whole form. Instead of calling Clear
you should use the Fill
property of the TRectangle
, like so:
Rectangle1.Fill.Color := TAlphaColorRec.White;
I can't comment on how it was in Delphi XE2, but there has been many changes to the FMX library, since then. Maybe this is one of them.
Also refer to FireMonkey Component Rendering