KineticJS使文本垂直对齐

KineticJS make text vertically aligned

本文关键字:对齐 垂直 文本 KineticJS      更新时间:2023-09-26

我正在尝试用KineticJS绘制一些东西。我想使文本垂直对齐,但没有找到使其按我想要的方式呈现的属性。

我尝试了"对齐","垂直对齐",但这些都不能满足我的要求。

我希望文本显示如下:

TEXT

但它不起作用,并且总是像这样显示:

文本
我想

最好的办法是单独创建文本并将其添加到组中,也许是这样的函数:

function(text){
   group = new Kinetic.Group();
   letters=text.split("");
   for(foo in letters){
    window['text' + foo] = new Kinetic.Text({config}) // use the foo incrementaly to change the Y axis of the text and pass letters[foo] as text argument
    group.add(window['text' + foo]);

   }
   layer.add(group);
   layer.draw();
}

它可以写得更优雅(不使用窗口对象,但这是我所知道的创建 dinamic var 的唯一方法),但这应该可以完成工作(我认为);