-
Notifications
You must be signed in to change notification settings - Fork 0
shashashasha/palette-map-js
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
palette-map.js Allows you to map one set of colors to an existing Canvas, based on the pixel data contained. This is similar to Actionscript's BitmapData.paletteMap method An example is here: http://shashashasha.github.com/palette-map-js/ Usage: // create the web worker var paletteMapper = new Worker('palette-map.js'); var imageData = ctx.getImageData(0, 0, canvas.width, canvas.height); // pass it the arrays of colors to be mapped paletteMapper.postMessage({ // possible modes include scaled-rgb, scaled-rgba, mode: 'scaled-rgb', r: [an Array of values to be mapped to the Red channel], g: [an Array of values to be mapped to the Green channel], b: [an Array of values to be mapped to the Blue channel], imageData: imageData }); // place the pixels back paletteMapper.addEventListener('message', function(e) { if (e.data.imageData) { ctx.putImageData(e.data.imageData, 0, 0); } }, false);
About
Web Worker that can map imageData to a new palette given R, G, B or Alpha arrays
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published