1 introduction to postscript sep. 21 dae-eun hyun 3d map lab

13
1 Introduction to Introduction to PostScript PostScript Sep. 21 Dae-Eun Hyun 3D MAP Lab.

Upload: percival-bates

Post on 18-Jan-2018

215 views

Category:

Documents


0 download

DESCRIPTION

3 Syntax of Postscript Postscript commands obtain parameters from the stack. Postfix notation : mul Data types such as reals, booleans, arrays and strings. User space resolution : 1 dot = 1 / 72 inch

TRANSCRIPT

Page 1: 1 Introduction to PostScript Sep. 21 Dae-Eun Hyun 3D MAP Lab

1

Introduction to Introduction to PostScriptPostScript

Sep. 21 Dae-Eun Hyun

3D MAP Lab.

Page 2: 1 Introduction to PostScript Sep. 21 Dae-Eun Hyun 3D MAP Lab

2

What is Postscript?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

Page 3: 1 Introduction to PostScript Sep. 21 Dae-Eun Hyun 3D MAP Lab

3

Syntax of PostscriptSyntax of Postscript• Postscript commands obtain parameters

from the stack.• Postfix notation : 32 14 mul• Data types such as reals, booleans, arra

ys and strings.• User space resolution :

1 dot = 1 / 72 inch

Page 4: 1 Introduction to PostScript Sep. 21 Dae-Eun Hyun 3D MAP Lab

4

Drawing with Postscript Drawing with Postscript 11

• Line drawingnewpath : empties the current path.

x y moveto : moves to the (x,y) position. x y lineto : constructs path from the previ

ous position to the position (x,y). stroke : makes the line visible by stroke showpage : makes the page visible

Page 5: 1 Introduction to PostScript Sep. 21 Dae-Eun Hyun 3D MAP Lab

5

Drawing with Postscript Drawing with Postscript 22

• Example newpath 144 72 moveto 0 216 rlineto 288 –216 rlineto -288 0 rlineto 10 setlinewidth stroke showpage (0, 0)(0, 0)

Page 6: 1 Introduction to PostScript Sep. 21 Dae-Eun Hyun 3D MAP Lab

6

Variables and Variables and ProceduresProcedures

• 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.

Page 7: 1 Introduction to PostScript Sep. 21 Dae-Eun Hyun 3D MAP Lab

7

Variables and Variables and ProceduresProcedures

• Example % draw a 3, 4, 5 triangle /triangle { moveto

0 3 inch rlineto4 inch 3 inch neg rlinetoclosepathfill

} def

Page 8: 1 Introduction to PostScript Sep. 21 Dae-Eun Hyun 3D MAP Lab

8

Transformations 1Transformations 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

Page 9: 1 Introduction to PostScript Sep. 21 Dae-Eun Hyun 3D MAP Lab

9

Transformations 2Transformations 2

• Example 0 inch 1 inch translate 45 rotate 0.5 0.5 scale /grayshade grayshade .2 add def grayshade setgray 0 0 triangle

Page 10: 1 Introduction to PostScript Sep. 21 Dae-Eun Hyun 3D MAP Lab

10

Text printingText 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 showshow

Page 11: 1 Introduction to PostScript Sep. 21 Dae-Eun Hyun 3D MAP Lab

11

Text printing 2Text printing 2• Example

/Times-Roman findfont30 scalefontsetfont1 inch 6 inch moveto

(Times Roman) show

Page 12: 1 Introduction to PostScript Sep. 21 Dae-Eun Hyun 3D MAP Lab

12

Curve DrawingCurve 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

Page 13: 1 Introduction to PostScript Sep. 21 Dae-Eun Hyun 3D MAP Lab

13

LoopsLoops

• Loop control operatorsstart incr end

{ body } for• Example

0.95 -0.05 0 {setgray printken 1 0.5 translate} for