How to track Top Left position of rectangle when scaling from center of pages.

217 Views Asked by At

I am building some drawing apps that require to track the XY coordinate of user drawing rectangle (it can be multiple rectangle) on image. Now i have bump into a problem is i do not know how to track the XY coordinate of each rectangle after image is scaled up. A better illustration of my problem can be shown in the below figure. Do any experts here have an solution how to calculate the XY coordinates after scaled up/down? Thanks

enter image description here

enter image description here