Page 1 of 1

TTeePolygon

Posted: Mon Sep 26, 2011 11:38 am
by 10554308
Hi,

I want to dray a polygon and fill it with a calculated bitmap.
I followed an example from your site along these lines:

var
ASerie: TMapSeries;
APol: TTeePolygon;
begin
ASerie:=TMapSeries.Create(Chart1);
ASerie.ParentChart:=Chart1;
ASerie.Pen.Color:=clWhite; // color of polygon line
APol:=ASerie.Shapes.Add;
APol.Color:=clRed; // color inside polygon
APol.Points.Clear;
for n := 1 to 10 do
APol.Points.AddXY(x,y);
end;

In this case, the inside of the polygon will be solid red.
Is there a way to paint it with a custom bitmap ?

Regards, Matt

Re: TTeePolygon

Posted: Mon Sep 26, 2011 2:37 pm
by narcis
Hi Matt,

You can assign a bitmap to the TMapSeries, for example:

Code: Select all

uses TeeMapSeries;

procedure TForm1.FormCreate(Sender: TObject);
var
  ASerie  : TMapSeries;
  APol    : TTeePolygon;
  MyBmp   : TBitmap;
begin
  MyBmp:=TBitmap.Create;
  MyBmp.LoadFromFile('c:\temp\rocks.bmp');

  ASerie:=TMapSeries.Create(Chart1);
  ASerie.ParentChart:=Chart1;
  ASerie.Pen.Color:=clWhite; // color of polygon line
  ASerie.Brush.Bitmap:=MyBmp;

  APol:=ASerie.Shapes.Add;
  APol.Points.Clear;

  with APol.Points do
  begin
    AddXY(1,1);
    AddXY(1,10);
    AddXY(10,10);
    AddXY(10,1);
  end;
end;

Re: TTeePolygon

Posted: Mon Oct 03, 2011 9:23 pm
by 10554308
Thanks Narcis, that works. I obviously used the wrong brush here.
I would like to add some marks for the polygon, but I have only managed to get a single mark in the middle for the TMapSeries.
Is it at all possible to add marks to points of a polygon?

As a workaround, I could add a number of line series, which would have the same points, and use these to generate the marks from.

Regards, Matt

Re: TTeePolygon

Posted: Wed Oct 05, 2011 8:16 am
by yeray
Hello Matt,

As you've seen, the TMapSeries shows a mark for each shape, in the centre of the shape.
If you want a mark at each point/edge, the easiest solution would be using an extra series (like a TPointSeries) with a point for each edge. Here it is a simple example:

Code: Select all

uses TeeMapSeries, Series;

procedure TForm1.FormCreate(Sender: TObject);
var
  ASerie  : TMapSeries;
  AMSerie : TPointSeries;
  APol    : TTeePolygon;
  MyBmp   : TBitmap;
  i       : Integer;
begin
  Chart1.Legend.Visible:=false;
  Chart1.View3D:=false;

  MyBmp:=TBitmap.Create;
  MyBmp.LoadFromFile('c:\temp\rocks.bmp');

  ASerie:=TMapSeries.Create(Chart1);
  ASerie.ParentChart:=Chart1;
  ASerie.Pen.Color:=clWhite; // color of polygon line
  ASerie.Brush.Bitmap:=MyBmp;

  AMSerie:=TPointSeries.Create(Chart1);
  AMSerie.ParentChart:=Chart1;
  AMSerie.Marks.Visible:=true;
  AMSerie.Marks.Style:=smsXY;
  AMSerie.Pointer.Visible:=false;

  APol:=ASerie.Shapes.Add;
  APol.Points.Clear;
  with APol.Points do
  begin
    AddXY(1,1);
    AddXY(1,10);
    AddXY(10,10);
    AddXY(10,1);

    for i:=0 to Count-1 do
      AMSerie.AddXY(XValue[i], YValue[i]);
  end;
end;