code: function positionRectangleInsideAnother(pos, a, b) {
      var aWidth = a.x2 - a.x1;
      var aHeight = a.y2 - a.y1;
  
      var bWidth = b.x2 - b.x1;
      var bHeight = b.y2 - b.y1;
  
      if (bHeight <= aHeight || bWidth <= aWidth) {
          return a;
      }
  
      var adjusted;
      switch (pos) {
          case "center":
              return {
                  x1: a.x1 + (bWidth - aWidth)/2,
                  x2: a.x2 + (bWidth - aWidth)/2,
                  y1: a.y1 + (bHeight - aHeight)/2,
                  y2: a.y2 + (bHeight - aHeight)/2
              };
          case "ne":
              return {
                  x1: a.x1 + (bWidth - aWidth),
                  x2: a.x2 + (bWidth - aWidth),
                  y1: a.y1,
                  y2: a.y2
              };
          case "se":
              return {
                  x1: a.x1 + (bWidth - aWidth),
                  x2: a.x2 + (bWidth - aWidth),
                  y1: a.y1 + (bHeight - aHeight),
                  y2: a.y2 + (bHeight - aHeight)
              };
          case "sw":
              return {
                  x1: a.x1,
                  x2: a.x2,
                  y1: a.y1 + (bHeight - aHeight),
                  y2: a.y2 + (bHeight - aHeight)
              };
          case "nw":
          default:
              return a;
      }
  
      return {}
  }
docs: center rectangle a inside rectangle b assumption: rectangles have the form {x1: 0, y1: 0, x2: 0, y2: 0} assumption: b is larger than a such that a fits completely inside b