Changing Opacity of Text and Text Bacground separately in Fabric JS

Viewed 107

I am adding text to the Canvas using Fabric JS.

let text = new fabric.IText('My Text', {
    fill: 'black',
    fontSize: 40,
    textBackgroundColor: 'yellow'
})

canvas.add(text);

If I change Opacity of text like this:

 text.set({'opacity': 0});

It also changes the Opacity of Text Background which I do not want. I want to change the Opacity of Text without changing it's background.

Actually, I want to punch out Text or you can say set text opacity to '0' with out changing Backgound of text.

Like This:

enter image description here

Is there any way I can do that?

0 Answers
Related