how to convert a 2d coordinate to an index

39

js 1d index to 2d coord -

y = index / width;
x = index % width;

how to convert a 2d coordinate to an index -

index = x + width * y;

Comments

Submit
0 Comments