Simple "edge" detection

I just can’t get around this.
I have a 2D array with each cell consisting of ONE character (either a “.” or “#”) where the “.” is a “floor” and the “#” is a “wall”

what I need to do is convert all the “FLOOR” that is OUTSIDE the outer wall to a “+” to represent “dirt” for lack of a better description

So I’d like this

..###.###..
..#.#.#.#..
..#.#.#.#..
###.#.#.###
#...#.#...#
#..#...#..#
#...#.#...#
###..#.###.
..#.....#..
..#######..

to become This

++###+###++
++#.#+#.#++
++#.#+#.#++
###.#+#.###
#...#+#...#
#..#+++#..#
#...#+#...#
###..#.###+
++#.....#++
++#######++

The problem is there are vertical and horizontal INTERNAL walls, so just crossing a wall doesn’t mean you went from inside to outside

I would enclose the entire thing in one more set of dots and flood-fill.
This

..###.###..
..#.#.#.#..
..#.#.#.#..
###.#.#.###
#...#.#...#
#..#...#..#
#...#.#...#
###..#.###.
..#.....#..
..#######..

Becomes

.............
...###.###...
...#.#.#.#...
...#.#.#.#...
.###.#.#.###.
.#...#.#...#.
.#..#...#..#.
.#...#.#...#.
.###..#.###..
...#.....#...
...#######...
.............

http://en.wikipedia.org/wiki/Point_in_polygon

worked perfectly… slapping forehead for not thinking of this one myself :slight_smile:

Array is temp_level
replace exterior “:” characters with “+” characters

call flood_fill 1,0 // X is one-based, but Y is zero based

  If x<1 Or y<0 Then Exit Sub
  If y>temp_level.Ubound Then Exit Sub
  If x>temp_level(y).Len Then Exit Sub
  
  //
  If Mid(temp_level(y),x,1)=":" Then 
    temp_level(y)=Left(temp_level(y),x-1)+"+"+Mid(temp_level(y),x+1)
    //
    flood_fill(x+1,y)
    flood_fill(x-1,y)
    flood_fill(x,y+1)
    flood_fill(x,y-1)
  End If