I have been trying to show a image as oval shape but no luck.
below is my code snippet, which works for circle but there are gaps when we are converting image from rectangle to ellipse
how can i add both rx, ry in html canvas?
this is how current code converts my rectangle image to ellipse, there are gaps in height & width they are not accurate.
sample output image:
fabric.util.loadImage(imageURL, function (img) {
var oImg = new fabric.Image(img);
if (slot.image_shape == "ellipse") {
let shadow = (options && options.shadow) || {
affectStroke: true,
};
const radius =
oImg.width < oImg.height ? oImg.width / 2 : oImg.height / 2;
oImg.set({
clipTo: function (ctx) {
return ctx.arc(0, 0, radius, 0, Math.PI * 2, false);
},
});
}
question from:
https://stackoverflow.com/questions/65916009/fabric-js-how-to-make-an-image-in-the-shape-of-a-oval-with-strokes-shadow-etc 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…