html5-canvas Clip images inside shapes with "source-in"


Example

context.globalCompositeOperation = "source-in";

source-in compositing clips new drawings inside an existing shape.

Note: Any part of the new drawing that falls outside the existing drawing is erased.

context.drawImage(oval,0,0);
context.globalCompositeOperation='source-in';  // picture clipped inside oval
context.drawImage(picture,0,0);

enter image description here