ericdrowell / KineticJS

KineticJS is an HTML5 Canvas JavaScript framework that extends the 2d context by enabling canvas interactivity for desktop and mobile applications.
http://www.kineticjs.com
3.98k stars 752 forks source link

How to create image mask with png #970

Open michaelDotco2 opened 10 years ago

michaelDotco2 commented 10 years ago

Is it possible to create an image mask with a transparent png treating the transparent areas as not part of the "shape" to mask. Eg an alpha mask.

pfautrero commented 10 years ago

According to me, there are two solutions :

  1. drawHitFromCache Just cache your image and call drawHitFromCache.
  2. Do it yourself with hitFunc http://www.html5canvastutorials.com/kineticjs/html5-canvas-kineticjs-custom-hit-function-tutorial/ You just have to play with context and getImageData, putImageData