user4039871
user4039871

Reputation:

Fabric.js how to set opacity of lines

Using the fabric.js library, I can set line width and color as follows:

canvas.freeDrawingBrush.width = 5;
canvas.freeDrawingBrush.color = "#f00";

Is there a way to set the opacity too? Couldn't find anything in the documentation, neither on the net anywhere.

Upvotes: 3

Views: 2241

Answers (1)

leroydev
leroydev

Reputation: 2945

Instead of using a hexadecimal color code, you can set color to use rgba, like below:

canvas.freeDrawingBrush.color = 'rgba(255, 0, 0, 0.1)';

Demo JSFiddle

Upvotes: 5

Related Questions