Fabric JS: How to Transform Fabric Image

僤鯓⒐⒋嵵緔 提交于 2021-02-19 04:41:06

问题


How Can I skew and Scale left or right a Fabric Image inside a Canvas using Fabric JS? I need it to follow the way this monitor is being displayed so I can paste it like it is being displayed on the screen

enter image description here


回答1:


Please go through this link. You can set transform and skew as 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>


来源:https://stackoverflow.com/questions/14485716/fabric-js-how-to-transform-fabric-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!