IText对象的Fabric.js背景错过了boundingbox

时间:2013-12-05 15:01:23

标签: javascript fabricjs bounding-box

在Fabric.js中创建IText对象时遇到一些问题。问题是IText的背景与其边界框不匹配。基本上我所做的就是这个,请参阅下面的JSFiddle演示。

    //Regular text, works
    text1 = new fabric.Text('Regular text', {
        fill: 'red',
        left: 100,
        top: 100,
        backgroundColor: 'rgba(0,255,0, 0.65)'
    });

    //IText misses
    text2 = new fabric.IText('Interactive text \nbackground misses \nboundingbox', {
        fill: 'blue',
        left: 100,
        top: 200,
        backgroundColor: 'rgba(0,255,0, 0.65)'
    });

    canvas.add(text1);
    canvas.add(text2);
    text1.setCoords();
    text2.setCoords();
    canvas.calcOffset();
    canvas.renderAll();

JSFiddle

0 个答案:

没有答案