I am using Fabric.js to create some animations on HTML canvas. I need to make this :
If I use image element I cannot make it circular and not put white border.
If I use circle object I cannot put an image in it.
Any ideas will be appreciated. TIA
Try someting like this with clipTo
function:
fabric.Image.fromURL(imageURL, function(oImg) {
oImg.scale(1.0).set({
left: 10,
top: 10,
stroke : 'white',
strokeWidth : 100,
clipTo: function (ctx) {
ctx.arc(0, 0, radius, 0, Math.PI * 2, true);
}
});
canvas.add(oImg).setActiveObject(oImg);
canvas.renderAll();
});
Fiddle: http://jsfiddle.net/q6Y6k/8/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With