Skip to content

piratefsh/pixel-color-cruncher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#Pixel Color Cruncher

Given an image, gives you the a palette of colors from it. A median-cut color quantization implementation.

Demo

See it in action here: demo!

To use

Pixel cruncher is a WebWorker.

// create web worker
var pixelCruncher = new Worker('/js/pixel-cruncher.js'); // or wherever pixel-cruncher.js is located

pixelCruncher.addEventListener('message', function(e){
    var colors = e.data;

    // returns an array of [r,g,b] colors that you can now use
    doSomethingWith(colors);
});

// spawn worker thread to crunch pixels. num_colors must be multiple of 2
pixelCruncher.postMessage({data: imageData, num_colors: 16});

Refer to js/main.js for a usage example.

Credits

Shoutout to Giorgio who paired on me with this!

About

Given an image, find a palette of colors.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published