title: Using transformation matrix in KineticJS
body: <p>I have a body simulated with Box2Dweb and an image attached to the body. I want to take the body transformation matrix and apply the transformation to the image (draw the image with the transformation), so that its position and orientation (relative) on the screen matches that of the body. I can't find a function for using with a transformation matrix in KineticJS. There are separate functions for moving and rotating, and there's a <code>Kinetic.Transform</code> class which holds some 'matrix' inside, but I have no idea what to do with it then. There's also a <code>_setTransform</code> function somewhere, but again, no idea how to use it (and does the underscore suggest that I must  not call it directly or what?).</p>
  
  <p>I used this code to draw images over bodies in plain Javascript:</p>
  
  <pre><code>function drawImageOverBody(context, body, image, scale)
  {
      context.save();
      var pos = body.GetPosition();
      var center = [scale*pos.x, scale*pos.y];
      var R = body.GetTransform().R;
      context.translate(center[0], center[1]);
      context.transform(R.col1.x, R.col1.y, R.col2.x, R.col2.y, 0, 0);
      context.translate(-center[0], -center[1]);
      context.drawImage(image, center[0] - image.width/2.0, center[1] - image.height/2.0);
      context.restore();
  }
  </code></pre>
  
  <p>How do I do the same with KineticJS?</p>
  
  <p>EDIT: apparently, the only transformations I can get from Box2d are translation and rotation, which I can get by calling <code>GetPosition()</code> and <code>GetAngle()</code> on the Box2d body, then apply to a KineticJS image with <code>setX(), setY()</code> and <code>setRotation()</code>. So I don't really need the transformation in matrix form here. Still, curious.</p>