Wednesday, 15 April 2015

fabricjs - How to get the background color of a canvas -


What I'm trying to do is this: using Fabricjs, I have the warning ("BG Color : "+ Canvas.getBackgroundColor ()) However, that method does not exist

I also tried canvas.backgroundColor , but it returns an empty string .

Despite my efforts, the color of the canvas background does not return, does anyone have to do this?

The HTML canvas is transparent by default.

When an empty canvas is pulled, then the background of the body will be visible.

To set the background color in the fabric JS, do this:

  canvas. Background color = 'red';   

Unless you have already set the background color, you can retrieve it like this:

  var bkColor = canvas. BackgroundColor; Alternatively, you can set the background in CSS because the canvas making Fabelajs will take you the CSS of the canvas element of the first supply:  
  # MyCanvas {background-color: "sky blue"; }    

No comments:

Post a Comment