190 likes | 534 Views
Introduction to PostScript. Sep. 21 Dae-Eun Hyun 3D MAP Lab. What is Postscript?. Programming language optimized for printing graphics and text Page description Language Introduced by Adobe in 1985 and Currently Version 3.0 Stack-based language. Syntax of Postscript.
E N D
Introduction to PostScript Sep. 21 Dae-Eun Hyun 3D MAP Lab.
What is Postscript? • Programming language optimized for printing graphics and text • Page description Language • Introduced by Adobe in 1985 and Currently Version 3.0 • Stack-based language
Syntax of Postscript • Postscript commands obtain parameters from the stack. • Postfix notation : 32 14 mul • Data types such as reals, booleans, arrays and strings. • User space resolution : 1 dot = 1 / 72 inch
Drawing with Postscript 1 • Line drawing newpath : empties the current path. x y moveto : moves to the (x,y) position. x y lineto : constructs path from the previous position to the position (x,y). stroke: makes the line visible by stroke showpage: makes the page visible
Example newpath 144 72 moveto 0 216 rlineto 288 –216 rlineto -288 0 rlineto 10 setlinewidth stroke showpage Drawing with Postscript 2 (0, 0)
Variables and Procedures • Variables and Procedures are declared using / and a name and ended with def. /inch {72 mul} def /grayshade 0 def • Procedures have curly braces { } around the body.
Variables and Procedures • Example % draw a 3, 4, 5 triangle /triangle { moveto 0 3 inch rlineto 4 inch 3 inch neg rlineto closepath fill } def
Transformations 1 • Affine transformation • translate : move the origin of the drawing to the (x,y) positions • rotate : rotate the coordinate system by the specified number of degrees. • scale : scale the coordinate system by the x and y scale factors
Transformations 2 • Example 0 inch 1 inch translate 45 rotate 0.5 0.5 scale /grayshade grayshade .2 add def grayshade setgray 0 0 triangle
Text printing • Postscript brings the character information from special typeface files. Times family typeface : Times Roman, Italic and Bold, etc. • How to use special font • Find the file of the font description • Set the font size and print using show
Text printing 2 • Example /Times-Roman findfont 30 scalefont setfont 1 inch 6 inch moveto (Times Roman) show
Curve Drawing • Operators for drawing curevs • arc and arcn : clockwise and anticlock. • 5 parameters for arc and arcn (x, y) of center of the arc arc radius the start angle and the end angle
Loops • Loop control operators start incr end { body } for • Example 0.95 -0.05 0 {setgray printken 1 0.5 translate} for