Код: Выделить всё
const tiles = 'https://static.koalabeast.com/textures/musclescupgradients/tiles.png';
(async () => {
const app = new PIXI.Application();
await app.init({ width: 640, height: 440 });
document.body.appendChild(app.view);
const sheetTexture = await PIXI.Assets.load(tiles);
const w = 40;
const sheetBase = sheetTexture.baseTexture;
const cols = Math.floor(sheetBase.width / w);
const rows = Math.floor(sheetBase.height / w);
const tileTextures = [];
for (let row = 0; row < rows; row++) {
for (let col = 0; col < cols; col++) {
const x = col * w;
const y = row * w;
const frame = new PIXI.Rectangle(x, y, w, w);
const tileTex = new PIXI.Texture({ source: sheetBase, frame });
tileTextures.push(tileTex);
const sprite = new PIXI.Sprite(tileTex);
sprite.x = col * w;
sprite.y = row * w;
app.stage.addChild(sprite);
}
}
})();
Исходное изображение
Подробнее здесь: https://stackoverflow.com/questions/796 ... -js-v8-6-6