Skip to content

Instantly share code, notes, and snippets.

@andrei-cacio
Created May 16, 2018 14:28
Show Gist options
  • Save andrei-cacio/7dfec242d4821756fc68920c46371d2e to your computer and use it in GitHub Desktop.
Save andrei-cacio/7dfec242d4821756fc68920c46371d2e to your computer and use it in GitHub Desktop.
The desired output of distil-wasm
async function distil(imgPath, nrOfPalettes = 2) {
const wasmModule = await compile('distil.wasm');
const { imgBufferLocation, length } = await readImgIntoMemory(imgPath);
const paletteBuffer = wasmModule.exports.distil(imgBufferLocation, length);
console.log(bufferToHex(paletteBuffer, nrOfPalettes));
}
// -> ['#ff1122', '#jjkkll']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment