PolygonFloat...world or screen coordinates?

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
JNuzzi
Newbie
Newbie
Posts: 11
Joined: Mon Mar 21, 2022 12:00 am

PolygonFloat...world or screen coordinates?

Post by JNuzzi » Wed Sep 18, 2024 1:49 pm

I don't know why I cannot find any documentation or previous posts about this, but do the xxFloat calls take world or screen coordinates? I tried sending world figuring that was the purpose and the points would be transformed to screen in the call, but it does not seem to be working.

Yeray
Site Admin
Site Admin
Posts: 9587
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: PolygonFloat...world or screen coordinates?

Post by Yeray » Thu Sep 19, 2024 6:34 am

Hello,

All the drawing methods in the canvas use screen coordinates.
Here you have an example using PolygonFloat function:
polygonfloat.png
polygonfloat.png (21.55 KiB) Viewed 94 times

Code: Select all

uses Chart, TeEngine, TeCanvas, Series;

var Chart1: TChart;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1:=TChart.Create(Self);

  with Chart1 do
  begin
    Parent:=Self;
    Align:=alClient;
    Color:=clWhite;
    Gradient.Visible:=False;
    Walls.Back.Color:=clWhite;
    Walls.Back.Gradient.Visible:=False;
    Legend.Hide;
    View3D:=False;

    AddSeries(TPointSeries).FillSampleValues;

    OnAfterDraw:=ChartAfterDraw;
  end;
end;

procedure TForm1.ChartAfterDraw(Sender: TObject);
var
  series: TChartSeries;
  polygon: Array of TPointFloat;
  tmpBlend : TTeeBlend;
  i: Integer;
begin
  if Chart1.SeriesCount<1 then
     Exit;

  series:=Chart1[0];
  if series.Count<2 then
     Exit;

  SetLength(polygon, series.Count+2);

  for i:=0 to series.Count-1 do
  begin
    polygon[i].x:=series.CalcXPos(i);
    polygon[i].y:=series.CalcYPos(i);
  end;

  polygon[i].x:=polygon[i-1].x;
  polygon[i].y:=Chart1.Axes.Bottom.PosAxis;

  Inc(i);
  polygon[i].x:=polygon[0].x;
  polygon[i].y:=polygon[i-1].y;

  tmpBlend:=Chart1.Canvas.BeginBlending(Chart1.ChartRect, 50);
  Chart1.Canvas.Pen.Style:=psDash;
  Chart1.Canvas.Brush.Color:=clRed;
  Chart1.Canvas.PolygonFloat(polygon);
  Chart1.Canvas.EndBlending(tmpBlend);
end;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply