Sign in to follow this  
walle

Algorithm design

Recommended Posts

Hello. Need some help designing a algorithm, or help getting in the right direction anyway. In my map editor, simple 2d maps. I want to have a navigation box, like in photoshop. Were you can see the whole map scaled down and a marcing to show were you are currently looking. My maps doesn't have a upper or lower limit really, so you could make a 3000 x 150 pixels map as well as a 150 x 3000 (not that I know how it would be useful though). Basically I want to scale my drawing surface down to fit either way in the navigation box. And I need some ideas on how to do that :)

Share this post


Link to post
Share on other sites
Determine the scaling factor of the map if it is scaled to fit horizontally, and then determine the scaling factor of the map if it is scaled to fit vertically. Use the smaller of the two.

Share this post


Link to post
Share on other sites
I'm Using SDL.Net under c#. My maps are stored in lists, but I thought it would be easier to take the surface I'm drawing to and scaling it in some way.

Yes Sneftel, but is there a general way to determine the scaling factor?

Share this post


Link to post
Share on other sites
Say that your mini-map box is 150x200 pixels.
And your surface (with the map) is 350x750 pixels.

The horizontally (-) scaling factor would be 150/350, which equals approximately 0.42.
Do the same for the vertical (|) and get that it's scaling factor is 0.26.

The smallest of these two is 0.26 ( 0.26 < 0.42 ), which leads you to that you should scale down your surface (map)
with a scaling factor of 0.26 to make it fit your mini-map box. (Both on the horizontal and vertical side.)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this