I have an image 1916x971 in size embedded in an app.
I'm implementing a zoom action that allows the user to scale the image from 1 (actual size) to 6.
I am also restricting the movement so when the user slides out of bounds of the image, the movement will stop.
When the scale is 1, the translation matrix equals the original matrix, and therefore the "right" movement stops at 1916 and "down" stops at 971, as expected.
However when I zoom in and move right and down, the translated matrix stops well before the edge of the image. As the scale grows, so does the distance from the edge of the image.
I was able to gather the values in which the movement should stop, but my math is quite weak and I can't figure out what formula, dependent on Scale and Width\Height, will give me the required values for each Scale.
Scale Right Down
1 1916 971
1.3 1892 948
1.5 1868 938
2 1788 916
3 1652 878
4 1498 814
6 1187 727
What I'm looking for is the formula, that, for example:
input: Scale=1 Width=1916, output: 1916
input: Scale=1.3 Width=1916, output: 1892
input: Scale=4 Width=1916, output 1498
Could the formula be used for any image size?
Well, a simple linear regression calculation using
python's panda and scipylibraries provided with the following:Taking 1916x971 into consideration, the following linear regression formulas:
I hope this will work for different
WidthandHeight, otherwise it's back to the drawing board