rlguy / FantasyMapGenerator

A fantasy map generator based on Martin O'Leary's "Generating fantasy map" notes
Other
696 stars 55 forks source link

SVG output support #3

Open miilic opened 7 years ago

miilic commented 7 years ago

It would be rather convenient to have the ability to output in SVG format, since SVG files are much more friendly for editing and scaling. I tried adding that to Python rendering script (using svgwrite library), but it became painfully slow once I added the slope lines to output. In the end I hacked something together in C++, adding the MapGenerator::outputSvgData and a couple of small helper functions to MapGenerator class. SVG generation is pretty straight-forward, and it comes with an unexpected benefit of not having to calculate and pass label text extents for background covering, since SVG filtering can be employed to do that automagically. I used to a simple semi-opaque white to cover label backgrounds, but the specifics are easily editable. Patch and a couple of output SVG files (B&W vs color) are attached. I verified those SVG files by opening and editing them in Inkscape, in case your SVG viewer of choice is giving you trouble. Thanks for an awesome application and a great educational write-up on how it all works together! svg_output.zip

psi29a commented 7 years ago

Could make a pull request?