I want to set a global clipTo
in my Fabric-powered Canvas that will affect all user-added layers. I want a background image and an overlay image, which are unaffected by this clip mask.
Example:
Here's what's happening in this photo:
- A canvas overlay image makes the t-shirt look naturally wrinkled. This overlay image is mostly transparent
- A background image in the exact shape of the t-shirt was added, which is supposed to make the t-shirt look blue
- A
canvas.clipTo
function was added, which clips the canvas to a rectangular shape - A user-added image (the famous Fabric pug) was added
I want the user-added image (the pug) to be limited to the rectangular area.
I do not want the background image (the blue t-shirt shape) affected by the clip area.
Is there a simple way to accomplish this? I really don't want to have to add a clipTo
on every single user layer rather than one tidy global clipTo
.
You can play with a JS fiddle showing the problem here.