Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // draw the phone case on the canvas
- context.drawImage(phonecase,0,0);
- // set compositing to source-in
- // future drawings will only be visible where existing pixels are opaque
- context.globalCompositeOperation='source-in';
- // draw the artwork over the phonecase
- // compositing will display the artwork only inside the opaque phonecase pixels
- context.drawImage(artCanvas,offsetX,offsetY);
- // always clean up! Return compositing to its default mode
- context.globalCompositeOperation='source-out';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement