`;
+ // Calculate scale to fit tiles in 32x32 display boxes
+ const displaySize = 32;
+ const scale = displaySize / sheet.TileWidth;
+ const scaledSheetW = sheet.SheetWidth * scale;
+ const scaledSheetH = sheet.SheetHeight * scale;
+
+ let html = `
`;
for (const tile of sheet.Tiles) {
if (currentFilter !== 'all' && tile.Type !== TileType[currentFilter]) continue;
const col = tile.FrameIndex % sheet.Columns;
const row = Math.floor(tile.FrameIndex / sheet.Columns);
- const bgPos = `-${col * sheet.TileWidth}px -${row * sheet.TileHeight}px`;
+ // Scale the position too
+ const bgPosX = col * sheet.TileWidth * scale;
+ const bgPosY = row * sheet.TileHeight * scale;
const isSelected = selectedTile && selectedTile.id === tile.Id;
const borderClass = isSelected ? 'border-yellow-400 border-2' : 'border-gray-600 border';
@@ -222,7 +230,7 @@
html += `
+ style="width: ${displaySize}px; height: ${displaySize}px; background-image: url('${imgUrl}'); background-position: -${bgPosX}px -${bgPosY}px; background-size: ${scaledSheetW}px ${scaledSheetH}px; image-rendering: pixelated;">
`;
}
@@ -288,7 +296,7 @@
}
html += `