# Algorithm design

This topic is 4155 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 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 on other sites
Which graphics API are you using, and how is your rendering done? How are your maps stored?

##### 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 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 on other sites
Aha, thanks. Sounds simple now when I know, but I couldn't come up with it myself.

##### Share on other sites
Basically, what you do is that you get how many percent bigger the target is than the source.

1. 1
2. 2
3. 3
Rutin
22
4. 4
5. 5

• 13
• 19
• 14
• 9
• 9
• ### Forum Statistics

• Total Topics
632936
• Total Posts
3009312
• ### Who's Online (See full list)

There are no registered users currently online

×