Fabric JS:如何转换Fabric图像

时间:2013-01-23 17:28:37

标签: html5 canvas javascript fabricjs

如何使用Fabric JS在画布内左右倾斜布料图像? 我需要它按照显示器的显示方式,所以我可以像它一样粘贴它 正在屏幕上显示

enter image description here

1 个答案:

答案 0 :(得分:0)

请浏览this链接。您可以将变换和倾斜设置为Fiddle



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



fabric.Image.fromURL("https://www.google.co.in/images/srpr/logo11w.png", function(img) {
    img.set({transformMatrix: [1, .30, 0, 1, 0, 0],width:200,height:50,top:100,left:150});
    img.setCoords();
    canvas.add(img);
    
    canvas.renderAll();
  })

body {
    background-color: ivory;
    padding:30px;
}
canvas {
    border: 1px solid red;
}

<h3>FabricJS: using transformMatrix to skew-Y</h3>

<canvas id="canvas" width="300" height="300"></canvas>
&#13;
&#13;
&#13;