Fabric.js set text color

Fabric.js is a powerful javascript canvas library which wraps html5 canvas operation, and introduces objects (text, shape, path, etc.) to developer.

There is a common method set() for object, it can be used to set property of an object. But if you want to change text color, text.set(‘color’, ‘#0f0’) will not work.

To set color of text, we need modify the fill attribute or use setColor() method (only available for text object)

Or

 

 

  • http://codeaffair.com/ Saransh Dhingra

    Its weird, that I couldn’t find this in their main tutorial page for text. or maybe I didn’t look properly!
    Anyway, thanks!