New features, small fixes Part 2: Bucket Fill!

Standard

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!

fill bucket.gif

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!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s