Overview What is PostScript? Types Language Concepts Control Operators Examples
What is PostScript page description language : PostScript is a programming language optimized for printing graphics and text It was introduced by Adobe in 1985 The main purpose of PostScript was to provide a convenient language in which to describe images in a device independent manner. This device independence means that the image is described without reference to any specific device features (e.g. printer resolution)
Types String : “This is a string” would be written as (This is a string). Express a string as hexadecimal codes in angle brackets. “ABC” would be expressed as. Boolean Real Array
Types Arrays: One Dimensional Object of different types in an array /arrayName [ 12 (Twelve) True] def /arrayName [ add] def /arrayName 10 array Store and Fetch array elements: put, get /anArray 10 array def anArray 8 (language) put anArray 8 get
Language Concepts Variable: /varName value def Path: A path is a collection of (possibly disjoint) line segments and curves arranged on the page. newpath moveto linto stroke showpage Dictionary: is a table that associates pairs of objects System Dictionary : operator, action User Dictionary : /var1Name Value def
Language Concepts Procedures: /inch {72 mul} def Stack: Graphic Stack Operand Stack (c lear, dup, pop, roll, pstack ) Dictionary Stack Operator: Every command in PostScript is an operator: add, mul, findfont, moveto...
Programming in PostScript Postfix Notation in PostScript : One must first place the operands on stack and then call the operator add 8 –7 * mul sub 7 3 mul 8 exch sub
Control Operators Conditional: Comparisons: Logical Operator: And, or, not, xor bool { op } if bool {op1} {op2} ifelse
Control Operator Loops: Repeat: Iteration { loop_body_expression} repeat For: Loop_counter_init_value increment_value {op} for { op }loop : end with “exit” AnArray {op} forall
/Times-Italic findfont 30 scalefont setfont /printZip { 0 0 moveto (Zip) show} def translate % start incr. end {setgray printZip -1.5 translate } for 1 setgray printZip showpage
/starside { 72 0 lineto %add line to path currentpoint translate %move origin -144 rotate } def %rotate coord. sys. /star %stack: x y { moveto currentpoint translate 4 {starside} repeat closepath gsave.5 setgray fill grestore stroke } def star
Refrences