2015-03-03 25 views
0

我使用下面的代碼爲動能textPath轉換爲圖像將動能轉換textPath圖像

 var simpleText = new Kinetic.TextPath({ 
     x: 400, 
     y: 0, 
     fill: '#333', 
     fontSize: '24', 
     fontFamily: 'Arial', 
     text: 'Lorem Ipsum Lorem Ipsum ', 
     data: 'M70,70 A50,50 0 1,1 69,70' 
     }); 

     var textImgSrc = simpleText.toDataURL(); // base64 image of text 
     var textImgObj = new Image(); 
     textImgObj.src = textImgSrc; 
     console.log(textImgObj.src); 

但在控制檯它給了我沒有其他的圖像「數據:」,

回答

1

必須設置位置和您TextPath大小屬性:

var textImgSrc = simpleText.toDataURL({ 
    x : 0, 
    y : 50, 
    width : 130, 
    height : 130 
}); // base64 image of text 

http://jsbin.com/newuro/1/edit?html,js,output

+0

你能PLE看看這也是: http://stackoverflow.com/questions/28735789/convert-line-to-image-in-kinetic-js-v5-0-0。提前致謝 – saad 2015-03-05 05:41:12