问题
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
回答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