115                                    {
  116        u16 min_x = 0;
  117        bool min_x_set = false;
  118        u16 min_y = 0;
  119        bool min_y_set = false;
  120        u16 max_x = 0;
  121        bool max_x_set = false;
  122        u16 max_y = 0;
  123        bool max_y_set = false;
  125            const vec2<u16> &pt = it.first;
  126            if (!min_x_set || pt.x < min_x) {
  127                min_x = pt.x;
  128                min_x_set = true;
  129            }
  130            if (!min_y_set || pt.y < min_y) {
  131                min_y = pt.y;
  132                min_y_set = true;
  133            }
  134            if (!max_x_set || pt.x > max_x) {
  135                max_x = pt.x;
  136                max_x_set = true;
  137            }
  138            if (!max_y_set || pt.y > max_y) {
  139                max_y = pt.y;
  140                max_y_set = true;
  141            }
  142        }
  143        return rect<u16>(min_x, min_y, max_x + 1, max_y + 1);
  144    }