Einzelnen Beitrag anzeigen

bernhard_LA

Registriert seit: 8. Jun 2009
Ort: Bayern
1.123 Beiträge
 
Delphi 11 Alexandria
 
#1

FMX bunte Polygone zeichnen

  Alt 18. Aug 2020, 08:23
scheitere aktuell dabei jetzt bunte Polygone zu zeichnen


hier der Demo code :


Delphi-Quellcode:
procedure TForm1.btn_draw_PolygonClick(Sender: TObject);
var
  p1, p2, p3, p4, p5: TPointF;
  MyPolygon: TPolygon;
  I: Integer;
  Brush: TStrokeBrush;
begin


  for I :=1 to 10 do
  begin
  Brush := TStrokeBrush.Create(TBrushKind.Solid, randomColor);
  Brush.Thickness := 2;
  // sets the points that define the polygon
  p1 := TPointF.Create(200+ Random(50), 220 + Random(50) );
  p2 := TPointF.Create(250+ Random(50), 360+ Random(50));
  p3 := TPointF.Create(280+ Random(50), 260+ Random(50));
  p4 := TPointF.Create(200+ Random(50), 180+ Random(50));
  p5 := TPointF.Create(100+ Random(50), 160+ Random(50));
  // creates the polygon
  SetLength(MyPolygon, 5);
  MyPolygon[0] := p1;
  MyPolygon[1] := p2;
  MyPolygon[2] := p3;
  MyPolygon[3] := p4;
  MyPolygon[4] := p5;

  // localBMP.Canvas.Stroke := Brush; geht nicht weil read only property ......

  localBMP.Canvas.BeginScene;
  // draws the polygon on the canvas
  localBMP.Canvas.DrawPolygon(MyPolygon, 50) ;
  localBMP.Canvas.EndScene;
  // updates the bitmap
  // Image1.Bitmap.BitmapChanged;

  LoadBMP2GUI(nil);

  Brush.Free;
  end;
end;

ich kann den Brush nicht an meine Bitmap übergeben , und einen Aufruf incl. Brush gibt es für Canvas.DrawPolygon nicht
Miniaturansicht angehängter Grafiken
random_polygon.jpg  

Geändert von bernhard_LA (18. Aug 2020 um 08:27 Uhr)
  Mit Zitat antworten Zitat