0

How to make canvas text object to slant right and slant left using Fabric js ? Screen shots for this.

For slant right

And for slant left

Any Help Greatly Appreciated.

Azam
  • 1
  • 3

1 Answers1

1

Depending on fabric js version you are using, you may have skew support out of the box: (1.6.0-rc+)

var canvas = new fabric.Canvas('canvas');

var textLeft = new fabric.Text('13-arid-365',{
    left:100,
    top: 25,
    skewX: 45    
});
canvas.add(textLeft);

var textRight = new fabric.Text('13-arid-365',{
    left: 100,
    top: 75,
    skewX: -45    
});
canvas.add(textRight);
<script src='http://www.deltalink.it/andreab/fabric/fabric.js'></script>
<canvas id="canvas" width=300 height=300></canvas>

Difference between transformMatrix and skew feature is that skew is better supported and allows you to have a coherent bounding box, while transform matrix does not.

AndreaBogazzi
  • 14,323
  • 3
  • 38
  • 63