forked from phenom/healer-man
Release Healer Man 0.1.40
This commit is contained in:
1 parent
ed0d2fea3d
commit
197a64117c
215 files changed
+5131
-181
No files matched your search
@@ -0,0 +1,12 @@
|
||||
/** WoW's twelve row-major 256px tiles are cropped to the client map's 1002x668 rectangle. */
|
||||
export function stitchMap(tiles) {
|
||||
if (tiles.length !== 12) throw new Error("A map requires all twelve tiles");
|
||||
const width = 1002, height = 668, pixels = Buffer.alloc(width * height * 4);
|
||||
tiles.forEach((tile, index) => {
|
||||
if (tile.width !== 256 || tile.height !== 256) throw new Error("Unexpected map tile dimensions");
|
||||
const x = (index % 4) * 256, y = Math.floor(index / 4) * 256;
|
||||
const copyWidth = Math.min(256, width - x), copyHeight = Math.min(256, height - y);
|
||||
for (let row = 0; row < copyHeight; row += 1) tile.pixels.copy(pixels, ((y + row) * width + x) * 4, row * 256 * 4, (row * 256 + copyWidth) * 4);
|
||||
});
|
||||
return { width, height, pixels };
|
||||
}
|
||||
Reference in new issue
Block a user