Friday, May 31, 2019

Worldbuilding Magazine Cartography Contest

Shortly after I'd finished my entry for the Monochrome Map Challenge, the Worldbuilding Magazine Cartography Contest popped up on my newsfeed.  Each issue of Worldbuilding Magazine typically features some aspect of worldbuilding as a central theme; the theme for the August issue will be “geography" and they partnered with Wonderdraft to run a contest for maps with the winners to run in the August issue.  I can't resist a contest, so I decided to put together an entry.

Unlike the Monochrome Challenge, there are no real restrictions on the map for this contest.  The only real requirement is that “Image size should be at least 1536x2048px."  That's actually a little bit of a challenge for me.  Obviously I can generate a map with any given pixel dimensions (SVG scales without loss) but I don't think they really want a very high resolution small map; they're looking for a more traditional “continent" sized map.  I have done some work on generating continent-sized maps but that is not complete, and it's a bit of a pain for me to work on big maps because they take a long time to generate and render.  But needs must as they say.  At least I can do most of the styling work on smaller maps before moving on to a bigger map.

I'm not going to step through every design decision I made for this entry (like I did for the Monochrome entry).  But I will hit some highlights.

For an overall style I settled (somewhat randomly) on a muted palette to give the feel of an old, faded map.  I won't present it as a book page, but as a standalone map.  Along those same lines, I'll use a compass with a muted color scheme and a simple map border.

I decided to use a faux 3D style for representing mountains, as shown in this excerpt:
Since this contest is sponsored by Wonderdraft, I expect a lot of entries created with that tool, and I wanted to distinguish my map from those.  Wonderdraft represents mountains with icons so I wanted to avoid that style.  When I started playing with the style above, I realized I didn't have any way to control how dramatic the coloring is, so I added an option for that.  For example, I can turn the coloring down to create a more subtle indication of the landform:
Overall I'm going for a subtle, faded style in this map so being able to dial in the terrain shadows is very useful.

Adding a Lost Coast to this map triggered a bug.  It was possible for the Lost Coast to be on a part of the map that wasn't visible (beyond the edge of the map).  That was fixed by checking visibility as candidate locations are investigated.  Another problem was that the Lost Coast was right on top of a barrier island.  Both features look for a section of flat coast for placement, so this should have not been a surprise.  The fix involved setting the Lost Coast (which gets created after the islands) to stay away from the islands.

While I was working on barrier islands, I decided to fix their generation.  When I first implemented barrier islands I had an issue with the underlying Voronoi regions on the map being too big to properly show narrow, broken islands next to the shore.  I addressed this by adding the ability to represent land as a polygon unconnected to the Voronoi regions.  This worked well as far as it went, but the polygons I could generate were somewhat unsatisfying -- long blobs:
Since then, I revisited how I generate the Voronoi regions and adopted an approach where I use very dense Voronoi grid early in generation and then “downsize" the grid after capturing the detailed coastlines.  This permits me to generate very detailed land without later overwhelming the browser trying to display the map.  With this approach in place, I can generate barrier islands using the dense Voronoi regions, allowing me to generate more detailed and broken islands:
These look much better.

I also wanted to include an ocean illustration on this map (since it will be a continent-sized map and the larger ocean will have ample room for an illustration), and discovered in turning that on that it had a bug resulting from a new way I adopted for loading external SVG.  There are so many different features in Dragons Abound that I often find old features that have stopped working for one reason or another.

With those changes in place I was close to a finished map, but I then ran into another problem -- I was unable to save the whole map as a PNG file.  It's surprisingly difficult to save an SVG image out of a browser.  Unlike (say) a JPG image, there's no “Save Image" or “Save As" option for SVG elements.  There's no way to save a web page as an image, and if the image is larger than the screen you cannot use a screenshot.

So far, I have been using the SaveAsPng library to capture images.  This has generally worked fine, but it runs into problems with larger maps and crashes the tab.  The method for converting an SVG into a PNG is a horrible kludge -- it involves turning the SVG into a data URI, writing that into an HTML canvas element, extracting a data Blob from the canvas, and then writing that out as a PNG.  The SVG for a map of the size I'm doing for this contest is almost 300M, and at this size the step of writing that into canvas element overwhelms Chrome.

I took a look at the SaveAsPng code and I don't see any obvious way to avoid the problem.  In the meantime, there are a couple of possible workarounds  for getting a screenshot, although they all have drawbacks.  The SaveAsPng code actually works (at least in limited testing) on Firefox, but there are other problems on Firefox -- it has aggressive security code that rejects some fonts, and prevents images in the map (such as the compass) from being captured by SaveAsPng.  It might be possible to work around the image problem but overall it's not a good solution.

Another approach is to save the SVG, view it in Inkscape, and then print from there.  This sort-of works -- again, there's some problems with fonts that have to be manually corrected.  It's also a slow multi-step process.

There are some Chrome extensions that promise “full page" screenshots.  Unfortunately, the ones I've tried fail to actually capture the whole map.  It might be that I could adjust my HTML to help them work better, but they also take a long time -- several minutes -- to create a capture, so that doesn't seem like a workable solution.

Finally, the Chrome developer tools include a screenshot tool that can capture the entire screen.  This works quite well and only takes about 15 seconds to capture a large map.  The drawback is that it is only accessible via the Chrome developer console, so it can't be used as (say) a button on the map webpage.

For the moment I can use the Chrome developer tools to get my screenshots, but in the long-run I'd like something that would work from the webpage itself.

With the basic style established, I then generated some candidate maps using different random seeds, and selected one that I thought looked interesting:  a single continent with two extensive river valleys on opposite sides of some interior highlands, a complex southern coastline and expansive forests.  In the final step I tweaked a few location names and adjusted some labels.  This is the final result (click through for full size):
This is the sort of thing I can tweak forever, but I spent far too long on this as it is, so this is the version that I will submit.

3 comments:

  1. Inkscape has a command line version that may be of some use. It's not really any more efficient but it saves you having to manually open a complex map.

    ReplyDelete
  2. Scott: Can you upload an example I can test in firefox? I'd be interesting in testing it -- I *might* have a couple of ideas to save it as a png.

    ReplyDelete
  3. Could you run Dragons Abound with Electron? Then you could access Inkscape from the command line to do the conversion automatically.

    ReplyDelete