Fabric.js: Rotate the background image

Created on 6 Dec 2013  Â·  5Comments  Â·  Source: fabricjs/fabric.js

Any way to rotate the canvas background image?

Most helpful comment

for anyone seeing this issue in 2020, it's called rotate now

canvas.backgroundImage.rotate(45);
canvas.renderAll();

All 5 comments

Please ask questions like this at Fabric's google group or StackOverflow.
https://github.com/kangax/fabric.js/blob/master/CONTRIBUTING.md#questions

Yes you can:

canvas.backgroundImage.setAngle(45);
canvas.renderAll();

 Thanks for your help.
I try it , but still has a error.
Uncaught TypeError: Object has no method 'setAngle'

On Friday, December 6, 2013 1:44 AM, Stefan Kienzle [email protected] wrote:

Please ask questions like this at Fabric's google group or StackOverflow.
https://github.com/kangax/fabric.js/blob/master/CONTRIBUTING.md#questions
Yes you can:
canvas.backgroundImage.setAngle(45); canvas.renderAll();
—
Reply to this email directly or view it on GitHub.

Please update to version 1.4. Then it should work.

for anyone seeing this issue in 2020, it's called rotate now

canvas.backgroundImage.rotate(45);
canvas.renderAll();

In my case, the background image is rotated, but the width and height is wrong it seems. I think the rotation is based on center position and once it is rotated to 90 we have to reposition it to center. Any idea?

Was this page helpful?
0 / 5 - 0 ratings