anchor.diff:              canvas.add(rect1);
   
               rect2 = new fabric.Rect({
  -                top : canvasHeight - (textHeight / 2.0),
  -                left : canvasWidth / 2.0,
  +                top : canvas.getHeight() - (textHeight / 2.0),
  +                left : canvas.getWidth() / 2.0,
                   width : textWidth,
                   height : textHeight,
                   fill: 'red'
  
positive.code:                 if (leftSide < 0) {
                      target.setLeft(halfWidth);
                  }
                  if (rightSide > canvasWidth) {
                      target.setLeft(canvasWidth - halfWidth);
                  }
                  if (topSide < 0) {
                      target.setTop(halfHeight);
                  }
                  if (bottomSide > canvasHeight) {
                    target.setTop(canvasHeight - halfHeight);
                  }
              });
  
  
negative.code:     });
  }
  
  // scale width and height so that neither is larger than maxSide
  function resizeToFit(width, height, maxSide) {
      "use strict";
  
      var result = {
              width : width,
              height : height
          };
  
      if (width > maxSide) {
          result.width = maxSide;
          result.height = height * (maxSide / width);
      }
  
      if (result.height > maxSide) {
          result.width = result.width * (maxSide / result.height);
          result.height = maxSide;
      }
  
      return result;
  }
  
  function positionText() {
      "use strict";
  
      var imageUrl = $('#u').val(),
          canvas;
  
      if (imageUrl.length > 0) {
          $('#positionTable').show();
  