Search code examples
delphifiremonkey

How do I draw a shape with a hole in it?


How do I draw a blue square with a transparent circular hole in the middle, as shown below, using Delphi and Firemonkey?

I want to draw something like this:

transparent circle on blue surface

But I can't find a way to make the circle transparent :(


Solution

  • Something like this should do it:

    var lPath: TPathData;
    begin
      lPath := TPathData.Create;
      lPath.AddRectangle(RectF(0,0,100,100), 0,0, []);
      lPath.AddEllipse(RectF(20,20,80,80));
      Canvas.Fill.Color := $FF8080FF;
      Canvas.FillPath(lPath,1);
      lPath.Free;
    end;