Search code examples
postscript

How to write programmatically lines with regular angle between them in PostScript?


I was trying to go a little bit beyond in my PostScript skills and tried to write 12 phrases with 30 of angle between them.

I don't really know how to name the problem, so the title is a bit weird...

Here is where I came so far:

%!
/Times-Roman findfont 20 scalefont setfont
/r 360 12 / def

306 396 translate
0 0 moveto
(text) show

0 0 moveto
30 rotate
(text) show

0 0 moveto
30 rotate
(text) show

0 0 moveto
30 rotate
(text) show

0 0 moveto
30 rotate
(text) show

0 0 moveto
30 rotate
(text) show

0 0 moveto
30 rotate
(text) show

0 0 moveto
30 rotate
(text) show

0 0 moveto
30 rotate
(text) show

0 0 moveto
30 rotate
(text) show

0 0 moveto
30 rotate
(text) show

0 0 moveto
30 rotate
(text) show

showpage

But there are some problems with this code:

  1. it uses explicit steps instead of an iteration (although it works)
  2. all the text overwrites the others in the middle

Any help?


Solution

  • As suggested by KenS, all the code between translate and showpage can be replaced by:

    12 { 0 0 moveto (text) show 30 rotate } repeat

    If you want to avoid overlaps, use this for instance:

    12 { 50 0 moveto (text) show 30 rotate } repeat