本文介绍了Fabric JS:如何转换织物图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用Fabric JS在Canvas内向左或向右缩放织物图像?我需要它遵循此监视器的显示方式,因此我可以像粘贴它一样粘贴它在屏幕上显示

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 isbeing displayed on the screen

推荐答案

请通过链接.您可以将transform和skew设置为小提琴

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>

这篇关于Fabric JS:如何转换织物图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-16 21:55
查看更多