code: function fitRect(x, y, w, h) {
          
          // Calculate bounds
          var opBoundX = w + x;
          var opBoundY = h + y;
          
          // Determine max width
          var resizeWidth;
          if (opBoundX > layer.width)
              resizeWidth = opBoundX;
          else
              resizeWidth = layer.width;
  
          // Determine max height
          var resizeHeight;
          if (opBoundY > layer.height)
              resizeHeight = opBoundY;
          else
              resizeHeight = layer.height;
  
          // Resize if necessary
          layer.resize(resizeWidth, resizeHeight);
  
      }
docs: Given the X and Y coordinates of the upper-left corner of a rectangle
  and the rectangle's width and height, resize the backing canvas element
  as necessary to ensure that the rectangle fits within the canvas
  element's coordinate space. This function will only make the canvas
  larger. If the rectangle already fits within the canvas element's
  coordinate space, the canvas is left unchanged.
  
  @private
  @param {Number} x The X coordinate of the upper-left corner of the
  rectangle to fit.
  @param {Number} y The Y coordinate of the upper-left corner of the
  rectangle to fit.
  @param {Number} w The width of the the rectangle to fit.
  @param {Number} h The height of the the rectangle to fit.