/** * WebGL readback into a canvas, the right way up. * * Its own module because two debug pages need it and neither should pull in the * other's dependencies to get it. It lived in checks/gallery.js, and importing * it from the filmstrip dragged the entire gallery — the engine, the song bank, * the look generator, the whole scene library — into a page that wanted ten * lines of pixel copying. */ export function blit(canvas, pixels, width, height) { canvas.width = width; canvas.height = height; const ctx = canvas.getContext('2d'); const image = ctx.createImageData(width, height); const row = width * 4; for (let y = 0; y < height; y++) { const src = (height - 1 - y) * row; image.data.set(pixels.subarray(src, src + row), y * row); } ctx.putImageData(image, 0, 0); }