floodFill = function(bmp, x, y, targetColor, replacementColor) // Check if pixel is outside the bounds if not(0 < x < bmp.width) or not(0 < y < bmp.height) then return // Check the current pixel color currentColor = bmp.pixel(x, y) if currentColor != targetColor then return // Replace the color bmp.setPixel x, y, replacementColor // Recursively apply to adjacent pixels floodFill(bmp, x + 1, y, targetColor, replacementColor) floodFill(bmp, x - 1, y, targetColor, replacementColor) floodFill(bmp, x, y + 1, targetColor, replacementColor) floodFill(bmp, x, y - 1, targetColor, replacementColor) end function clear img = file.loadImage("Unfilledcirc.png") gfx.drawImage img, 0, 0 floodFill gfx, 50, 50, "#FFFFFFFF", "#00FFFFFF" floodFill gfx, 100, 125, "#000000FF", "#0000FFFF"