PostScript adaptation
In October of last year, I posted a PostScript note bar snippet that I wrote about a year or so ago, on my blog. I've since received in private mail quite a number of requests to adapt it to other page sizes (letter, A5, whatnot). I've always kindly explained people that I think the numbers are self-evident and that this isn't hard, and what the numbers mean anyway, and that they should try to read some PostScript tutorial, but I'm sick of it now; I can't keep doing this. So, for everyone interested, here's the explanation. Please update your bookmarks, if you have any.
For reference, the entire code snippet again:
%!PS 50 75 moveto 1 1 13 { 1 1 5 { 500 0 rlineto -500 5 rmoveto } for 0 30 rmoveto } for stroke showpage
Now, what do the numbers mean? Line by line:
- 50 75 moveto
- moves the PostScript cursor (or whatever it's called) to a point 50 units from the left side of the page, and 75 units from the bottom.
- 1 1 13 {
- The following is a code block with three numbers as the argument. The block ends with } for, so it's a counting loop which is started at one, incremented by one, and ended when 13 is reached. Meaning, there are 13 note bars on one page. Adjust if you have space for more note bars on a page.
- 1 1 5 {
- Another loop; this time to make sure a single note bar consists of five lines. You don't want to touch this, except if you're going to write some gregorian music or so.
- 500 0 rlineto
- Draws a line from the current point on the page to 500 postscript units to its right. Adjust if your page size is wider or smaller than A4.
- -500 5 rmoveto
- Moves the postscript cursor back to the left end of the page, but 5 postscript units above our previous location (so that the next line will be drawn slightly above the previous one). Adjust accordingly to the one above; adjust the 5 if you want more or less space between two lines of a single note bar.
- 0 30 rmoveto
- Moves the postscript cursor another 30 units up, once the complete note bar of 5 lines has been drawn. Adjust if you want more or less space between two note bars.
The rest (%!PS, stroke and showpage) are PostScript language constructs that are necessary if you want to get the correct output. Ignore them.