1

我想制作沿织物弯曲的可编辑文本。路径为波纹管预期图像。
在此处输入图像描述


这是我的代码:
我创建了一个弯曲的 fabric.Path 和一个 fabric.TextBox,但我不知道如何沿着该路径弯曲文本。请帮我解决这个问题。

var canvasObject = document.getElementById("editorCanvas");
// set canvas equal size with div
$(canvasObject).width($("#canvasContainer").width());
$(canvasObject).height($("#canvasContainer").height());

var canvas = new fabric.Canvas('editorCanvas', {
  selectionLineWidth: 2,
  width: $("#canvasContainer").width(),
  height: $("#canvasContainer").height()
});

var Path_0_1 = new fabric.Path('M127.91,99.29c32.16,10.73,53.41,7.33,67.81,0 c34.07-17.34,41.99-62.82,60.98-60.98c8.19,0.79,14.11,9.98,17.91,17.91', {
  fill : null,
  stroke: '#000000',
});
canvas.add(Path_0_1);

var curvedText = new fabric.IText("Anh Minh", {
  left: 50, 
  top: 50, 
  width: 200, 
  fontSize: 24, 
  fontFamily: 'Times New Roman', 
  fontWeight: 'normal', 
  textAlign: 'center',
  lineHeight: 1,
  fill: "#404041",
});
canvas.add(curvedText);
#canvasContainer {
  width: 100%;
  height: 500px;
}
<script src="https://code.jquery.com/jquery-3.3.1.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fabric.js/2.4.3/fabric.js"></script>
  
<div id="canvasContainer">
  <canvas id="editorCanvas"></canvas>
</div>



补充信息:
经过几个小时的谷歌搜索,我看到了一个有趣的Konva.TextPath,我想知道我们是否可以在 Fabric.js 中制作与 Konva.TextPath 相同的对象?

谢谢!

4

0 回答 0