This page is work-in-progress. You can reach me on twitter or mail to rezoner1337@gmail.com

getPalette

Returns all unique colors in a layer

cq().getPalette();
var layer = cq(800, 200).clear("#000").appendTo(document.body);

loadImages("ship", function(images) {

  layer.drawImage(images.ship, 0, 32);

  var palette = cq(images.ship).getPalette();

  for(var i = 0; i < palette.length; i++) {
    var color = palette[i];

    layer.fillStyle(color).fillRect(24 * i, 0, 24, 24);
  }  
});


Have any questions? Don't hesitate to ask:

Post issues on github, support my work on gratipay author rezoner