# Rectangle co-ordinates on resize

### Rectangle co-ordinates on resize

Hi, I have 2 rectangles as in the attached image.
Blue Rect(Lets say, w by h -> 300 x 80)
There's a Red Rect inside Blue rect(Lets say, co-ordinates -> Top Left point(75,15)
(w by h -> 48 x 23).

Now if the blue rect is resized to (w by h = 128 x 32), what would be the co-ordinates and width x height of the red rect inside the blue rect of (128 x 32).

Regards,
Sayan
Attachments Example of rectangle resize
Untitled.png (2.22 KiB) Viewed 208 times
Guest

### Re: Rectangle co-ordinates on resize

The outer rectangle is 300 by 80 and is resized to 128 b y 32. That is, horizontally, it is reduced to $$\frac{128}{300}= \frac{32}{75}$$. Vertically, it is reduced to $$\frac{32}{80}= \frac{2}{5}$$. The horizontal side length of the smaller rectangle is $$48\left(\frac{32}{75}\right)= \frac{512}{25}= 20.48$$ and the vertical side length is $$23\left(\frac{2}{5}\right)= \frac{46}{5}= 9.2$$. The position horizontal and vertical position of the upper left corner is set the same way, $$75\left(\frac{32}{75}\right)= 32$$ and $$15\left(\frac{5}{2}\right)= \frac{75}{2}= 37.5$$.

HallsofIvy

Posts: 51
Joined: Sat Mar 02, 2019 9:45 am
Reputation: 13