Artificial intelligent assistant

How to determine width and height of outer rectangle when it is scalled to an inner rectangle I have a rectangle with more than 800 width and 600 height. It can be 1000 x 600, 2000 x 1000 and etc. I want to scale it to 800 x 600. I want to determine which one matches first, the height or the width and also get the other value that didn't meet first. | | | |800x600 | | | |inners rec| | | |outer rectangle(1000 x 1000) if I resize which one will hit the boundaries of the inner rectangle left and right or top and bottom. updated I used the term square When it should be rectangle.

Take the ratio in each axis and use the smaller one. So if you start with $2000 \times 1000$ the horizontal is $\frac {800}{2000}=0.4$, the vertial is $\frac {600}{1000}=0.6$. So you scale by a factor $0.4$ and the vertical is $0.4 \cdot 1000=400$. These are rectangles, not squares.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 27b6975722f4c3bf1e17dd2da939670d