Brian Alderson
Brian Alderson

Reputation: 51

How do I get the shadow color value of some text in Fabric JS?

I can't seem to find any reference in the Fabric.js docs (or anywhere else) on how to get the shadow color value of some text placed on the canvas?

I'm quite new to Fabric.js.

Upvotes: 1

Views: 718

Answers (2)

Brian Alderson
Brian Alderson

Reputation: 51

Here's how to get the rgb values of a text shadow color:

...
var activeObject = canvas.getActiveObject();
var shadColor = activeObject.shadow.color;
var shadProps = shadColor.split(",");

var r = shadProps[0];
r = r.replace("rgb(", "");

var g = shadProps[1];

var b = shadProps[2];
b = b.replace(")", "");

console.log('Red: '+r+'   Green: '+g+'   Blue: '+b);
...

Upvotes: 1

StefanHayden
StefanHayden

Reputation: 3669

if you have a reference to the fabric object it's located at: fabricObject.shadow.color

Upvotes: 0

Related Questions