I'm building a smartphone javascript application but my question today is really only math related. To give you a quick idea of what I'm doing, my code checks the smartphone's gyroscope to determine how much it is rotated. Based on that rotation, it's supposed to pan a background image around. So in the image below, the red box is stationary, while the photo is supposed to pan around in the background as you rotate your device.

Anyway, here's the math problem (focusing only on moving the X axis):
- The gyroscope gives a reading of 0 to 360
- The photo in the background gets moved from the top left, so its max and min values are 0 to -100
- Therefore the formula for how much to move the image based on the device rotation would be a simple ratio: (Gyroscope Reading * -100)/360
- However, I don't want people to need to turn their device all the way over to achieve the full animation, so I'm only interested in the gyroscope readings of about 140 to 220.
- So, what formula would achieve 140 = 0 and 220 = -100? The formula should maintain the ratio for all points in between.