On 08/17/2011 12:48 AM, Kevin Fishburne wrote: > I'm sure this is ridiculously simple, but my simple brain can't seem > to figure it out. > > I have a set of screen coordinates, xPos and yPos. I need to adjust > their positions based on a zoom level, CameraZoom. The zoom level is > relative to the center of the screen (swidth / 2, sheight / 2), and > the zoom level range is from 1 to 2. If the zoom is at 1, the x and y > coordinates wouldn't change. If the zoom is at 2, they would be half > their previous distance from the center of the screen. This simulates > the positions of objects changing as the camera zooms in and out. > > There has to be some simple equation to produce this. I've attached > the procedure that needs this just for reference. Any clues > appreciated, as always.
Maybe I'm not quite as dumb as I thought. ;) I got it. I needed to do this: ' Assign initial values to variables CameraZoom = 1 / Zoom.Current ' Modify screen coordinates for zoom level. xPos = (swidth / 2) + ((xPos - (swidth / 2)) / CameraZoom) yPos = (sheight / 2) + ((yPos - (sheight / 2)) / CameraZoom) ' Modify dimensions for zoom level. Width = Width / CameraZoom Height = Height / CameraZoom I could probably just multiply by Zoom.Current instead of dividing by CameraZoom, but whatever. Hopefully someone will find the algorithm useful someday. -- Kevin Fishburne Eight Virtues www: http://sales.eightvirtues.com e-mail: [email protected] phone: (770) 853-6271 ------------------------------------------------------------------------------ Get a FREE DOWNLOAD! and learn more about uberSVN rich system, user administration capabilities and model configuration. Take the hassle out of deploying and managing Subversion and the tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2 _______________________________________________ Gambas-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/gambas-user
