SheetXL - v0.8.0-beta.9+sites.210.e2d420901
    Preparing search index...

    Function clipToOuterRect

    • Computes the largest unrotated size for an inner rectangle such that, when rotated by rotation degrees about its own centre, it fits entirely within the outer rectangle.

      The algorithm centres dimInner inside dimOuter, rotates the inner rectangle, then clips its edges against the four sides of the outer rectangle using line–line intersection. The clipped points are un-rotated and their axis-aligned bounding box is returned.

      Axis-aligned special cases (0°, 90°, 180°, 270°) are handled analytically and do not go through the intersection path.

      Parameters

      • dimInner: Size

        The width and height of the inner rectangle before rotation.

      • dimOuter: Size

        The width and height of the bounding outer rectangle (unrotated).

      • rotation: number = 0

        Clockwise rotation angle in degrees to apply to the inner rectangle. Negative values are normalized to the [0, 360) range. Defaults to 0.

      Returns Size

      The unrotated Size (width × height) of the inner rectangle after it has been clipped to fit within dimOuter at the given rotation.