I wrote one of these. Its pretty simple. Use a scrollpane and use scrollpane.load to load an image. Then you record its dimensions (like 800x600). Then, you make a slider. Then you set the onRelease of the slider to compute its distance from the start to the end to get a number. Then you use a linear transformation to change that number to a number between 1 and 10 (for a 10x maximum magnification).
Use this number (time 100) as the xscale and yscale for scrollpane.content. If you want to center as you zoom, you have to do some math to figure out the increase in x pixels and y pixels after the scale, and subtract half from the content's current _x and _y. Also you use startdrag and stopdrag on the content to move it around.
|