The width of the source content (e.g., image width).
The height of the source content (e.g., image height).
The width of the destination area to fit the content within.
The height of the destination area to fit the content within.
Optionalmin: numberThe minimum scale factor. Defaults to 0.
Optionalmax: numberThe maximum scale factor. Defaults to Infinity.
The scale factor to apply to the source content to fit it within the destination area.
Scales an image (or any content) to fit within a destination area while maintaining its aspect ratio.
The function calculates the scaling factor by determining the minimum scale factor between the destination width and height based on the source's aspect ratio. It then clamps the result to be within the specified minimum and maximum scale factors.