Abracadabra index (one word is worth a hundred pixels)

Selected visual index (1600 pixels per entry)

triangular tilings spiralin tiling square tiling tsume go ps go board forms 9x9 go board

All images on this page are so-called png images capturing a fragment from rendered PostScript. The PostScript can be viewed by clicking the highlighted text in the accompanying text, provided your browser knows what to do with a PostScript file. For Windows and Macintosh users there is Aladdin software to do the job.

PostScript

PostScript (PS) is the all-round page description language from Adobe Systems. Not many people know that it is actually very easy to write PS files oneself. It was John Tromp who made me aware of this. The PS language is compact, powerful, and has a clean design. Its syntax is entirely stack based, which might be a hurdle for some. Writing PS (or, writing programs that write PS) can be a good move if you need pictures that are made of repeating shapes or pictures that have a simple geometrical design. In order to appreciate the examples below you should have a PostScript viewer available. For most operating systems (e.g. Windows, Macintosh) there is Aladdin software to do the job.

All of the figures in my thesis (that did not represent matrices) were generated by attaching PostScript output routines to the cluster software. This ensured that the pictorial representation of various clustering characteristics could be closely monitored and easily changed, that the resulting PostScript files were small in size, and that the whole process of picture generation was transparent and easy. Two examples can be found in the aforementioned thesis section.

Apart from viewing the examples on this page in an editor, you can see actual PostScript source right away on this page in the section on Go boards and notation forms.

Spiraling mosaic

Spiral example

A mosaic induced by a tiling on a spiraling grid. In this particular drawing it is easy to play with variables such as the number of spirals, their angular speed, the width of the lines, et cetera, leading for example to this variant.

Recursive tiling in squares

Tiling in squares

Tiling in squares. A recursive tiling based on a tiling of a 112x112 square in 21 smaller square, each of a different dimension. The set of smaller dimensions being 2, 4, 6, 7, 8, 9, 11, 15, 16, 17, 18, 19, 24, 25, 27, 29, 33, 35, 37, 42, and 50. An image of the base tiling can be found on the recreational fragment.

The recursion limit in the PS tiling can be set arbitrarily, although setting it to 4 already slows down the interpreter noticeably. Another tunable is reverse video.

Hexagonal tiling of the plane

A hexagonal tiling written by Daniel C. Nygren. Very useful if you want to play around with hexagonal tilings, as I once did, and neat code too. Parameters you might want to change are indeed easily tunable.

Triangular tiling of the plane

A triangular tiling. This source is nearly trivial. For playing around with triangular tilings.

Triangular tilings overlayed

tritri

One result of playing around with the triangular tiling. This is a tiling obtained by overlaying (and applying reverse video and a line-etching trick to) three triangular tilings rotated by different angles. It is based on the fact that a triangle with sides 3, 7, and 8, has the 3\/8 angle equal to 60 degrees. Call the other angles in such a triangle a and b. Setting the overlay rotation angles to a and b gives the tiling shown here. The funny thing is that it is built from straight lines only that extend infinitely - by quite simple means, that is.

The 3,7,8 triangle is an example of an interesting family of triangles, namely those with integer sides and one angle equal to 60 or 120 degrees. It is in a sense a sibling to the family of pythagorean triangles. I'll write more about it later.

Colour spectra

A PS file with which various colour spectra can be viewed. Using the CMYK (Cyan, Magenta, Yellow, and blacK) coding, it is currently possible to vary two of the four CMYK dimensions (by hand-editing the PS-file), keeping the other dimensions fixed. The offset and range according to which the dimensions are varied can also be adjusted. This can be useful for testing color schemes on a printer device. For me it was also an exercise in programming stack rolls where the number of rolled variables is itself a variable. The next thing I will do in this direction is to make a PS file in which all of the CMYK dimensions can be varied.

Label printing

A simple Perl script, well documented within , to convert paragraph based records in a plain text file into PostScript source where the text is aligned and vertically centered in cells in a grid. Typically useful for printing addresses on labels. I hope nobody minds me using millimeters as the unit length in this particular case. Its hard to measure labels in points ..

Writing a 9x9 go board

[For a wider variety of customizable Go boards go here]

Terse PostScript program which prints a 9x9 go board with four handicap points. Below you can see what the code looks like:

%!PS
62.6 68.3 scale 1 3 translate .032 setlinewidth
0 1 8 {0 moveto 0 8 rlineto} for
0 1 8 {0 exch moveto 8 0 rlineto} for stroke
/h { .04 1 0 arc fill} def
2 2 h 2 6 h 6 2 h 6 6 h
stroke showpage

The same program can be written in a more structured and user-friendly fashion (also shown below). It has a number of variables that can be changed so that output can be adapted to different wishes. For example, you can choose between having 0, 1, or 4 handicap points appear as dots on the board, and the board can be automatically centered on the page if the paper size is European A4. Some additional work can make the program still more generic, e.g. accomodating automatic centering for other paper sizes. Being lazy and living in Europe does not help though. One thing to note is that there is unfortunately no easy and clean way to separate variables that are meant to be accessible to users from the PostScript source. This can be a bit scary - the least one can do is put all such variables in some kind of preamble that is clearly separated from the rest of the code. A second thing to note is that I have not found a convenient way to implement if .. else if .. else if .. else clauses other than in the nested fashion as shown below. This is due to the fact that the PostScript operator ifelse always takes two blocks (and a condition) as arguments.

%!PS
% (c) Stijn van Dongen.

/nrHandiPoints       4     def      % Number of handicap points (0, 1, or 4)
/HandiPointRadius    1.0   def      % Radius of handicap point in mm.
/DoA4Centering       (yes) def      % Automatic A4 paper positioning (yes/no).
/LLx                 0     def      % For non-automatic positioning (in mm).
/LLy                 0     def      % For non-automatic positioning (in mm).
/LineWidth           0.7   def      % Width of lines in mm.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

2.845 2.845 scale                   % this makes 1mm the unit size.

/bxc { 22 mul } def                 % do line arithmetic with 0..8
/byc { 24 mul } def                 % do line arithmetic with 0..8

LineWidth setlinewidth
DoA4Centering (yes) eq
{  210 22 8 mul sub 2 div
   297 24 8 mul sub 2 div
   translate
}
{  LLx LLy translate
}
ifelse

0 1 8 { bxc 0 moveto 0 8 byc rlineto} for
0 1 8 { 0 exch byc moveto 8 bxc 0 rlineto } for stroke

/handi { HandiPointRadius 1 0 arc fill } def
nrHandiPoints 4 eq
{  2 bxc 2 byc handi
   2 bxc 6 byc handi
   6 bxc 2 byc handi
   6 bxc 6 byc handi
}
{  nrHandiPoints 1 eq
   {  4 bxc 4 byc handi
   }
   {  nrHandiPoints 0 eq
      {  }
      {  0 -20 moveto
         /Courier findfont 6 scalefont setfont
         (Error: nrHandiPoints should equal 0, 1, or 4) show
      }
      ifelse
   }
   ifelse
}
ifelse

stroke showpage

19x19 Go notation forms

Notation form example The Go notation form I like best.
A standard form with south west coordinates.
A standard form with south west north east coordinates.
A standard form with no coordinates.

The latter three forms are derived from the same PostScipt source by different parameter settings. Both types of forms are highly customizable. The `form I like best' does not feature coordinates. It can be easily added, and I will do so on request.

I find the usual forms such as the three above very weird. After writing down a game all the intersections make it look as if it was all wrong, crosses here, there, and everywhere. The point in case here is that the intersections make it hard to visualize the game on the form, both while writing down a game and while replaying it. So in the first form given above you find stone shadows on each spot. By drawing the circle outline after writing down the move's number a much nicer effect is obtained IMHO. Many parameters can be varied easily, such as the size of the form, various grey shades, the `stone shadow' size, and the line width.

Ascii to PostScript tsume-go converter

Atsume (tentative name) is a Perl script that converts tsume-go problems in ascii format to PostScript output. It can be used for fast generation of pretty looking tsume-go problems (see below!). Atsume handles arbitrarily many problems per input file, and puts them onto a neatly aligned grid. Tsume-go problems are denoted using a simple ASCII-style notation, which may take many forms. Atsume splits a file into paragraphs, and assumes that each paragraph denotes a tsume-go problem. It produces PostScript output that is controlled by many user-definable parameters.

Currently atsume does not produce multiple pages, but in the next update it will indeed. Another shortcoming is that alignment takes place relative to the top right of each tsume-go problem, meaning that output looks great if all problems are situated in the upper right corner or on the upper side, but looks funny otherwise. This will be fixed soon also.

The reason for using ASCII input, rather than using the SGF format and adding to a chain of existing tools, is that I want

Below you find a sample of example output produced by atsume. Note that it is a rastered derivative of the original output, so it does not look nearly as good. This is because browsers generally do not support PostScript images.

Tsume-go output

Below you find four different types of input; all four yield the same PostScript output. You'll find a sample of the PostScript output below.
Atsume input examples

 -----
 .#.O.|
 .#.O.|
 .#O..|
 #.#O.|
 ..#O.|
 ...##|
 ..#..|

   

 ----------
 . # . O . |
 . # . O . |
 . # O . . |
 # . # O . |
 . . # O . |
 . . . # # |
 . . # . . |

   

     -
  #.O.|
  #.O.
  #O..
 #.#O.
   #O.
   .##
   #  

   
orientation[tr]
whitechar[o]
blackchar[*]
  * o  
  * o  
  *o   
 * *o  
   *o  
    ** 
   *   
   

All four examples above, when input to atsume, result in the same PS output. Below you see a rastered (PNG) image giving an impression of the PS output (generated using pstoimg, a shell around GhostScript and the Netpbm tools). Some details were lost, such as the greater thickness of the border lines. Suggestions for improvement are welcome.

Tsume-go output

Atsume has a README too. The main thing you need to know is that atsume is now entirely paragraph based, meaning that no empty lines are allowed to occur within a single tsume-go problem. There are currently three keywords that can be used in a tsume-go problem. These are orientation[..], whitechar[X], and blackchar[Y]. Atsume's command-line help is now existent and useful.

Resources

Some people link to this page, and when I check I usually find some other gems, either on the page itself, or links to them. It seems that PostScript pages have the old-style tendency to slowly amass the same set of links into a complete graph.

At this point I should add that the style of PostScript programming in most of the entries on this page might be a bit blunt, which is not necessarily bad of course. I've seen some very elegant and exquisite PostScript code on pages elsewhere. Here goes.

Back to Stijn's index page.