Made a function to count bitmaps around a given point in JS