Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi TPlotgrid zeichnet Strich in Polygon (https://www.delphipraxis.net/201727-tplotgrid-zeichnet-strich-polygon.html)

Stewag 13. Okt 2022 07:47

AW: TPlotgrid zeichnet Strich in Polygon
 
... hier die Lösung, aus https://www.youtube.com/watch?app=de...nnel=QuarkCube
:-)

Code:
var
  FPoints: TPolygon;

procedure TfMain.CalculateCos;
var
  i: Integer;
begin
  SetLength(FPoints, Resolution + 1); // Alloc space for number of points to be calculated
  SetParams;
  for i := 0 to High(FPoints) do
  begin
    FPoints[i].X := Origin.X + Radian * xPixels / Pi; // Calculate X value with scaling
    FPoints[i].Y := Origin.Y - cos(Radian) * yPixels; // Calculate Y value (f(X)) with scaling
    Radian := Radian + Interval; // Set next point
  end;
end;

procedure TfMain.PlotGridPaint(Sender: TObject; Canvas: TCanvas; const ARect: TRectF);
var
  i: Integer;
begin
  PlotGrid.Canvas.Stroke.Thickness := 2; // Liniendicke
  CalculateCos; // hier nur Cosinus
  PlotGrid.Canvas.Stroke.Color := TAlphaColorRec.White;

  for i := 1 to High(FPoints) do
    PlotGrid.Canvas.DrawLine(FPoints[i - 1], FPoints[i], 1);
end;


Alle Zeitangaben in WEZ +1. Es ist jetzt 22:32 Uhr.
Seite 2 von 2     12   

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz