Hello folks! In this part, I’ll be talking about our second feature that I finished this week and it is… Bucket Fill! One of the most anticipated features for editing your maps! Now you can fill the areas you want!
As you can see in the gif, you can select a type, tap on the area you want to fill, and here you go! Also, you can undo and redo the changes you’ve done.
For implementing this, the good ol’ Flood Fill algorithm helped me a lot. You can find detailed info from this link but TLDR:
We create an empty queue. Then in a while loop we enqueue the cells around the center cell , dequeue each one in an iteration and change their Type (color) till the area is empty.
It was an easy one to implement and had fun while I remembered the days I saw this algorithm from my university days.
In Part 3, I’ll be talking about Rectangle brush!
Stay in tune!