Download ppt - Post script

Transcript
Page 1: Post script

PostScriptיישומי גרפיקה וראיה ממוחשבת –

ד”ר יעקב ©רובינוביץ

דף מודפס שפה לתיאור • מטפלת בשלשה סוגים של אובייקטים •

גרפיים:

טקסט•

צורות גיאומטריות•

תמונות מיובאות•

ניתן לבצע בקלות טרנספורמציות •

גרפיות של כל האובייקטים על גבי

הדף המודפס

(Rotation, scaling clipping)

Page 2: Post script

PostScriptיישומי גרפיקה וראיה ממוחשבת –

ד”ר יעקב ©רובינוביץ

דף עקרונות של ציור בדיו / בנית

מודפס: דף ריק Current Page הדף הנוכחי •

שעליו התוכנית ממקמת סימונים של

האובייקטים. בתום הגדרת הדף

הנוכחי, הוא נשלח להדפסה.

: Current Pathהמסלול הנוכחי •

מסלול שבנוי מאובייקטים גרפיים. לאחר

הגדרתו, ניתן לצייר את המסלול, למלא

אותו )בגוון או צבע( או להשתמש בו

כגבול חיתוך.

Imaging Model מודל יצירת התמונה

Page 3: Post script

PostScriptיישומי גרפיקה וראיה ממוחשבת –

ד”ר יעקב ©רובינוביץ

Device Spaceבמדפסת: •

ייחודי לכל מדפסת ומדפסת

(Current Pageבדף הנוכחי ) •מערכת קואורדינטות של המשתמש

User Coordinate System )user

space(

ע"י: ניתן לשנות את מרחב המשתמש

,Translation) (הזזה של ראשית הצירים

,(Rotation )סיבוב הצירים

עבור כל (Scaling)או שינוי קנה המידה

ציר בנפרד.

מערכת קואורדינטות

Page 4: Post script

PostScriptיישומי גרפיקה וראיה ממוחשבת –

ד”ר יעקב ©רובינוביץ

אופרטורים גרפיים – כשליש מן השפה• בזיכרון לנתונים Stackמחסנית •

)מספרים, שרשראות תווים, אופרטורים(

•Postfix Notation האופרטורים : שולפים את הנתונים מהמחסנית. לכן יש למקם את הנתונים במחסנית לפני הקריאה לאופרטור. התוצאה מוחזרת

למחסנית.סוגי הנתונים :•

Data: reals, booleans, arrays, strings

Objects: operators, dictionary, mark

עקרונות התכנות

Page 5: Post script

PostScriptיישומי גרפיקה וראיה ממוחשבת –

ד”ר יעקב ©רובינוביץ

LIFOהמחסנית עובדת במשטר •ל סוגי את כניתן למקם במחסנית •

הנתונים )מספרים, שרשראות תווים, אופרטורים(

המחסנית ופעולות אריטמטיות

12 6.3– 99 –996.312

(PS[ )1 2/ ]Font mark

mark/Font[1 2](PS)

Page 6: Post script

PostScriptיישומי גרפיקה וראיה ממוחשבת –

ד”ר יעקב ©רובינוביץ

add, subהאופרטורים • המחסנית ופעולות אריטמטיות

5 27 add

275

5 325 27 add

8.3 6.6 sub

6.68.3

8.3 1.78.3 6.6 sub

Page 7: Post script

PostScriptיישומי גרפיקה וראיה ממוחשבת –

ד”ר יעקב ©רובינוביץ

המחסנית ופעולות אריטמטיות

13 18 div => 1.625

25 3 idiv => 8

12 10 mod => 2

6 8 mul => 48

-27 neg => 27

sqrt, exp, ceiling, sin…

Page 8: Post script

PostScriptיישומי גרפיקה וראיה ממוחשבת –

ד”ר יעקב ©רובינוביץ

פעולות אריטמטיות מורכבות יותר6( + 3 : 8)

.375 6

8 6.3758 div add

8( – 7 X 3)

div 6 add38

63

36

218

8 -138 exc

hsub

mul submul3

37

2121

78

Page 9: Post script

PostScriptיישומי גרפיקה וראיה ממוחשבת –

ד”ר יעקב ©רובינוביץ

Stack operators פעולות מחסנית נוספות

6 8 12 clear_ >=

6 dup => 6 6

17 8 pop => 17

7 8 9 3 1 roll => 9 7 8

7 8 9 3- 1 roll => 8 9 7

Page 10: Post script

PostScriptיישומי גרפיקה וראיה ממוחשבת –

ד”ר יעקב ©רובינוביץ

User Coordinate System )user

space(

1 = ”72 points

newpath

144 72 moveto

144 432 lineto

stroke

showpage

פעולות גרפיות - מערכת קואורדינטות

144

72

0,0

432

Page 11: Post script

PostScriptיישומי גרפיקה וראיה ממוחשבת –

ד”ר יעקב ©רובינוביץ

newpath

72 216 moveto

144 72 rlineto

144 288 moveto

0 -216 rlineto

stroke

showpage

פעולות גרפיות

72

216

144

288

Page 12: Post script

PostScriptיישומי גרפיקה וראיה ממוחשבת –

ד”ר יעקב ©רובינוביץ

newpath

270 360 moveto

0 72 rlineto

72 0 rlineto

0 -72 rlineto

-72 0 rlineto

4 setlinewidth

stroke

showpage

פעולות גרפיות

Page 13: Post script

PostScriptיישומי גרפיקה וראיה ממוחשבת –

ד”ר יעקב ©רובינוביץ

newpath

270 360 moveto

0 72 rlineto

72 0 rlineto

0 -72 rlineto

closepath

4 setlinewidth

stroke

showpage

פעולות גרפיות

Page 14: Post script

PostScriptיישומי גרפיקה וראיה ממוחשבת –

ד”ר יעקב ©רובינוביץ

newpath

270 360 moveto

0 72 rlineto

72 0 rlineto

0 -72 rlineto

closepath

fill

showpage

פעולות גרפיות – מילוי צורות

Page 15: Post script

PostScriptיישומי גרפיקה וראיה ממוחשבת –

ד”ר יעקב ©רובינוביץ

newpath

270 360 moveto

0 72 rlineto

72 0 rlineto

0 -72 rlineto

closepath

.5 setgray

fill

showpage

פעולות גרפיות – מילוי צורות

Page 16: Post script

PostScriptיישומי גרפיקה וראיה ממוחשבת –

ד”ר יעקב ©רובינוביץ

newpath %Begin black box 252 324 moveto 0 72 rlineto 72 0 rlineto 0 -72 rlineto closepathfillnewpath % gray box 270 360 moveto 0 72 rlineto 72 0 rlineto 0 -72 rlineto closepath .4 setgrayfill

פעולות גרפיות – מילוי צורות

newpath % light

288 396 moveto

0 72 rlineto

72 0 rlineto

0 -72 rlineto

closepath

.8 setgray

fillshowpage

Page 17: Post script

PostScriptיישומי גרפיקה וראיה ממוחשבת –

ד”ר יעקב ©רובינוביץ

Dictionaries Key Key’s value

system dictionary Operator Action

user dictionary Name Variable Name Procedure

/ppi 72 def/inch {72 mul} def/inch {ppi mul} def

5 72 mul5 inch

Procedures and Variablesשגרות ומשתנים

Page 18: Post script

PostScriptיישומי גרפיקה וראיה ממוחשבת –

ד”ר יעקב ©רובינוביץ

%---- Define procedures ----/ppi 72 def/inch {ppi mul} def /box %stack:x y => ---{newpath moveto 1 inch 0 rlineto 0 1 inch rlineto -1 inch 0 rlineto closepath} def/fillbox %stack: grayvalue => --- {setgray fill} def% ---------Main Program---------- 3.5 inch 4.5 inch box 0 fillbox 3.75 inch 5 inch box .4 fillbox 4 inch 5.5 inch box .8 fillbox showpage

פרוצדורות – מילוי צורות

Page 19: Post script

PostScriptיישומי גרפיקה וראיה ממוחשבת –

ד”ר יעקב ©רובינוביץ

/Times-Roman findfont 30 scalefont setfont/square %procedure to draw a{ newpath % filled square 0 0 moveto 90 0 lineto %define a square path 90 90 lineto 0 90 lineto closepath fill %fill it 6 92 moveto % & label it (A Box) show } def

square %do a square200 250 translate %move coord. sys.square %do another square200 250 translate %and move againsquare %do a third squareshowpage

גרפיקה – טרנספורמציות במערכת הקואורדינטות

Page 20: Post script

PostScriptיישומי גרפיקה וראיה ממוחשבת –

ד”ר יעקב ©רובינוביץ

square %do a square300 150 translate %move coord sys.60 rotate %and rotate itsquare %do it again . . .300 150 translate60 rotatesquare %do a third squareshowpage

גרפיקה – טרנספורמציות במערכת הקואורדינטות

Page 21: Post script

PostScriptיישומי גרפיקה וראיה ממוחשבת –

ד”ר יעקב ©רובינוביץ

square %do a square100 100 translate 1.5 1.5 scale square 100 100 translate .75 1.25 scale %non-uniform scaling squareshowpage

גרפיקה – טרנספורמציות במערכת הקואורדינטות

Page 22: Post script

PostScriptיישומי גרפיקה וראיה ממוחשבת –

ד”ר יעקב ©רובינוביץ

/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

גרפיקה – שמירת המצב הגרפי )המסלול הנוכחי(

% --main program----newpath200 200 starshowpage

Page 23: Post script

PostScriptיישומי גרפיקה וראיה ממוחשבת –

ד”ר יעקב ©רובינוביץ

/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

גרפיקה – שמירת המצב הגרפי )המסלול הנוכחי(

% --main program----newpath200 200 starshowpage