how to convert a 2d coordinate to an index
Code Example - how to convert a 2d coordinate to an index
index = x + width * y;
js 1d index to 2d coord
y = index / width;
x = index % width;