Is there a way to apply the clipTo function to an image or SVG in order to constrain objects within the shape or outline?
I'm looking to achieve a similar goal as the user in this post, but the solutions provided were not clear to me.
I have successfully used clipTo with a regular shape, like so:
var circle = new fabric.Circle({
radius: 150,
stroke: '#f55',
fill: "transparent",
top: 50,
left: 50
});
circle.selectable = false;
canvas.add(circle);
canvas.clipTo = function (ctx) {
circle.render(ctx);
};
You can view a working example in this fiddle: http://jsfiddle.net/o9f4dqjn/1/
However, I have been unable to replicate this functionality with an image. Is there a way to make it work with images?