[SOLVED] FloodFill on Canvas lazarus / 39-Graphics ---------------------------------------------------------------------- gafe · 2015-01-04 11:14 Hi: In my way to learn, i'm trying to implement a penrose tiling program (from one in python http://preshing.com/20110831/penrose-tiling- explained/). I'm almost there as you can see in attached image, but i'm drawing in a canvas and want to fill the triangles, but floodfill doesn't work (here it's linux with gtk). I have read http://bugs.freepascal.org/view.php?id=2001 and understand that maybe it's not implemented for gtk. I followed FloodFill until i get to intfbasewinapi.inc which have: Code: [Select]function TWidgetSet.FloodFill(DC: HDC; X, Y: Integer;   Color: TGraphicsColor;   FillStyle: TGraphicsFillStyle;   Brush: HBRUSH): Boolean; begin   Result := false; end;    My question is: if it's not implemented, there's another easy way to do it? I have found a implementation on a german forum that works with a bitmap (http://www.lazarusforum.de/viewtopic.php?f=25&t=3891 As always..thank you. ---------------------------------------------------------------------- Blaazen · 2015-01-04 12:52 Probably it is not implemented (I did a quick test and GTK2 and Qt cannot do floodfill) but the code you linked is not proof. TWidgetSet is abstract class, you should look elsewhere - depend on your widgetset. ---------------------------------------------------------------------- gafe · 2015-01-04 15:29 I tried on windows: Code: [Select] with Form1.Canvas do   begin   Pen.Color:=clWhite;   Moveto(50,50);   LineTo(100,50);   Lineto(100,100);   Lineto(50,100);   LineTo(50,50);   Brush.Color:=clgreen;   FloodFill(60,60,Form1.canvas.Pixels[60,60],fssurface);   end; and works well, surely it's not implemented.I'll try to adapt the code from the german forum to a canvas, or paint in a bitmap instead of a paintbox. Thanks. ---------------------------------------------------------------------- Carver413 · 2015-01-04 22:17 http://en.wikipedia.org/wiki/Flood_fill A simple 4 point recursive flood is pretty easy to implement. Thanks for the link, I'm always interested it stuff like this as I am working on a procedural engine for designing textures for games an such. ---------------------------------------------------------------------- gafe · 2015-01-18 13:48 If someone comes here with this problem, I solved it using Canvas2D from BGRABitmap, it is the same canvas as in javascript. Works well in all platforms.