const COLUMNS = 5;
const ROWS = 5;
const CELL_WIDTH = 32;
const CELL_HEIGHT = 32;
function updateAnchor(anchor, index) {
const column = (index - 1) % COLUMNS;
const row = Math.floor((index - 1) / COLUMNS);
return {
// Outputs -64, -64, -64, ...
x: column * CELL_WIDTH - (COLUMNS - 1) * CELL_WIDTH / 2,
// Outputs -64, -32, -0, ...
y: row * CELL_HEIGHT - (ROWS - 1) * CELL_HEIGHT / 2,
};
}