mkhexgrid — make hexagonal grids
mkhexgrid [option]... [specfile [outfile]]
mkhexgrid creates hexagonal grids in PNG, PostScript, and Scalable Vector Graphics (SVG) formats, optionally labeled with coordinates and hex centers. specfile is the name of the file containing hex grid parameters and outfile is the name of the file into which output is written. If outfile is not specified, output will be written to standard output. If specfile is not specified, grid parameters may be read from standard input.
mkhexgrid uses GNU getopt to process command-line arguments. Each option may be given as --option-name
for options which take no arguments, or as --option-name=argument
for options which take arguments.
Lengths and sizes are in pixels for PNG and SVG output and are given without specifying the unit. Lengths and sizes may be specified in inches, millimeters, or points (as in
, mm
, or pt
) for PostScript output, and default to points when no unit is given. (1in = 72pt = 25.4mm) Lengths and sizes for PNG output must be integers, with the exception of coordinate size, which may be a decimal. All angles are given as decimals in degrees.
Colors are given in hexadecimal RRGGBB format for PNG and SVG output (e.g., FFFFFF
is white, 8C6AC6
is a shade of purple). Colors are given as R,G,B triples for PostScript output, where R, G, and B are values in the interval [0,1] (e.g., 1,0,0
is red, and 0.8,0.8,0.8
is a light grey).
Opacity ranges over integers in [0,127] for PNG output, reals in [0,1] for SVG output, and is ignored for PostScript output.
-
) is given as the filename. To write to a file named -
, give ./-
as the filename.png
for PNGs, ps
for PostScript, and svg
for SVG.Not all of hex width, hex height, hex side, image width, image height, rows, and columns need be given in order to draw a grid. A grid will be drawn so long as enough of these are specified so that the ones omitted may be calculated.
808080
for PNG and SVG output, 0.5,0.5,0.5
for PostScript output.h
for horizontal and v
for vertical. With horizontal grain, the rows are straight and the columns wavy; vertical grain is the opposite, and is the default.i
for in, or o
for out. Which column or row is the first is fixed by the coordinate origin.These options affect the appearance and placement of coordinates within hexes.
808080
for PNG and SVG output, 0.5,0.5,0.5
for PostScript output.printf()
function in C. The following special markers cause values to be substituted into the format string where they appear:
%
and the format letter; numeric types can be zero-padded by prepending a 0
to the field width. The alphabetic formats count AB
as the successor of AA
by default; tally-like counting where BB
is the successor of AA
can be specified by inserting a t
before the format letter. A percent sign may be specified by %%
. The default format is %02c%02r
. Coordinates may be disabled by giving an empty string (""
) as the format.ul
for upper left, ur
for upper right, ll
for lower left, and lr
for lower right. Upper left is the default.n
for none, d
for dots, and c
for crosses.808080
for PNG and SVG output, 0.5,0.5,0.5
for PostScript output.FFFFFF
for PNG output, and to none for SVG and PostScript output.--
will not be interpreted as options. This is useful if you want to read a specfile the name of which begins with two dashes.Due to the large number of options which may be necessary to generate a single hex grid, users may also specify hex grid parameters in a specfile which can be read from standard input or named as the first non-option argument on the command line. A specfile contains =
-separated option/value pairs, one pair per line. Comments may be preceded by a #
, either following an option/value pair or on lines by themselves. Values containing spaces must be double-quoted. Double quotation marks may be included in quoted values by preceding them with a backslash. Options which require no value on the command line must be given a dummy value in a specfile. Options given on the command line override options given in a specfile.
Example:
# specfile example output = png hex-side = 30 # this is an end-of-line comment coord-format = "%C\" %02r" antialias = true # 'true' is a dummy value
Here, the coordinate format will produce coordinates like A" 01
, which isn't something anyone is likely to want, but it illustrates how to include spaces and quotation marks in a quoted value.
mkhexgrid --output=ps --image-width=34in --image-height=22in --hex-side=0.5in --coord-bearing=0 --coord-dist=0.3in --coord-size=8 --grid-thickness=1 --coord-font=Helvetica --grid-grain=h --grid-start=o --coord-tilt=-90 --centered -o test.ps
mkhexgrid is available from
http://www.nomic.net/~uckelman/mkhexgridNew releases of mkhexgrid are announced on the
mkhexgrid-announce@nomic.netmailing list. To join, send a message to
mkhexgrid-announce-request@nomic.netwith the word
subscribe
in the message body.
Written by Joel Uckelman <uckelman@nomic.net>.
Please report bugs to <mkhexgrid-bugs@nomic.net>.
Copyright © 2006, 2007 Joel Uckelman.
This is free software. You may redistribute copies of it under the terms of the GNU General Public License. There is NO WARRANTY, to the extent permitted by law.