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

applyMask

Applies transparency from mask to the layer

cq().applyMask();

Mask can be an array of [0.0 - 1.0] values or

Mask can be an array of [false | true] values

Grayscale mask:

var layer = cq(400, 200).clear("#004").appendTo(document.body);

loadImages("graymask", function(images) {

  /* mask image */

  layer.drawImage(images.graymask, 0, 0);

  /* some image to be merged with mask */

  var orangeRect = cq(240, 32).clear("#fa0");

  layer.drawImage(orangeRect.canvas, 0, 40);

  /* apply mask */

  var mask = cq(images.graymask).grayscaleToMask();
  orangeRect.applyMask(mask);
  layer.drawImage(orangeRect.canvas, 0, 80);

});


Have any questions? Don't hesitate to ask:

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