// tests/fixtures/_setup.js // Run once to create test fixtures. Not part of regular tests. const fs = require('node:fs'); const path = require('node:path'); const { PNG } = require('pngjs'); function writeSolidPng(filePath, w, h, rgba) { const png = new PNG({ width: w, height: h }); for (let y = 0; y < h; y++) { for (let x = 0; x < w; x++) { const i = (y * w + x) * 4; png.data[i + 0] = rgba[0]; png.data[i + 1] = rgba[1]; png.data[i + 2] = rgba[2]; png.data[i + 3] = rgba[3]; } } fs.writeFileSync(filePath, PNG.sync.write(png)); } function writeSolidL8Png(filePath, w, h, v) { const png = new PNG({ width: w, height: h, colorType: 0 }); // grayscale for (let y = 0; y < h; y++) { for (let x = 0; x < w; x++) { png.data[(y * w + x) * 4 + 0] = v; png.data[(y * w + x) * 4 + 1] = v; png.data[(y * w + x) * 4 + 2] = v; png.data[(y * w + x) * 4 + 3] = 255; } } fs.writeFileSync(filePath, PNG.sync.write(png)); } const dir = path.resolve(__dirname, 'small-fresh'); fs.mkdirSync(dir, { recursive: true }); writeSolidPng(path.join(dir, 'grass_diffuse.png'), 32, 32, [110, 170, 80, 255]); writeSolidPng(path.join(dir, 'stone_diffuse.png'), 32, 32, [120, 120, 120, 255]); writeSolidPng(path.join(dir, 'water_diffuse.png'), 32, 32, [ 60, 110, 180, 255]); writeSolidL8Png(path.join(dir, 'water_height.png'), 32, 32, 0); // L8=0 plane console.log('fixtures written: small-fresh/');