Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | 30x 17x 17x 17x 1x 16x 16x 16x 16x 88x 1497x 1497x 1497x 16x | export const resizeTiles = (
tiles: number[],
initialWidth: number,
initialHeight: number,
outputWidth: number,
outputHeight: number,
): number[] => {
const newWidth = Math.max(0, outputWidth);
const newHeight = Math.max(0, outputHeight);
if (newWidth === initialWidth && newHeight === initialHeight) {
return tiles;
}
const outputTiles = new Array(newWidth * newHeight).fill(0);
const rowsToCopy = Math.min(initialHeight, newHeight);
const colsToCopy = Math.min(initialWidth, newWidth);
for (let row = 0; row < rowsToCopy; row++) {
for (let col = 0; col < colsToCopy; col++) {
const oldIndex = row * initialWidth + col;
const newIndex = row * newWidth + col;
outputTiles[newIndex] = tiles[oldIndex];
}
}
return outputTiles;
};
|