just some floodfill code in js.