Drawing altitude maps with GD
Posted: Sun Sep 10, 2017 6:35 am
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.
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.