saad
saad

Reputation: 1364

Convert Kinetic textPath to image

I am using following code to convert kinetic textPath to image

        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);

but in console it gives me no image else "data:,"

Upvotes: 0

Views: 38

Answers (1)

lavrton
lavrton

Reputation: 20288

You have to set position and size properties for your 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

Upvotes: 1

Related Questions