How would I make flood filling from a specific point

Hello!
I’m trying to develop a Paper.io game. In my previos post someone suggested to use flood filling to fill the territory area. I’ve never heard about flooding and I don’t know how to create such a function or modify one.
I’ve tried modifying this function: flood filling post; but as I said, I don’t know what’s going on there and so it’s really difficult to adapt the function to my needs.

I’m happy about any help.

Here is a picture that describes of what I want to do:

make a [flood] function that gets all grey tiles next to the center point. then, loop those grey tiles and fill the tile and call the flood function for that tile. it will get all the grey tiles next to that tile that was just filled as well. eventually, the border will be reached where the tiles are already filled and it will not fill anymore.