An 2d array of bits are given.

```
var map1 = [[0,0,0,0,0,0,0,0],
            [0,0,0,0,1,0,0,0],
            [0,0,1,1,1,1,1,0],
            [0,0,1,0,0,0,1,0],
            [0,0,1,1,0,0,1,0],
            [0,0,1,0,0,0,1,0],
            [0,0,1,1,1,1,1,0],
            [0,0,0,0,0,0,0,0]];

```

How I can programmaticaly check if some of the "ones" are forming a closed path ?

<http://jsfiddle.net/RvN3k/>

The two left bitmaps contains closed paths, the upper one is obvious, the lower one are simply a closed path with nothing inside.

The two right bitmaps doesn't contains closed paths, in the upper example one bit is missing, in the lower example the one diagonal pixel doesn't count, orthogonal paths only.