Calculate inner rectangle new top left position after outer rectangle is scaled

195 Views Asked by At

I have a rectangle inside a rectangle, like this:

before scaling

After the outer rectangle is scaled, I'd like to scale the inner rectangle in proportion to outer as well (I can already do this). What I'm having trouble with getting the new position (x,y of top left) of the inner rectangle while still in proportion to the outer before scaling.

What formula should I use to calculate it? Would be extremely grateful for any help. Thanks!

Edit: I forgot to mention this: the top left x,y of the inner rectangle is not based on the outer rectangle(red) but rather their container(black). The same applies to the outer rectangle.