See attached picture for reference. I'm working on a map generator and I would like to include altitude, where either brightness of color represents altitude, or there are nested curves that show where the altitude crosses a certain threshold. If I just added circles or polygons at random, it would lead into drastic drops in altitude instead of a smooth increase or decrease.
My idea is to store the highest and lowest points within an area and if two high points can be connected by a straight line without crossing the impact circle of a local low, they are considered connected (red lines in graph). Similarly, low points will be connected if they don't get intercepted by high points. Then the program should surround the highest points with blobs that start out as circles, and the edges of the circles can be pushed inwards by the influence of nearby lows. Each low has an impact radius within which it can push lines towards high points. Highs within the same altitude and which are connected will be surrounded by a continuous line or a blob. If a high inside a blob is higher than the other highs, it will in addition to be surrounded by a nested circle or as many as are needed to represent the height difference. Similarly, lows that are lower than the base altitude will be wrapped in blobs. There will be as many nested blobs as necessary to cover the difference in altitude.
The problem is, how to calculate where the curves go? I think I need to start with calculating how many steps (lines) are between highs and lows and drawing short walls that separate them. (Image 3) When I have all the short walls drawn, I would connect them to each other. I should figure out which points are close enough to interact without crossing an invisible line connecting two other points.
It doesn't necessarily have to use bezier curves since I don't have ImageMagick but I've read that there are resources available that allow drawing bezier curves with GD. I would be happy even with polygons. The presence of corners doesn't necessarily bother me.
Drawing altitude maps with GD
Moderator: General Moderators
Re: Drawing altitude maps with GD
You can't do this well just by using high and low points. You need to know everything in between, and knowing it also gives you more control over the terrain.
You can start with high and low points, but in the next step calculate (however you want) all the elevation points everywhere on the map. There's also some degree of realism: local lows and highs aren't the same as global lows and highs.
As a simple example,
001123344455556677788
112233444555566677778
223344555566677888888
444455556667778889999
556667788888889998887
667788999999999887765
889999998888888999887
999888888777888899999
888877665556677888888
777666655455667777778
555555444444556666677
You can start with high and low points, but in the next step calculate (however you want) all the elevation points everywhere on the map. There's also some degree of realism: local lows and highs aren't the same as global lows and highs.
As a simple example,
Code: Select all
X 0 1 2
Y 012345678901234567890
00 001123344455556677788
1 112233444555566677778
2 223344555566677888888
3 444455556667778889999
4 556667788888889998887
5 667788999999999887765
6 889999988888889998877
7 999888888777888899999
8 888877665556677888888
9 777666655455667777778
10 555555444444556666677
112233444555566677778
223344555566677888888
444455556667778889999
556667788888889998887
667788999999999887765
889999998888888999887
999888888777888899999
888877665556677888888
777666655455667777778
555555444444556666677