FIXED : Delphi drawing on PlotGrid glitch? requires form resize first

  

UPDATE……………….

OK I am stupid. I was making a mistake on how I was pushing the cos wave across the screen which did not show the updates until the form changed sizes…BUT I did find something very interesting regarding the timage and bitmap sizes in an android.. see this conversation: (It is important and not documented).
Component sizes in Delphi Android

Origingal post …………………………………..

I am using fmx and delphi. I am doing my canvas drawing in the plotgrid paint event.
In the onpaint event I am drawing a cos wave. It initially draws, subsequent calls move the wave across the canvas. I initially tied a timer with a plotgrid.repaint and nothing would happen until I resized the form and then it would operate as expected. I disabled the timer and I added a button to call plotgrid.repaint. it does calls the paint event (I see this in showmessages and the debugger).. and nothing happens. Once I resize the form then everything works as expected subsequent button calls redraw on the plotgrid.canvas.. I started with the demo sample.

any help? thanks

please note I also added comment about what makes it work.
below.

Added code below

procedure TMainForm.PlotGridPaint(Sender: TObject; Canvas: TCanvas;
const ARect: TRectF);
begin

// plotgrid.Frequency:=2000;

//showmessage(‘plotgrid paint’);

PlotGrid.Canvas.Stroke.Thickness := 1; // Set stroke thickness

//CalculateSin; // Calculate and scale X and sin(X) values and save them in FPoints
// PlotGrid.Canvas.Stroke.Color := TAlphaColorRec.Red; // Set color for sin to red
//PlotGrid.Canvas.DrawPolygon(FPoints, 1); // Draw sin graph

// SetParams;
CalculateCos(Radian); // Calculate and scale X and cos(X) values and save them in FPoints
PlotGrid.Canvas.Stroke.Color := TAlphaColorRec.Blue; // Set color for cos to blue
PlotGrid.Canvas.DrawPolygon(FPoints, 1); // Draw cos graph
end;

procedure TMainForm.Timer1Timer(Sender: TObject);
begin
plotgrid.Repaint;

end;

Comments are closed.