PDA

View Full Version : Tweakin map zoom



zagnut
11-07-2003, 06:27 PM
While no one probably cares, it always bugged me that the map zoomed in so much when going from 1x to 2x. Here's the code that seems to handle how much the map gets zoomed, from MapParameters::reAdjust() in mapcore.cpp:

int pxrat = ((mapSize.width()) / (m_zoom));
int pyrat = ((mapSize.height()) / (m_zoom));

So, at 2x the width and height get cut in half (x/2). In other words, the area of the map that is shown goes from 100% to 25% ((x/2)^2). Here are a few of the others:

zoom area
1x 100%
2x 25%
3x 11%
4x 6%
...
32x <1%

Ideally (for me), that first zoom wouldn't be so big while the we kept the ability to zoom way in quickly. I'm sure someone can think of something better, but my first stab is:

int pxrat = ((mapSize.width() * 2) / (m_zoom + 1));
int pyrat = ((mapSize.height() * 2) / (m_zoom + 1));

zoom area
1x 100%
2x 44%
3x 25%
4x 16%
5x 11%
...
32x <1%

That isn't perfect. On the plus side, the 1x-2x zoom is great and the next few zooms are fine. On the minus side, the maximum amount you can zoom in is reduced, and it takes more clicks to get there.

Anyway, a two-line patch is attached if you want to try it out. If someone else cares about this and can think of a better algorithm (shouldn't be hard, my math suxx0rs), lemme know.
Thanks

cheeze69
11-08-2003, 06:44 PM
Seems like a good idea. I've noticed the huge zoom on the 1-to-2 setting also, but it never bothered me enough to look into it (that's the great thing about open source!) My pet peeve is when you're on the very edge of a map (ie. entering LDON) and you zoom-in to see the room (high-zoom-in) and your char always stays at the edge of the map. I know I could pan the map some, but it would be nice if it would have an option to keep my position at the center of the screen when zooming, but that's another story.

Anyway, you might be able to get good results with something like:

int pxrat = ((mapSize.width()) * ((11 - m_zoom)*10));
int pyrat = ((mapSize.height()) * ((11 - m_zoom)*10));

Obviously, the above would limit you to 10 zoom levels, but you could choose whatever number you wanted. Thus, at zoom=2, the map is 90% in each direction, at zoom=3 it's 80%, and so-on.

Maybe there's something braindead in my thinking and if so, I'm sure someone will point it out :D

Mike

EDIT: Remove first braindead mistake ;)