Registriert seit: 8. Jun 2009
Ort: Bayern
1.138 Beiträge
Delphi 11 Alexandria
|
AW: FMX bunte Linien zeichnen .... Random Farbwert
18. Aug 2020, 08:56
aktuelle Lösung :
Delphi-Quellcode:
function randomColor: TColor;
var
rec: TAlphaColorRec;
begin
with rec do
begin
A := random(255);
R := random(255);
G := random(255);
B := random(255);
end;
Result := rec.Color;
end;
procedure TForm1.btn_draw_linesClick(Sender: TObject);
var
p1, p2: TPointF;
i, j: Integer;
Brush: TStrokeBrush;
begin
for i := 1 to 100 do
begin
Brush := TStrokeBrush.Create(TBrushKind.Solid, randomColor);
Brush.Thickness := 2;
// Brush.Kind := Solid;
p1 := TPointF.Create(2, 2);
p2 := TPointF.Create(random(400), random(400));
localBMP.Canvas.BeginScene;
// draw lines on the canvas
localBMP.Canvas.DrawLine(p1, p2, 1, Brush);
localBMP.Canvas.EndScene;
LoadBMP2GUI(nil);
Brush.Free;
end;
end;
|
|
Zitat
|