Lingua italiana

nanDECK - HEXGRID

HEXGRID is a new directive, useful when you want to draw a grid of hexes on a card (or on a page). The syntax for this directive is:

HEXGRID = range, x, y, width, height, hex_size, flags, front_color (, back_color, thickness)

The last two parameters are optional: if omitted, the standard back_color is EMPTY and, if omitted, the standard thickness is 0 (1 pixel).

For example, if you want a 18 x 20 cm hex grid, with a hex (side) length of 1 cm (and a line thickness of 1 mm), you can write:

CARDSIZE = 18, 20
HEXGRID = 1, 0, 0, 18, 20, 1, , #000000, EMPTY, 0.1

The flags usable in the 7th parameter are:

D = center dot
L = letters
N = numbers
C = coordinates
E = coordinates with letters + numbers
. = separator for C flag
- = separator for C flag
_ = separator for C flag
X = no grid

With the L, N, C and E flags, coordinates are printed in each hex:
L) A, B, C, D...
N) 1, 2, 3, 4...
C) 0101,0102,0103...0201,0202,0203...
E) A1,A2,A3...B1,B2,B3...
C.) 1.1,1.2,1.3...2.1,2.2,2.3...
C-) 1-1,1-2,1-3...2-1,2-2,2-3...
C_) 1_1,1_2,1_3...2_1,2_2,2_3...

The font used for the coordinates is the last specified with a FONT directive. You can also specify multiple coordinates, using multiple flags.


For referencing a single hex, there is a new function: FRAMEHEX. You can use it to automatically define a frame (a label with size informations) for each hex. For example:

CARDSIZE = 18, 20
HEXGRID = 1, 0, 0, 18, 20, 1, , #000000, EMPTY, 0.1
[base] = FRAMEHEX(0, 0, 18, 20, 1, E)

It creates multiple frames named <basea1>, <basea2>, <basea3>, etc. These frames can be used in standard commands, like RECTANGLE, ELLIPSE, TEXT and so on. For example, this command draws a circle on the first hex:

CARDSIZE = 18, 20
HEXGRID = 1, 0, 0, 18, 20, 1, , #000000, EMPTY, 0.1
[base] = FRAMEHEX(0, 0, 18, 20, 1, E)
ELLIPSE = 1, <basea1>, #FF0000

The syntax for this function is:

[name] = FRAMEHEX(x, y, width, height, hex size, flags (, zoom))

The last parameter (zoom) is optional. The flags usable in the 6th parameter are:

L = letters
N = numbers
C = coordinates
E = coordinate with letters + numbers
. = separator for C flag
- = separator for C flag
_ = separator for C flag
O = outer frame (the default, it creates a frame suitable for drawing a circle outside the hex)
I = inner frame (it creates a frame suitable for drawing a circle inside the hex)

The zoom parameter has a default of 100. If you want half sized frames, you can specify 50, if you want double sized frames, the value is 200, and so on.


You can use ? and * as a wildcards for addressing groups of frames (? for any one character, * for a group of any character). As an example, this command draws a circle on all the hexes of the first column:

CARDSIZE = 18, 20
HEXGRID = 1, 0, 0, 18, 20, 1, , #000000, EMPTY, 0.1
[base] = FRAMEHEX(0, 0, 18, 20, 1, E)
ELLIPSE = 1, <basea*>, #FF0000

You can use ~ as a flag for addressing a random frame, for example, this command draws a circle on a random hex of the first column:

CARDSIZE = 18, 20
HEXGRID = 1, 0, 0, 18, 20, 1, , #000000, EMPTY, 0.1
[base] = FRAMEHEX(0, 0, 18, 20, 1, E)
ELLIPSE = 1, <~basea*>, #FF0000


Finally, you can define a group of frames (with the FRAMELIST function), and use a single command on all of them, for example, this script draws three circles on the first three hexes:

CARDSIZE = 18, 20
HEXGRID = 1, 0, 0, 18, 20, 1,, #000000, EMPTY, 0.1
[base] = FRAMEHEX(0, 0, 18, 20, 1, E)
[group] = FRAMELIST(basea1, basea2, baseb1)
ELLIPSE = 1, <group>, #FF0000

You can use a FRAMELIST function also with wildcards, for example:

CARDSIZE = 18, 20
HEXGRID = 1, 0, 0, 18, 20, 1,, #000000, EMPTY, 0.1
[base] = FRAMEHEX(0, 0, 18, 20, 1, E)
[group] = FRAMELIST(basea*, basek*, base?1, base?11)
ELLIPSE = 1, <group>, #FF0000


Back to home page