[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] How to add Zoom functionality?



gopal mishra wrote:
I am using Mirra to draw some shapes on the screen and set the environment “wx” to add the scrollbar. Does any one know how to add ZOOM in and zoom out functionality?

To "zoom" the shapes you are drawing, you will need to multiply the positions of all the points. For example, to zoom in twice as large, multiple the point positions by 2.0.

If you are using shapes like circles and arcs, you will also need to multiply any additional arguments (like radius) by the same amount.

This multiplying is all you need to zoom in and out, but you'll find it zooms everything away from a corner of the image, which usually isn't desirable. Usually you want to zoom around the center of the window. You'll need to figure out what the coordinate is for the window center. Then subtract that position from each point before scaling, and add the multiplied position back after scaling.