2014-01-11 mkhexgrid

My Old School Hex Map Tutorial tells people to use mkhexgrid, if they can. It’s what I’ve been doing for years, now.

On my wife’s laptop we now run Mac 10.9 (”Maverick”) and it no longer builds. As I’ve switched to using Homebrew, I recided to write my own Formula.

If you want to try it, save it as /usr/local/Library/Formula/mkhexgrid.rb and run brew install mkhexgrid. The only tricky thing is that it requires the GD library to be built with FreeType, apparently. If you don’t have GD installed, great. This Formula will do the right thing. If not, you might have to brew uninstall gd before proceeding.

require 'formula'

class Mkhexgrid < Formula
  homepage 'http://www.nomic.net/~uckelman/mkhexgrid/'
  url 'http://www.nomic.net/~uckelman/mkhexgrid/releases/mkhexgrid-0.1.1.src.tar.bz2'
  sha1 '3b8e0be3636f90a3217a5e3556bdaf7bb0c49116'

  depends_on 'gd' => %w{with-freetype}

  def install
    inreplace 'Makefile' do |s|
      s.change_make_var! "DESTDIR", prefix
      s.change_make_var! "CC", ENV.cc
      s.gsub! /install (.*) -o 0 -g 0/, 'install \1'
    inreplace 'mkhexgrid.cpp' do |s|
      s.sub! 'catch (exception &e)', 'catch (std::exception &e)'
    system "make" # needs to be separate
    system "make", "install"

  test do
    # test the example from the man page (but without inches)
    system "mkhexgrid", "--output=ps", "--image-width=2448",
    "--image-height=1584", "--hex-side=36", "--coord-bearing=0",
    "--coord-dist=22", "--coord-size=8", "--grid-thickness=1",
    "--coord-font=Helvetica", "--grid-grain=h", "--grid-start=o",
    "--coord-tilt=-90", "--centered", "-o", "test.ps"



These days, it’s part of Homebrew:

alex@Megabombus:~$ brew search mkhexgrid
homebrew/games/mkhexgrid ✔
alex@Megabombus:~$ brew install mkhexgrid
Warning: homebrew/games/mkhexgrid-0.1.1 already installed
alex@Megabombus:~$ brew reinstall mkhexgrid
==> Reinstalling homebrew/games/mkhexgrid
==> Downloading http://www.nomic.net/~uckelman/mkhexgrid/releases/mkhexgrid-0.1.
`#``#``#``#``#``#``#``#``#``#``#``#``#``#`## 100,0%
==> make
==> make install
🍺  /usr/local/Cellar/mkhexgrid/0.1.1: 14 files, 214.9K, built in 28 seconds

– Alex Schroeder 2016-04-13 05:41 UTC

Please make sure you contribute only your own work, or work licensed under the GNU Free Documentation License. Note: in order to facilitate peer review and fight vandalism, we will store your IP number for a number of days. See Privacy Policy for more information. See Info for text formatting rules. You can edit the comment page if you need to fix typos. You can subscribe to new comments by email without leaving a comment.

To save this page you must answer this question:

Please say HELLO.