title: Using KineticJs to update and rescale a drawing
body: <p>I am having an issue trying to update a drawing that uses a number of different drawing objects.  The drawing is similar to an AutoCad drawing and is measured in mm so the scale is already being calculated in order to get the drawing to fit on the stage.  When this is calculated the scale is set to one.</p>
  
  <p>I have the drawing objects (lines, circles, arcs, etc.) stored in an array.  I am trying to update the drawing andd rescale it without clearing the stage and doing a full redraw to improve performance.</p>
  
  <p>What I am trying to do is to increment the length of the drawing.  The drawing has a cut point so the objects to the right of the cut point will move by the increment value and any lines that span the cut point will increase in length.  This change will require an update to the scale initially calculated to get the drawing to appear on the stage.</p>
  
  <p>There are 2 Fiddles that I have set up to demonstrate the problem.  The first (<a href="http://jsfiddle.net/tctruckscience/3HxuP/4/" rel="nofollow">http://jsfiddle.net/tctruckscience/3HxuP/4/</a>) shows what I am currently doing.  The problem is that drawing will scale but it will start to move away from the right hand side of the screen.  </p>
  
  <pre><code>originalRectWidth = 2600;
  rectWidth = rectWidth + 20;    
  scaleValue = originalRectWidth / rectWidth;
  
  oldRectWidth = rect.getWidth();
  newPixelsPerScaleUnit = 260 / rectWidth;
  
  newRectScaled = rectWidth * newPixelsPerScaleUnit;
  drawingGroup.setWidth(newRectScaled);
  rect.setWidth(newRectScaled);
  drawingGroup.scaleBy(scaleValue);
  </code></pre>
  
  <p>Also, if I make a lot of increments and then make a large decrement using a text box there is an issue in the redraw.  It that lines are not decremented correctly.  I think it is an issue with the scaling.  When I resize the page, which calls a refresh of the drawing objects from the array in which they are held, the drawing proportions are correct</p>
  
  <p>The second Fiddle (<a href="http://jsfiddle.net/tctruckscience/rsEyA/15" rel="nofollow">http://jsfiddle.net/tctruckscience/rsEyA/15</a>) shows how I would like the drawing to behave.</p>
  
  <pre><code>oldWidth = drawingGroup.getWidth();
  newWidth = drawingGroup.getWidth() + 20;
  scaleValue = originalWidth / newWidth;
  </code></pre>
  
  <p>Is there a way to do this?</p>