Automatic Creation of Tab Separators

As part of my work to organize my Pathfinder ACG box, I found that I needed a way to create alternating tabs in a general way. In particular, a few times, I found myself in the position where I had designed the tabs in photoshop only to realize when I was done that I had forgotten something. Or, in the case of Wrath of the Righteous, that there were new cards that needed to go in the middle of the sequence. Since this would require re-ordering all of the tabs following it, this became a bit of a task.

To solve this problem, I decided that I wanted to write a program to lay out tabs for me, and automatically take care of that alternation. To prototype, I create a short function in perl that had the basic imagemagick commands that I would use, and took a big list of tabs as input. The script automatically “-flop”ed the template to perform the horizontal mirror, and placed the appropriate text in position from the correct edge (i.e. positioned from the left edge on the left tabs, and from the right edge on the right tabs). I used this prototype to figure out the basic features I would need, and created the tabs for Rise of the Runelords and Wrath of the Righteous.

The next step was creating a program like I had for laying out card decks. In this case, my Domain Specific Language would be a little closer to ImageMagick, but would be specialized for composing images and text onto a template with alternation. With some smart defaults and the ability to distill common commands into the header, I should be able to create a variety of effects with very little code.

The part that I’m less sure on now is the format of my DSL. My initial thought was one argument per line as that is quite easy to parse (the only delimiter to worry about is a newline), but then separating out a single tab would be a bit more difficult, and I think this would make for long text files for which the information is ungrouped. In this case, a pair of tabs might look like:

caption:'a left tab'
-size 100x24
-geometry 5x5
caption:'with extra text'
-size 100x24
-geometry 5x30
caption:'a right tab'
#use the default size and position

In choosing a different delimiter though, I also wanted something that wouldn’t have to be escaped on the command line or ImageMagick (in many cases) as this would end up causing the many backslash problem, of which I’m not a huge fan. To resolve this, my plan is two use two-character delimiters that can be escaped if needed with the contents of a tab on a single line. With this, I should be able to parse the arguments without too many slashes and have nicely grouped tabs. These tabs would then look like:

caption:'a left tab' == -size 100x24 == -geometry 5x30 && caption:'with extra text' == -size 100x24 == -geometry 5x30
caption:'a right tab'

Once creates all the images for the tabs, I can easily invoke script to make pages to print and cut. I thought quite a bit about whether I wanted to include a subset of the capabilities of in, i.e. include enough options that could be called from a script. I decided not to primarily to avoid having to parse all of the options up front; I may revisit if I find that there’s a small enough subset that it becomes worth it.

Once the scripting is done, I’ll start creating card tabs for a fair number of my box organization projects. First the projects I have open (Pathfinder ACG and Netrunner), then I’ll keep the script around for whatever tabs I may need…

Category(s): Gaming, Programming
Tags: , , ,

Comments are closed.