import fs from 'node:fs'; import {fileURLToPath} from 'node:url'; const source=fs.readFileSync(fileURLToPath(new URL('../DuneRealmsGUI/planet-artwork/flat-sand/default_sand.png',import.meta.url))); const table=Array.from({length:256},(_,n)=>{for(let i=0;i<8;i++)n=(n&1)?0xedb88320^(n>>>1):n>>>1;return n>>>0;}); function crc(bytes){let n=0xffffffff;for(const b of bytes)n=table[(n^b)&255]^(n>>>8);return (n^0xffffffff)>>>0;} // Palette-only build transform: preserve the source's exact grain and seamless tile. export function palette(rgb,contrast=.3,darken=1){ const out=Buffer.from(source);if(out[25]!==3)throw Error('Pinned indexed sand PNG required'); for(let i=8;i