Rough computation of the smaller {@link RectL} that contains a rotated {@link RectL}
Emulating {@link Canvas#getClipBounds(Rect)} after a canvas rotation
The code is supposed to be exactly the same as the Rect version, except for int/long
@since 6.0.2
974500
public static RectL getBounds(final RectL pIn,
                                  final long pCenterX, final long pCenterY, final double pDegrees,
                                  final RectL pReuse) {
        final RectL out = pReuse != null ? pReuse : new RectL();
        if (pDegrees == 0) { // optimization
            out.top = pIn.top;
            out.left = pIn.left;
            out.bottom = pIn.bottom;
            out.right = pIn.right;
            return out;
        }
        final double radians = pDegrees * Math.PI / 180.;
        final double cos = Math.cos(radians);
        final double sin = Math.sin(radians);
        long inputX;
        long inputY;
        long outputX;
        long outputY;
        inputX = pIn.left; // corner 1
        inputY = pIn.top;
        outputX = getRotatedX(inputX, inputY, pCenterX, pCenterY, cos, sin);
        outputY = getRotatedY(inputX, inputY, pCenterX, pCenterY, cos, sin);
        out.top = out.bottom = outputY;
        out.left = out.right = outputX;
        inputX = pIn.right; // corner 2
        inputY = pIn.top;
        outputX = getRotatedX(inputX, inputY, pCenterX, pCenterY, cos, sin);
        outputY = getRotatedY(inputX, inputY, pCenterX, pCenterY, cos, sin);
        if (out.top > outputY) {
            out.top = outputY;
        }
        if (out.bottom < outputY) {
            out.bottom = outputY;
        }
        if (out.left > outputX) {
            out.left = outputX;
        }
        if (out.right < outputX) {
            out.right = outputX;
        }
        inputX = pIn.right; // corner 3
        inputY = pIn.bottom;
        outputX = getRotatedX(inputX, inputY, pCenterX, pCenterY, cos, sin);
        outputY = getRotatedY(inputX, inputY, pCenterX, pCenterY, cos, sin);
        if (out.top > outputY) {
            out.top = outputY;
        }
        if (out.bottom < outputY) {
            out.bottom = outputY;
        }
        if (out.left > outputX) {
            out.left = outputX;
        }
        if (out.right < outputX) {
            out.right = outputX;
        }
        inputX = pIn.left; // corner 4
        inputY = pIn.bottom;
        outputX = getRotatedX(inputX, inputY, pCenterX, pCenterY, cos, sin);
        outputY = getRotatedY(inputX, inputY, pCenterX, pCenterY, cos, sin);
        if (out.top > outputY) {
            out.top = outputY;
        }
        if (out.bottom < outputY) {
            out.bottom = outputY;
        }
        if (out.left > outputX) {
            out.left = outputX;
        }
        if (out.right < outputX) {
            out.right = outputX;
        }
        return out;
    }
1167987
public Rect getScreenRect(final Rect reuse) {
		final Rect out = getIntrinsicScreenRect(reuse);
		if (this.getMapOrientation() != 0 && this.getMapOrientation() != 180) {
			GeometryMath.getBoundingBoxForRotatatedRectangle(out, out.centerX(), out.centerY(),
					this.getMapOrientation(), out);
		}
		return out;
	}
1338032
protected void computeTransformedBounds ()
    {
        int w = _base.getWidth();
        int h = _base.getHeight();
        Point[] points = new Point[] {
            new Point(0, 0), new Point(w, 0), new Point(0, h), new Point(w, h) };
        _transform.transform(points, 0, points, 0, 4);
        int minX, minY, maxX, maxY;
        minX = minY = Integer.MAX_VALUE;
        maxX = maxY = Integer.MIN_VALUE;
        for (int ii=0; ii < 4; ii++) {
            minX = Math.min(minX, points[ii].x);
            maxX = Math.max(maxX, points[ii].x);
            minY = Math.min(minY, points[ii].y);
            maxY = Math.max(maxY, points[ii].y);
        }

        _bounds = new Rectangle(minX, minY, maxX - minX, maxY - minY);
    }
1119568
function () {
        // Rect before any transform
        var rawRect = this.getBoundingRect();
        var cx = rawRect.x + rawRect.width / 2;
        var cy = rawRect.y + rawRect.height / 2;

        return [cx, cy];
    }
1192461
function _getBoundingRect (rects) {
  var bounds = {
    left: Number.POSITIVE_INFINITY,
    top: Number.POSITIVE_INFINITY,
    right: Number.NEGATIVE_INFINITY,
    bottom: Number.NEGATIVE_INFINITY,
    width: Number.NaN,
    height: Number.NaN
  }

  forEach(rects, function (rect) {
    if (rect.left < bounds.left) {
      bounds.left = rect.left
    }
    if (rect.top < bounds.top) {
      bounds.top = rect.top
    }
    if (rect.left + rect.width > bounds.right) {
      bounds.right = rect.left + rect.width
    }
    if (rect.top + rect.height > bounds.bottom) {
      bounds.bottom = rect.top + rect.height
    }
  })
  bounds.width = bounds.right - bounds.left
  bounds.height = bounds.bottom - bounds.top
  return bounds
}
711817
function(rect, opt) {

        rect = g.rect(rect);
        opt = joint.util.defaults(opt || {}, { strict: false });

        var method = opt.strict ? 'containsRect' : 'intersect';

        return this.getElements().filter(function(el) {
            return rect[method](el.getBBox());
        });
    }
233607
function getIntersectionRect (rect1, rect2) {
  const intersectRect = {
    topLeft: {},
    bottomRight: {}
  };

  if (!doesIntersect(rect1, rect2)) {
    return;
  }

  const rect1Points = rectToPoints(rect1);
  const rect2Points = rectToPoints(rect2);

  if (rect1.width >= 0) {
    if (rect2.width >= 0) {
      intersectRect.topLeft.x = Math.max(rect1Points.topLeft.x, rect2Points.topLeft.x);
      intersectRect.bottomRight.x = Math.min(rect1Points.bottomRight.x, rect2Points.bottomRight.x);
    } else {
      intersectRect.topLeft.x = Math.max(rect1Points.topLeft.x, rect2Points.bottomRight.x);
      intersectRect.bottomRight.x = Math.min(rect1Points.bottomRight.x, rect2Points.topLeft.x);
    }
  } else if (rect2.width >= 0) {
    intersectRect.topLeft.x = Math.min(rect1Points.topLeft.x, rect2Points.bottomRight.x);
    intersectRect.bottomRight.x = Math.max(rect1Points.bottomRight.x, rect2Points.topLeft.x);
  } else {
    intersectRect.topLeft.x = Math.min(rect1Points.topLeft.x, rect2Points.topLeft.x);
    intersectRect.bottomRight.x = Math.max(rect1Points.bottomRight.x, rect2Points.bottomRight.x);
  }

  if (rect1.height >= 0) {
    if (rect2.height >= 0) {
      intersectRect.topLeft.y = Math.max(rect1Points.topLeft.y, rect2Points.topLeft.y);
      intersectRect.bottomRight.y = Math.min(rect1Points.bottomRight.y, rect2Points.bottomRight.y);
    } else {
      intersectRect.topLeft.y = Math.max(rect1Points.topLeft.y, rect2Points.bottomRight.y);
      intersectRect.bottomRight.y = Math.min(rect1Points.bottomRight.y, rect2Points.topLeft.y);
    }
  } else if (rect2.height >= 0) {
    intersectRect.topLeft.y = Math.min(rect1Points.topLeft.y, rect2Points.bottomRight.y);
    intersectRect.bottomRight.y = Math.max(rect1Points.bottomRight.y, rect2Points.topLeft.y);
  } else {
    intersectRect.topLeft.y = Math.min(rect1Points.topLeft.y, rect2Points.topLeft.y);
    intersectRect.bottomRight.y = Math.max(rect1Points.bottomRight.y, rect2Points.bottomRight.y);
  }

  // Returns top-left and bottom-right points of intersected rectangle
  return intersectRect;

}
189000
public Rectangle getTextBounds() {
        List<TextElement> texts = this.getText();
        if (!texts.isEmpty()) {
            return Utils.bounds(texts);
        }
        else {
            return new Rectangle();
        }
        
    }
885733
private Rectangle getHDropLineRect(JTable.DropLocation loc) {
        if (!loc.isInsertRow()) {
            return null;
        }

        int row = loc.getRow();
        int col = loc.getColumn();

        if (col >= table.getColumnCount()) {
            col--;
        }

        Rectangle rect = table.getCellRect(row, col, true);

        if (row >= table.getRowCount()) {
            row--;
            Rectangle prevRect = table.getCellRect(row, col, true);

            rect.y = prevRect.y + prevRect.height;
        }

        if (rect.y == 0) {
            rect.y = -1;
        } else {
            rect.y -= 2;
        }

        rect.height = 3;

        return rect;
    }
501507
function(current) {
        var bounds = this.getBoundsNoRotate(current);
        if (this._clip) {
            var worldWidth = current ?
                this._worldWidthCurrent : this._worldWidthTarget;
            var ratio = worldWidth / this.source.dimensions.x;
            var clip = this._clip.times(ratio);
            bounds = new $.Rect(
                bounds.x + clip.x,
                bounds.y + clip.y,
                clip.width,
                clip.height);
        }
        return bounds.rotate(this.getRotation(current), this._getRotationPoint(current));
    }
933793
@Pure
	protected Rectangle2d calcBounds() {
		final Rectangle2d bb = new Rectangle2d();
		boolean first = true;
		Rectangle2afp<?, ?, ?, ?, ?, ?> b;

		// Child bounds
		N child;
		for (int i = 0; i < getChildCount(); ++i) {
			child = getChildAt(i);
			if (child != null) {
				b = child.getBounds();
				if (b != null) {
					if (first) {
						first = false;
						bb.setFromCorners(
								b.getMinX(),
								b.getMinY(),
								b.getMaxX(),
								b.getMaxY());
					} else {
						bb.setUnion(b);
					}
				}
			}
		}

		// Data bounds
		P primitive;
		GeoLocation location;
		for (int i = 0; i < getUserDataCount(); ++i) {
			primitive = getUserDataAt(i);
			if (primitive != null) {
				location = primitive.getGeoLocation();
				if (location != null) {
					b = location.toBounds2D();
					if (b != null) {
						if (first) {
							first = false;
							bb.setFromCorners(
									b.getMinX(),
									b.getMinY(),
									b.getMaxX(),
									b.getMaxY());
						} else {
							bb.setUnion(b);
						}
					}
				}
			}
		}

		return first ? null : bb;
	}
1034681
function(rectangle) {
        return $.Rect.fromSummits(
            this.pixelFromPoint(rectangle.getTopLeft(), true),
            this.pixelFromPoint(rectangle.getTopRight(), true),
            this.pixelFromPoint(rectangle.getBottomLeft(), true)
        );
    }
856185
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
	@Override
	int calculateEndLeftBound(float xAxisDelta) {
		return (int) (getView().getX() + xAxisDelta);
	}
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))
1174170
public Rectangle getRect1() {
        verifyPropertyPresence(RECT1);
        //noinspection unchecked
        return mapToRect((Map<String, Object>) getCommandResult().get(RECT1));
    }
175307
private Rectangle getDefaultBounds() {
		final Dimension size = getToolkit().getScreenSize();
		final Insets insets = getToolkit().getScreenInsets(getGraphicsConfiguration());
		return new Rectangle(insets.left, insets.top, size.width - insets.left - insets.right,
				size.height - insets.top - insets.bottom);
	}
529841
public Rectangle2D getBounds() {
		if (needsRefresh)
			refreshCurve();
		Rectangle2D b = curve.getBounds();
		Area area = new Area(bounds);
		area.transform(affineToText);
		b.add(area.getBounds());
		return b;
	}