Algorithm design

Started by
5 comments, last by blueapple 16 years, 10 months ago
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 :)
Advertisement
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.
Which graphics API are you using, and how is your rendering done? How are your maps stored?
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?
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.)
Check out my devlog.
Aha, thanks. Sounds simple now when I know, but I couldn't come up with it myself.
Basically, what you do is that you get how many percent bigger the target is than the source.
Check out my devlog.

This topic is closed to new replies.

Advertisement