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.

Old School Hex Map Tutorial

mkhexgrid

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.

Homebrew

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'
    end
    inreplace 'mkhexgrid.cpp' do |s|
      s.sub! 'catch (exception &e)', 'catch (std::exception &e)'
    end
    system "make" # needs to be separate
    system "make", "install"
  end

  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"
  end
end

​#Maps ​#SVG ​#Mac

Comments

(Please contact me if you want to remove your comment.)

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