RGBSurface.FloodFill

From Xojo Documentation

Method

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.

Notes

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 Canvas control. The variable p is a Picture object.

Var randomColor As Color
randomColor = 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