• Scales an image (or any content) to cover a destination area while maintaining its aspect ratio.

    The function calculates the scaling factor by determining the maximum scale factor between the destination width and height based on the source's aspect ratio. This ensures the content will fully cover the destination area, possibly overflowing one dimension (either width or height).

    Parameters

    • sourceWidth: number

      The width of the source content (e.g., image width).

    • sourceHeight: number

      The height of the source content (e.g., image height).

    • destWidth: number

      The width of the destination area to cover.

    • destHeight: number

      The height of the destination area to cover.

    Returns number

    The scale factor to apply to the source content to cover the destination area.