0

我已经更新到 4.4。我正在像这样初始化一个 Text 对象:

var droppableText = new Kinetic.Text({
            x : posX,
            y : posY,
            name : field,
            stroke : '#555',
            strokeWidth : 2,
            fill : '#ddd',
            text : text,
            fontSize : fontSize,
            fontFamily : 'Calibri',
            textFill : '#555',
            width : width,
            height : height,
            padding : padding,
            align : 'center',
            fontStyle : 'italic',
            shadow : {
                color : 'black',
                blur : 10,
                offset : [10, 10],
                opacity : 0.2
            },
            cornerRadius : 10
        });

似乎 X、Y 和文本位置正确,但没有像以前那样的背景或边框。这在我使用 4.0 版本之前有效,我刚刚更新到 4.4,现在它不起作用。想法?

4

1 回答 1

0

是的,从 4.3.0 版开始,边框矩形就消失了

https://github.com/ericdrowell/KineticJS/wiki/Change-Log

Big changes to Kinetic.Text shape. 

Rectangle component has been removed to simplify the API. textFill is now fill, textStroke is now stroke, textStrokeWidth is now strokeWidth, and textShadow is now shadow. 

If you want to have a rectangle behind the text, you need to group the text with a Kinetic.Rect shape. Text fontSize units are now in pixels (used to be in points). The lineHeight attr is now defaulted to 1 (used to be defaulted to 1.2).

cornerRadius attr moved to rect shape
于 2013-04-01T19:14:09.117 回答