Registriert seit: 12. Jun 2008
175 Beiträge
Delphi 12 Athens
|
AW: TPlotgrid zeichnet Strich in Polygon
13. Okt 2022, 08:47
... 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;
Steffen
Geändert von Stewag (13. Okt 2022 um 09:28 Uhr)
|
|
Zitat
|