Filling a wall of wool

Discussion in 'Plugin Development' started by Milkaselnuss, Mar 16, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    Milkaselnuss

    Hi,

    at the moment I have a big wall out of wool.
    I have already programmed that i can draw on this wall with different colors.
    BUT what I want now is to have the ability to fill out everything that is connected like in paint.
    Example: I draw a circle and now i want to fill it with any color (I know how to change the color) but how do I know which blocks are inside and which are out. and what if I make more difficult pictures?

    I hope you understand what i mean, otherwise I'll explain it in more detail. Just ask for more information.

    push

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  2. Offline

    GameplayJDK

    Milkaselnuss
    I know what you mean, but it won't be easy. Filling an area is done by a nested for loop.
    for (int x = x1; x < width; x++) { // depend on how your wall is build, facing x or z
    for (int y = y1; y < height; y++) {
    ...
    But it'd be easier to calculate the coordinates of a circle based on the centered block with a given radius than checking if an area is surrounded by wool blocks with another color.
     
  3. Offline

    Milkaselnuss

    The problem is that it's not a perfect circle because i draw it by hand.
    I don't know if you know the Mineplex Server. The gamemode DrawMyThing is basically the same I am doing at the moment and they have a fill option with a bucket. That's what I'm trying to do, too.
    So if anyone has an idea of easily doing this, please post it :)

    push

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  4. Offline

    Ironraptor3

    Hm. I'm too lazy to write the actual code, but you should save the color of the block they clicked on, then get the relative blocks for that. If they are the same color, set their color to the chosen color, and add them to a list. Every time the list goes through, check all the relative blocks to the most recent on the list. That's the general idea
     
Thread Status:
Not open for further replies.

Share This Page