docs: def limit_pos(p, se_pos, nw_pos):
          """
          Limits position p to stay inside containing state
          :param p: Position to limit
          :param se_pos: Bottom/Right boundary
          :param nw_pos: Top/Left boundary
          :return:
          """
          if p > se_pos:
              _update(p, se_pos)
          elif p < nw_pos:
              _update(p, nw_pos)