Einzelnen Beitrag anzeigen

Stewag

Registriert seit: 12. Jun 2008
161 Beiträge
 
Delphi 12 Athens
 
#1

AW: TPlotgrid zeichnet Strich in Polygon

  Alt 11. Okt 2022, 17:09
Leider wird der Path in D11 (in Android) wieder durch den Strich geschlossen
https://www.swiftease.de/download/Sc...011-221811.PNG

Hat jemand eine Idee, wie Rollos obiger T289_Plotgrid Code angepasst werden kann?

Rollo hatte im Sample Code (https://docwiki.embarcadero.com/Code...tGrid_(Delphi))) das Polygon durch einen Pfad ersetzt.
Das hat bis D10 funktioniert.

Hier der zentrale Code (nur Cosinus):
Code:
procedure TForm1.CalculateCos;
var
  I : Integer;
  LPt: TPointF;
  LStr: string;
begin
  FPathData.Clear;

  SetParams;
  SetLength(FPoints, Resolution);                      // Alloc space for number of points to be calculated

  // First point moveto
  LPt := PointF( Origin.x + Radian * xPixels / Pi,
                 Origin.y - cos(Radian) * yPixels );

  LStr := LStr + 'M'
               + Format('%1.2f', [LPt.X], FFormatSettings)
               + ', '
               + Format('%1.2f', [LPt.Y], FFormatSettings)
               ;

  Radian := Radian + Interval;                       // Set next point

  for I := 1 to High(FPoints) do
  begin

    LPt := PointF( Origin.x + Radian * xPixels / Pi,
                   Origin.y - cos(Radian) * yPixels );

    LStr := LStr + 'L'
                 + Format('%1.2f', [LPt.X], FFormatSettings)
                 + ', '
                 + Format('%1.2f', [LPt.Y], FFormatSettings)
                 ;


    Radian := Radian + Interval;                       // Set next point
  end;

  LStr := LStr + 'M0 0';
  LStr := LStr + 'Z';

  FPathData.Data := LStr;

end;

procedure TForm1.SetParams;
begin
  Resolution := 200;                   // Set resolution to 200 points
  Radian := -2.0 * Pi;                 // Start angle at -2Pi
  xPixels := PlotGrid.Width / 4;       // Contain graph width within a quarter of the grid width (actually half because of neg values)
  yPixels := PlotGrid.Height / 4;      // Contain graph height within a quarter of the grid height (actually half because of neg values)
  Origin := PointF(PlotGrid.Width / 2, // Calculate the center point of the plot grid
    PlotGrid.Height / 2);
  Interval := 4.0 * Pi / Resolution;   // Set interval between two points in which function values are calculated
end;



procedure TForm1.PlotGridPaint(Sender: TObject; Canvas: TCanvas;
  const ARect: TRectF);
begin
  PlotGrid.Canvas.Stroke.Thickness := 3;                 // Set stroke thickness

  CalculateCos;
  PlotGrid.Canvas.Stroke.Color := TAlphaColorRec.Blue;  // Set color for cos to blue
  PlotGrid.Canvas.DrawPath( FPathData, 1.0 ); // DrawPolygon(FPoints, 1);              // Draw cos graph
end;
Steffen

Geändert von Stewag (12. Okt 2022 um 10:16 Uhr)
  Mit Zitat antworten Zitat