Page 1 of 1
TPolygonShape
Posted: Tue Jul 14, 2009 6:29 pm
by 10546824
Is it possible, at this time, to apply an image to a TPolygonShape, with imagealignment of iaCenter and have the image fill out just within the boundaries of the polygon, rather than creating a rectangle?
Re: TPolygonShape
Posted: Thu Jul 16, 2009 3:37 pm
by yeray
Hi mendelo,
Take a look at the following example:
Code: Select all
uses TeCanvas;
procedure TForm1.FormCreate(Sender: TObject);
begin
PolygonShape1.ImageAlignment := iaCenter;
PolygonShape1.Image.LoadFromFile('C:\tmp\yourPicture.bmp');
end;
procedure TForm1.Tree1AfterDraw(Sender: TObject);
begin
Tree1.Canvas.UnClipRectangle;
end;
procedure TForm1.Tree1BeforeDraw(Sender: TObject);
var i: Integer;
c: Integer;
p: array of TPoint;
begin
c:=PolygonShape1.Points.Count;
SetLength(p, c);
for i:=0 To c-1 do
p[i] := TeePoint(PolygonShape1.Points.Point[i].X,
PolygonShape1.Points.Point[i].Y);
Tree1.Canvas.ClipPolygon(p, c);
end;
Re: TPolygonShape
Posted: Thu Jul 16, 2009 8:24 pm
by 10546824
Thank you Yeray
That does work, but only temporarily. If you perform any other change to the TTree, such as turn off the grid etc. then the image reverts back to a rectangle. Additionally it does weird things to other TTreeNodeShapes, such as causing the images not to display within all other shapes.
Thanks