Given the list of coordinates (x,y), this procedure computes
    the smallest rectangle that covers all the points.
961423
def _compute_bounding_box(points):
    """"""
    (xmin, ymin, xmax, ymax) = (999999, 999999, -999999, -999999)
    for p in points:
        xmin = min(xmin, p[0])
        xmax = max(xmax, p[0])
        ymin = min(ymin, p[1])
        ymax = max(ymax, p[1])
    return (xmin, ymin, xmax, ymax)
975207
def snapPointToCanvas(self, x, y):
        
        if x < 0 or x > self.pixmap.width() or y < 0 or y > self.pixmap.height():
            x = max(x, 0)
            y = max(y, 0)
            x = min(x, self.pixmap.width())
            y = min(y, self.pixmap.height())
            return x, y, True

        return x, y, False
1373736
def bound(self, p1, p2=None):
    """"""
    r = Rect(p1, p2)
    return Point(min(max(self.x, r.l), r.r), min(max(self.y, r.t), r.b))
36445
def get_minimum_size(self, data):
        """"""
        size = self.element.get_minimum_size(data)
        return datatypes.Point(
            max(size.x, self.min_width),
            max(size.y, self.min_height)
            )
1265804
public function rectangle($x, $y, $width, $height, $context, $x, $y, $width, $height)
    {
    }
516229
private int[] rect() {
		 if(np==0)return null;
		int xMin = x[0], yMin=y[0], xMax=x[0],yMax=y[0];

		 for(int i=1;i<np;i++) {
			 if(x[i]<xMin)xMin=x[i];
			 else if(x[i]>xMax)xMax=x[i];
			 if(y[i]<yMin)yMin=y[i];
			 else if(y[i]>yMax)yMax=y[i];
		 }

		 return new int[] { xMin, yMin, xMax-xMin, yMax-yMin };
	}
1334387
def rectangle(self, x, y, width, height, corner_radius = 0):
        """"""
        if corner_radius <= 0:
            self._add_instruction("rectangle", x, y, width, height)
            return

        # convert into 4 border and  make sure that w + h are larger than 2 * corner_radius
        if isinstance(corner_radius, (int, float)):
            corner_radius = [corner_radius] * 4
        corner_radius = [min(r, min(width, height) / 2) for r in corner_radius]

        x2, y2 = x + width, y + height
        self._rounded_rectangle(x, y, x2, y2, corner_radius)
870696
def handle_sub_rectangles(self, images, sub_rectangles):
        
        image_info = [im.info for im in images]
        if isinstance(sub_rectangles, (tuple, list)):
            # xy given directly

            # Check xy
            xy = sub_rectangles
            if xy is None:
                xy = (0, 0)
            if hasattr(xy, '__len__'):
                if len(xy) == len(images):
                    xy = [xxyy for xxyy in xy]
                else:
                    raise ValueError("len(xy) doesn't match amount of images.")
            else:
                xy = [xy for im in images]
            xy[0] = (0, 0)

        else:
            # Calculate xy using some basic image processing

            # Check Numpy
            if np is None:
                raise RuntimeError("Need Numpy to use auto-sub_rectangles.")

            # First make numpy arrays if required
            for i in range(len(images)):
                im = images[i]
                if isinstance(im, Image.Image):
                    tmp = im.convert()  # Make without palette
                    a = np.asarray(tmp)
                    if len(a.shape) == 0:
                        raise MemoryError("Too little memory to convert PIL image to array")
                    images[i] = a

            # Determine the sub rectangles
            images, xy = self.get_sub_rectangles(images)

        # Done
        return images, xy, image_info
1336837
def rectangle(self, rect, attr=None, fill=u' '):
        '''
        x0, y0, x1, y1 = rect
        n = DWORD(0)
        if attr is None:
            attr = self.attr
        for y in range(y0, y1):
            pos = self.fixcoord(x0, y)
            self.FillConsoleOutputAttribute(self.hout, attr, x1 - x0, 
                                            pos, byref(n))
            self.FillConsoleOutputCharacterW(self.hout, ord(fill[0]), x1 - x0,
                                             pos, byref(n))
468506
def _get_smallest_dimensions(self, data):
        """"""
        min_width = 0
        min_height = 0
        for element in self.elements:
            if not element: continue
            size = element.get_minimum_size(data)
            min_width = max(min_width, size.x)
            min_height = max(min_height, size.y)
        return datatypes.Point(min_width, min_height)
1065875
def coords
      x, y, z = Array.new, Array.new, Array.new
      @coordinates.each do |coord|
        x << coord.x
        y << coord.y
        z << coord.z
      end
      return x, y, z
    end
651848
private void calculateMinimapBounds() {
        float ratioX = Constants.MINIMAP_MAX_SIZE / optimalPageWidth;
        float ratioY = Constants.MINIMAP_MAX_SIZE / optimalPageHeight;
        float ratio = Math.min(ratioX, ratioY);
        float minimapWidth = optimalPageWidth * ratio;
        float minimapHeight = optimalPageHeight * ratio;
        minimapBounds = new RectF(getWidth() - 5 - minimapWidth, 5, getWidth() - 5, 5 + minimapHeight);
        calculateMinimapAreaBounds();
    }
1023698
def get_rectangle(self):
        
        rec = [self.pos[0], self.pos[1]]*2
        for age in self.nodes:
            for node in age:
                # Check max/min for x/y coords
                for i in range(2):
                    if rec[0+i] > node.pos[i]:
                        rec[0+i] = node.pos[i]
                    elif rec[2+i] < node.pos[i]:
                        rec[2+i] = node.pos[i]
        return tuple(rec)
989464
def union_rectangles(R):
    
    if R == []:
        return 0
    X = []
    Y = []
    for j in range(len(R)):
        (x1, y1, x2, y2) = R[j]
        assert x1 <= x2 and y1 <= y2
        X.append(x1)
        X.append(x2)
        Y.append((y1, +1, j))    # generate events
        Y.append((y2, -1, j))
    X.sort()
    Y.sort()
    X2i = {X[i]: i for i in range(len(X))}
    L = [X[i + 1] - X[i] for i in range(len(X) - 1)]
    C = Cover_query(L)
    area = 0
    last = 0
    for (y, delta, j) in Y:
        area += (y - last) * C.cover()
        last = y
        (x1, y1, x2, y2) = R[j]
        i = X2i[x1]
        k = X2i[x2]
        C.change(i, k, delta)
    return area
1336133
def rectangles_from_histogram(H):
    
    best = (float('-inf'), 0, 0, 0)
    S = []
    H2 = H + [float('-inf')]  # extra element to empty the queue
    for right in range(len(H2)):
        x = H2[right]
        left = right
        while len(S) > 0 and S[-1][1] >= x:
            left, height = S.pop()
            # first element is area of candidate
            rect = (height * (right - left), left, height, right)
            if rect > best:
                best = rect
        S.append((left, x))
    return best
1247122
def min(self):
        
        results = [x.ufuncs.min() for x in self.elem]
        return np.min(results)
1182466
List<Integer> convexhull(List<Float> pts) {
        int npts = pts.size() / 3;
        List<Integer> out = new ArrayList<>();
        // Find lower-leftmost point.
        int hull = 0;
        for (int i = 1; i < npts; ++i) {
            float[] a = new float[] { pts.get(i * 3), pts.get(i * 3 + 1), pts.get(i * 3 + 2) };
            float[] b = new float[] { pts.get(hull * 3), pts.get(hull * 3 + 1), pts.get(hull * 3 + 2) };
            if (cmppt(a, b)) {
                hull = i;
            }
        }
        // Gift wrap hull.
        int endpt = 0;
        do {
            out.add(hull);
            endpt = 0;
            for (int j = 1; j < npts; ++j) {
                float[] a = new float[] { pts.get(hull * 3), pts.get(hull * 3 + 1), pts.get(hull * 3 + 2) };
                float[] b = new float[] { pts.get(endpt * 3), pts.get(endpt * 3 + 1), pts.get(endpt * 3 + 2) };
                float[] c = new float[] { pts.get(j * 3), pts.get(j * 3 + 1), pts.get(j * 3 + 2) };
                if (hull == endpt || left(a, b, c)) {
                    endpt = j;
                }
            }
            hull = endpt;
        } while (endpt != out.get(0));

        return out;
    }