Note that there are some explanatory texts on larger screens.

plurals
  1. POKineticJS toImage Width and Height issue
    primarykey
    data
    text
    <p>Im running into this strange problem..! I've a kineticJS text element and I'm converting it into image.. Here is the Code</p> <pre><code>var simpleText = new Kinetic.Text({ x: 50, y: 50, text: $("#text").val(), fontSize: $("#fontSize").val(), fontFamily: $("#fontName").val(), fill: $("#fontColor").val(), }); var twidth = simpleText.getWidth(); var theight = simpleText.getHeight(); simpleText.toImage({ width:twidth, height:theight, callback: function(img){ var textImg = new Kinetic.Image({ image: img, x: 0, y: 0, width: twidth, height: theight, name: 'image', stroke: 'red', strokeWidth: 2, strokeEnabled: false }); addElement(textImg, textImg.getWidth(), textImg.getHeight()); } }); </code></pre> <p>So the problem exist here..!</p> <pre><code>var twidth = simpleText.getWidth(); var theight = simpleText.getHeight(); </code></pre> <p>If I just put the width and height in numeric form, everything works fine and text is converted, something like this</p> <pre><code>var twidth = 500; var theight = 100; </code></pre> <p>But if I use simpleText.getWidth() and simpleText.getHeight(), nothing happens, the image is created but it doesn't have that TEXT. As I saw in documentation, width and height are optional params for toImage(), so I removed now, but now its show this error..</p> <blockquote> <p>Uncaught TypeError: Cannot read property 'bufferCanvas' of undefined kinetic.js:28 Kinetic.Node.toDataURL kinetic.js:28 Kinetic.Node.toImage kinetic.js:28 add_text canvas.js:83 (anonymous function) canvas.js:352 f.event.dispatch jquery.min.js:3 h.handle.i</p> </blockquote> <p>any idea whats wrong with my code?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload