Presentation is loading. Please wait.

Presentation is loading. Please wait.

Page description language from Adobe

Similar presentations


Presentation on theme: "Page description language from Adobe"— Presentation transcript:

1 Page description language from Adobe
Postscript Page description language from Adobe

2 Copyright 2000, Georgia Tech
Story History Basics Paths Drawing simple geometric shapes Working with Coordinate Systems Drawing ellipses Ghostscript and GSview 11/19/2018 Copyright 2000, Georgia Tech

3 Copyright 2000, Georgia Tech
History Before Postscript (pre 1984) Dot matrix printers with poor quality output High quality printers with proprietary languages John Warnock at Xerox Parc created Interpress Couldn’t convince management to sell it Left Xerox and created Adobe with his old boss Abode created Postscript (1984) First used with Apple LaserWriter and Aldus PageMaker Desktop publishing took off See for more of the history. Dot matrix printers are like a computer screen in that the printer has a resolution of dots (pixels) per inch. John Warnock and Chuck Geschke were the founders of Adobe. For years the Apple LaserWriters had faster processors than the Macs they were connected to. 11/19/2018 Copyright 2000, Georgia Tech

4 Copyright 2000, Georgia Tech
What is Postscript? A language for printing text and graphics. Advantages Device independent Manufactures license the interpreter Specifications are freely available Levels 1 (1985), 2 (1994), and 3 (1998) 11/19/2018 Copyright 2000, Georgia Tech

5 Copyright 2000, Georgia Tech
Basics Interpreted, stack-based language like FORTH 3 4 add Put 3 on the stack Put 4 on the stack add takes the top two items off the stack and adds them and puts the result on the stack This is also called postfix notation. 11/19/2018 Copyright 2000, Georgia Tech

6 Postscript files are Text
Postscript is written in ASCII characters Use % for comment % draw a vertical line newpath moveto lineto stroke showpage Using GSView to View x is 3 inches from left y is 6 inches from bottom x is 3 inches from left y is 4 inches from bottom 11/19/2018 Copyright 2000, Georgia Tech

7 Default Coordinate System
Origin is lower left corner of page X increases to left Y increases going up Units are 1/72 inches So 72 units in an inch Origin 11/19/2018 Copyright 2000, Georgia Tech

8 Copyright 2000, Georgia Tech
Like Drawing by Hand Start with the current page being empty Draw things on the page Things drawn on top of other things will obscure them When you are done send the page to the printer 11/19/2018 Copyright 2000, Georgia Tech

9 Copyright 2000, Georgia Tech
Postscript uses Paths What is a path? Set of connected and disconnected points, lines, and curves that describe shapes and their positions 11/19/2018 Copyright 2000, Georgia Tech

10 What can you do with a Path?
A path can be Stroked (like using a pen to draw it) Filled (like using a paint can to fill it) Used as a clipping boundary (like using a stencil) 11/19/2018 Copyright 2000, Georgia Tech

11 Copyright 2000, Georgia Tech
Defining a Path Use newpath to start a path newpath Use moveto to move the pen to a point on the page (but nothing draws yet) moveto Use lineto to create a line from the previous point to the current point lineto 11/19/2018 Copyright 2000, Georgia Tech

12 Disconnected Path Example
This will draw two unconnected lines newpath 72 72 moveto rlineto moveto 0 -72 rlineto stroke showpage Using GSView to View 11/19/2018 Copyright 2000, Georgia Tech

13 Copyright 2000, Georgia Tech
Relative Positioning Using rlineto uses the x and y as relative to the current position Positive values X right Y up Negative values X left Y down Can use rmoveto as well To move relative to the current position -x +y +x+y -x -y +x-y 11/19/2018 Copyright 2000, Georgia Tech

14 Copyright 2000, Georgia Tech
Drawing a Rectangle newpath moveto 0 72 rlineto 144 0 rlineto 0 -72 rlineto rlineto stroke showpage second third first The moveto moves the pen to 3.75 inches from left and 5 inches from the bottom of the page. The 0 72 rlineto draws a 1 inch line up from that position in y. The draws the top of the rectangle going 2 inches to the right. The draws the right side of the rectangle by going down 1 inch in y. The draws the bottom of the rectangle by going left in x 2 inches. fourth start 11/19/2018 Copyright 2000, Georgia Tech

15 Copyright 2000, Georgia Tech
Drawing a Polygon newpath moveto lineto lineto lineto lineto closepath stroke showpage 11/19/2018 Copyright 2000, Georgia Tech

16 Copyright 2000, Georgia Tech
Closing the Polygon Use closepath to go from last point to the last moveto point does a mitered join lineto lineto lineto moveto closepath lineto lineto 11/19/2018 Copyright 2000, Georgia Tech

17 Working with Coordinates
The default user coordinates are at the bottom left of the current page But the user coordinates can be Translated – moves the origin x y translate Scaled – change the size of the units x y scale Rotated – rotates the axes counterclockwise angle rotate 11/19/2018 Copyright 2000, Georgia Tech

18 Copyright 2000, Georgia Tech
Graphics State What is in the graphics state? Current path, gray value, line width, user coordinate system Save the state to return to it later gsave Restore a saved state grestore 11/19/2018 Copyright 2000, Georgia Tech

19 Copyright 2000, Georgia Tech
Using Graphics State newpath moveto 0 72 rlineto 144 0 rlineto 0 -72 rlineto rlineto gsave .5 setgray fill grestore stroke showpage Save current graphics state The fill command clears the current path. So, we save the current path with gsave and restore it to outline the border of the rectangle. Clears current path Restore the saved graphics state including path 11/19/2018 Copyright 2000, Georgia Tech

20 Copyright 2000, Georgia Tech
Drawing Arcs The arc operator draws arcs (and circles) Center is at centerX and centerY Radius of radius Arc drawing starts at beginAngle from x axis and counter clockwise to endAngle centerX centerY radius beginAngle endAngle arc Example: arc The example starts at 0 degrees from the x axis, so on the x axis and goes counterclockwise to 90 degrees. The center is at 300 in x and 365 in y with a radius of 100 units. You can also draw arcs clockwise using arcn. 11/19/2018 Copyright 2000, Georgia Tech

21 Copyright 2000, Georgia Tech
Drawing a Circle Use arc with a begin angle of 0 and an end angle of 360 Example arc 11/19/2018 Copyright 2000, Georgia Tech

22 Copyright 2000, Georgia Tech
How to Draw Ellipses? Use the arc operator But, first scale the user coordinate system Example newpath 1 .75 scale arc stroke showpage 1 .75 scale 1 .5 scale .5 1 scale To draw a ellipse you draw a circle but first scale the user coordinate system to match the ratio of the width to the height. 11/19/2018 Copyright 2000, Georgia Tech

23 Copyright 2000, Georgia Tech
Defining Variables Use the def operator to define variables /ppi 72 def % define the points per inch var 10 ppi mul % multiply 10 * 72 /ppi ppi 1 add def %add 1 to current value The /ppi means put the literal on the stack and don’t look up the value of it in the dictionary 11/19/2018 Copyright 2000, Georgia Tech

24 Postscript Dictionaries
Map keys to values System dictionary Maps predefined operators to actions User dictionary Maps names to user defined variables and procedures Looks in user dictionary first then system You can actually create more dictionaries. 11/19/2018 Copyright 2000, Georgia Tech

25 Copyright 2000, Georgia Tech
Procedures A procedure is a set of operations grouped together with a name It is stored in the user dictionary with the name as the key and the operations as the value Example /inch {72 mul} def 5 inch (results in 5 * 72) 11/19/2018 Copyright 2000, Georgia Tech

26 Copyright 2000, Georgia Tech
Creating a Procedure Create a box procedure /box { 72 0 rlineto 0 72 rlineto -72 0 rlineto closepath} def 11/19/2018 Copyright 2000, Georgia Tech

27 Copyright 2000, Georgia Tech
Using a Procedure newpath moveto box moveto box moveto box stroke showpage 11/19/2018 Copyright 2000, Georgia Tech

28 Copyright 2000, Georgia Tech
Printing Text Find the font in the font dictionary Returns a one-point size font Scale the font to the desired size Size is specified by the minimum vertical separation needed between lines of text 12 point font needs 12 points between lines of text A point is 1/72 of an inch Set the scaled font to the current font Show the text 11/19/2018 Copyright 2000, Georgia Tech

29 Copyright 2000, Georgia Tech
Fonts and Typefaces What is a font? A collection of characters with a unified design. An implementation of a typeface. Typeface The design used in a font Typeface families A set of typefaces designed to work together Examples: Times-Roman, Helvetica, Courier 11/19/2018 Copyright 2000, Georgia Tech

30 Copyright 2000, Georgia Tech
Example with Fonts % show ‘Hello World’ in times roman /Times-Roman findfont 24 scalefont setfont moveto (Hello World) show showpage 11/19/2018 Copyright 2000, Georgia Tech

31 Copyright 2000, Georgia Tech
Postscript Operators Add 3 4 add → 7 Subtract 8 4 sub → 4 Multiply 6 8 mul → 48 Divide 13 8 div → 1.625 11/19/2018 Copyright 2000, Georgia Tech

32 Copyright 2000, Georgia Tech
Stack Operators clear Removes all items from the stack 6 7 8 clear → nothing on stack dup Duplicates the top item on the stack 6 7 8 dup → pop Remove the top item from the stack 6 7 8 pop → 6 7 11/19/2018 Copyright 2000, Georgia Tech

33 Copyright 2000, Georgia Tech
Painting Operators fill Fill the current path with the current color setgray Set the current color .5 setgray (1 is white and 0 is black) setlinewidth Set the current line width (x/72 units) 4 setlinewidth % 4/72 units wide 11/19/2018 Copyright 2000, Georgia Tech

34 Copyright 2000, Georgia Tech
Ghostscript What is it? Ghostscript is an interpreter for the PostScript page description language Has 3 licenses Aladdin Free Public License (AFPL) allows free use but not commercial distribution Where to get it? There is also a GNU license version of Ghostscript. Ghostscript was originally created by L. Peter Deutsch, President of Aladdin Enterprises. 11/19/2018 Copyright 2000, Georgia Tech

35 Copyright 2000, Georgia Tech
GSview What is it? A PostScript previewer based on Ghostscript by Ghostgum Software Pty Ltd A graphical user interface for Ghostscript Where to get it? You must have Ghostscript installed to use GSview. 11/19/2018 Copyright 2000, Georgia Tech


Download ppt "Page description language from Adobe"

Similar presentations


Ads by Google