views:

38

answers:

2

Want to recalculate x and y in a centered layout relative to the current viewers resolution.

I have two numbers a set of coordinates x and y.

x=140
y=80

x and y was recorded in a resolution sessionWidth, sessionHeight

sessionWidth = 1024
sessionHeight = 400

Want to recalculate x and y so that they are relative to the viewers resolution.

currentViewWidth = 1280
currentViewHeight = 500

So want to plot x,y for a lot of coordinates (with different sessionWidth and SessionHeight) but want to normalize to the currentViewWidth and currentViewHeight.

currentViewWidth and currentViewHeight are constant.

How on earth do I do that - do you got a formula I can use? Thanks a million.

+1  A: 
newX = currentViewWidth * x / sessionViewWidth
newY = currentViewHeight * y / sesionViewHeight
Ignacio Vazquez-Abrams
A: 

new_x = 140/1024*1280 = 175 new_y = 80/400*500 = 100

hoang