Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does my Delphi TCanvas.DrawLine not appear when running on Android

I have a very simple FireMonkey application with a single form and the following code in the OnPaint event. When I run it using the Windows target, I see a red line and a red square. When I run it on my Android Nexus 7, only the square appears. I must be doing something silly, but what might it be?

Thanks for any help.

procedure TForm2.FormPaint(Sender: TObject; Canvas: TCanvas;
  const ARect: TRectF);
begin
    Canvas.Stroke.Color := claRed;
    Canvas.Fill.Color := claRed;

    Canvas.Stroke.Thickness := 3;

    Canvas.DrawLine( PointF( 0, 0 ), PointF( 200, 200 ), 1.0 );

    Canvas.FillRect( RectF( 300, 300, 500, 500 ), 0.0, 0.0, [], 1.0  );
end;
like image 920
Brian Frost Avatar asked Jan 11 '23 23:01

Brian Frost


1 Answers

I found that Canvas.Stroke.Kind under Android is initialised to bkNone (the 0'th ordinal) so no output.

You need to include Canvas.Stroke.Kind := TBrushKind.bkSolid before you get output.

like image 108
Brian Frost Avatar answered Jan 25 '23 13:01

Brian Frost