From Xojo Documentation

You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!

RGBSurface.FloodFill(x as Double, y as Double, FillColor as Color)

New in 5.5

Supported for all project types and targets.

Performs a "floodfill" (the action performed by a PaintBucket tool in an image editing program) on an RGBSurface.


The pixel at x, y and all adjacent pixels of the same color are changed to the passed FillColor.

Sample Code

The following code uses the FloodFill method to paint an RGBSurface object in a random color. It is in the MouseDown event of a DesktopCanvas control. The variable p is a Picture object.

Var randomColor As Color
randomColor = Color.RGB(Rnd * 255, Rnd * 255, Rnd * 255) // create random color
p.RGBSurface.FloodFill(x, y, randomColor) // fill the area with the color
Me.Graphics.DrawPicture(p, 0, 0) // repaint the canvas control