Postscript is a programming language originally developed by Adobe to describe images in a device independent manner.
Postscript is a stack based language (see also, Factor ), and it uses Reverse polish Notation (RPN). So, to multiply 12 and 10, you would write 12 10 mul
. I'd dabbled with Factor before, but without having an actual problem to solve in the new language, it is hard to get rid of old ways of thinking, which, in my case is Python.
The best thing about learning PS is graphics. I did not play with Logo when I learnt programming in school, but PS is giving me that chance :p
PS is so different from all the other languages that I know, it is actually fun and engaging.
Here is the first program I successfully wrote using Postscript.
Yin-Yang (earth and heaven).
%!PS % Draw Yin-yang /inch {72 mul} def /rad2 {1.5 inch} def /rad1 {3 inch} def /Times-Roman findfont 50 scalefont setfont gsave 5 inch 6.5 inch rad2 90 270 arc 5 inch 3.5 inch rad2 90 270 arcn 5 inch 5 inch rad1 270 90 arc fill 5 inch 5 inch 3 inch 270 90 arcn stroke %draw the small white circle 1 1 1 setrgbcolor 5 inch 6.5 inch 0.45 inch 0 360 arc fill %draw the small black circle 0 0 0 setrgbcolor 5 inch 3.5 inch 0.45 inch 0 360 arc fill % show message 2 inch 9 inch moveto (Hello Postscript!) show grestore showpage
Grab the output pdf.
© 2003-2011 Pradeep Gowda