scale = min(dst.width/src.width, dst.height/src.height)
This is your approach but written more cleanly.
To use this, the scaled rectangle would have the shape:
width = src.width * scale
height = src.height * scale
scale = min(dst.width/src.width, dst.height/src.height)
This is your approach but written more cleanly.
To use this, the scaled rectangle would have the shape:
width = src.width * scale
height = src.height * scale