Taking Advantage of PostScript. John F. Sherman

Size: px
Start display at page:

Download "Taking Advantage of PostScript. John F. Sherman"

Transcription

1 Tking Avntge of PostSript John F. Shermn

2

3 Tking Avntge of PostSript John F. Shermn University of Notre Dme Art, Art History & Design University of Notre Dme Notre Dme, IN

4

5 1 hpter Chpter 1 intro Designers fe new requirement: to quire n mster igitl rft. The tritionl rfts of olor theory, esign, typogrphy n rwing hve lwys een require for the esigner. All of these re importnt n I o not vote their ismissl. But the nee for igitl rft is eoming more pprent s the innovtions of tehnology rrive fster n fster. Designers, however, nnot fous on simply eing well-trine users of expensive piees of hrwre n softwre. By mstering the tehnology, they n reh point where innovtive new solutions to visul ommunition prolems n e isovere. The proess y whih n imge n e me hs hnge rmtilly. An imge n e onstrute y omintion of hn rwings, vieo pture, n omputer progrmming. The finishe imge provies solution y mens of fster investigtion, greter hoies, n new retive possiilities. Digitl rft entils lerning new lnguge visul lnguge. The greter the epth of unerstning n experiene in lnguge, the greter the vision of wht n exist in the min of the retor. Different lnguges llow ifferent relities to exist. Mny of the imges rete for this ook re visul ies tht hve een me into imges y writing them own. They n only e hieve y n intimte knowlege of the PostSript lnguge. I fin it exiting tht there re imges tht n only e rete y writing PostSript progrm. Unerstning PostSript is one mjor venue to mstering the tehnology of prouing grphis. 1.1 why lern PostSript? Why lern PostSript when there re so mny goo grphis progrms ville tht re muh esier to use thn progrmming? There re two nswers. First, knowing the PostSript Pge Desription Lnguge (PDL) gives the esigner n insight into grphis softwre se on the PostSript imge moe. The PostSript PDL hs strengths n weknesses. Hving this knowlege se uils onfiene euse it permits you to work with the strengths of softwre n not with flse expettions. When something oes not work s expete, you my e le to evise wy to work roun or ttk the prolem from nother iretion. Seon, the PostSript lnguge is riher grphis lnguge thn wht is me ville y menu seletions n ilog oxes in ll the grphis softwre pkges ville. There re visul opportunities ville to you tht re only ville y progrmming. A esign you write in PostSript might supplement pkge tehnique in softwre progrm or e written totlly in PostSript oe. intro 1

6 Tking Avntge of PostSript Either wy, you re in ontrol of the esign proess. 1.2 PostSript s kgroun PostSript is pge esription lnguge evelope y Aoe Systems Inorporte. PostSript resies within printer n ts s n interpreter for the t sent to it y either softwre progrm or n originl progrm written y progrmmer. A pge esription lnguge is the mens through whih printer prepres pge ontining text, line rt, n igitize imges. The pge is onstrute pixel y pixel (ot y ot). The size of ot will epen on the printer, n rnges from 300 to 2540 ots per inh (pi). A 300 pi printer will rw 1 inh squre 300 ots to sie, while 2540 pi printer will rw the squre 2540 ots per sie. Figures 1 1 n 1 2 re the sme shpe; they hve the sme esription. The otte line is the true shpe. Wht will e ifferent is the qulity of its presenttion through either printing or monitor s isply. The greter the resolution provie, the loser to the true esription the shpe will pper. figure 1 1 Figure 1 2 is the sme shpe with oule the resolution. figure 1 2 The most wiely known exmple of 300 pi printer is the Apple LserWriter. The Linotron L100 hs mximum resolution of 1270 pi n n e set to print t 600 n 300 pi. The Linotron L300 is lso ville with mximum printing resolution of 2540 pi. The vntge of using the inrese resolutions of these printers is tht greter numer of visully istint grys n e proue. The Linotron L100 n proue out one hunre visully seprte gry levels euse of its fine ot pttern. 2 intro

7 Chpter 1 The PostSript lnguge is printer inepenent, enling you to lternte from one rn of printer to nother without mking ny hnges to the originl oument. All the mjor originl equipment mnufturers of high resolution printers hve liense PostSript for their printers mking it the e fto inustry stnr. The esigner n use low ost lser printer for skething n then lter use the more ostly high resolution imgesetters when the esign is omplete. The ifferene in the resolution hnges the renering qulity n the numer of istint grys tht n e epite. Until reently, lser printer equippe with PostSript interpreter ws the only mens to see the esigns rete y writing PostSript progrms. Disply PostSript is n pttion of the PostSript PDL from Aoe Systems In. for use on omputer monitors, n the NeXT omputer is the only omputer tht uses it. Disply PostSript is to the grphi isply of omputer monitors s the PostSript PDL is to ifferent lser printers. It provies ommon imging moel for the grphi isply (sreen esription lnguge) n the lser printer. The Mintosh uses the QuikDrw lnguge for its sreen isply n file s t is onverte from QuikDrw to PostSript for printing. Beuse of this, the full rihness of the PostSript lnguge nnot e use n then viewe on the Mintosh sreen. Disply PostSript is monitor inepenent n utomtilly tkes vntge of the full pilities (gry levels or olor) of the omputer s monitor without hving to rewrite the prt of the softwre responsile for the grphi isply. Disply PostSript hs severl vntges. Most importntly, wht is seen on the sreen very losely mthes wht is printe. The only ifferene is the resolution of the imge on the monitor ompre to the resolution of the imge ultimtely printe on the lser printer. For exmple, in rwing 1 inh squre, the squre woul e rwn with ninety-two pixels per sie (resolution of the NeXT monitor) n the sme informtion woul e use gin n sent to the lser printer to rete the squre t 300 pi or more. 1.3 orgniztion of this ook Tking Avntge of PostSript is ivie into four mjor prts. Chpters 2 7 of this ook will introue some si PostSript onepts n rwing tehniques. Chpter 4 will show how these simple progrms n e sve s EPS files to e use within other progrms. Most of the simple eginning progrms re more esily rwn in vriety of grphis softwre progrms, ut they re the uiling loks to the more omplite progrmming tehniques tht ome in lter hpters. Chpters 8 17 will over vne PostSript tehniques tht unlesh the power of the PostSript Pge Desription Lnguge. Muh of wht is overe here nnot e omplishe in ville grphis softwre. Chpter 17 overs some vne progrmming tehniques n tkes severl esigns step y step n explins how n why they were written s they re. Chpter 18 will touh on some of the new fetures of PostSript Level 2. Chpters 19 n 20 of this ook re lirries of numerous exmples of PostSript progrms tht n e the strting point for new esigns. They generlly onentrte on one visul ie or progrmming tehnique. Chpter 21 is gllery of imges. The finl setion of the ook ontins severl referene ppenixes. intro 3

8 Tking Avntge of PostSript 1.4 lern PS 1 1 nimtion formts use in this ook The min nrrtive of this ook is in the font you re now reing. All PostSript progrm listings or the mention of PostSript opertor will e set in Courier Bol n look like this: PostSript oe % omment Notes or omments (expline in more etil in setion 2.5) will e set in regulr Courier to help set them off from the progrm. At times, when more lengthy nnottion is require, I ll rket the explntion like this for etter legiility n to sve spe: % Extene omments; not prt of the progrm. % When you see this symol in the mrgin, it mens tht the PostSript progrm is ville on isk for experimenttion within the ompnion LernPS tutoril. There will e version for oth Mintosh n NeXT omputers. The LernPS symol my lso inite tht the PostSript progrm for n illustrtion is ville or tht n nimtion emonstrting prtiulr point is ville. Use the numer or title elow the symol to help you lote the file in LernPS. Most of the PostSript exmples in this ook re written to pper on gri representing the ottom left orner of pge. A PostSript progrm will e liste elow the grphi it proues. In this wy, it will serve s title for the grphi. Otherwise, grphi title will e foun in the left mrgin. Eh hpter is ivie into setions. We re now in setion 1.4, mening hpter 1 setion 4. Often in this ook I ll refer to other setions using this system. 1.5 getting strte Writing simple originl PostSript progrm is firly esy tsk to omplish. You most likely lrey hve the tools neee if you hve Mintosh omputer n PostSript equippe printer. The progrm file n e written with ny wor proessing progrm tht n sve stnr ASCII text files. An ASCII text file is stnr form of sving text tht ll omputers unerstn. It nnot, however, ontin speilize formtting tht most pplitions provie, suh s vrile point sizes, font styles, or grphis. On the Mintosh you will nee: Softwre to write the progrm. Mirosoft Wor, MWrite, WriteNow n others will work fine. You my fin it onvenient to use text eitor esigne for working only with text files. A utility to sen the file to the PostSript printer. The most ommon is SenPS from Aoe. A PostSript equippe printer, to interpret your files. On the NeXT: The NeXT omputer omes with ll the softwre you ll nee to sen the file to 4 intro

9 Chpter 1 the printer or monitor. Chpter 2 overs getting strte in more etil. 1.6 options for ownloing files There re quite few utilities to sen or ownlo PostSript file to printer. On the Mintosh I hve use these, ut there re mny others: LserSttus DA from CE Softwre SenPS from Aoe Systems Downloer from Aoe Systems I hve two fvorite wys of working on the Mintosh. One option is to write the file using QUED (QUlity EDitor) from Promp. QUED is text eitor; it only opens n sves files s text. I then sen the PostSript file to the printer with LserSttus. Sine LserSttus is Desk Aessory, I n esily swith k n forth etween eitor n ownloer while eveloping esign. It looks like this elow: The seon metho is gin to use QUED to write the progrm, ut sen the file to the printer using either Aoe s SenPS or Downloer. The primry ifferene etween the two utilities is where the stnr output file is irete. This file my e n error messge or feek from the printer. With SenPS, the error messges n feek re sent to file on your omputer s isk. This is hny sine t times the messge n flsh y quikly or you my nee the informtion tht is sent k. The vntge of Downloer is tht those messges re sent to winow on the Mintosh sreen. The stnr output file will ome up numer times lter in setion 16.1 n the utilities ppenix. You will e le to sen PostSript files to your printer from within LernPS. intro 5

10 Tking Avntge of PostSript 6 overview of the sis

11 2 hpter Chpter 2 overview of the sis This setion is esigne to over the key points n terms use in PostSript progrmming. Even if PostSript is your first ttempt t writing omputer progrm, you shoul fin PostSript is not nerly s intimiting to lern s other progrmming lnguges. I elieve the reson for this is tht the gol is to get n imge on pper, whih is muh more interesting thn lulting some interest rte or personnel t se. Plus, the Hello Worl output, the lssi first gol in other progrmming tutorils, n now e in vriety of fonts n ple nywhere on the pge. 2.1 oorinte system The pge is oorinte system se on n x n y xis. The origin, the 0 0, is usully the ottom left orner of the pge. We ll see lter tht this n e hnge t ny time. y xis figure x xis Distne is mesure in points with 72 points equling n inh. Eh squre ove in figure 2 1 represents 36 points. This is silly the sme unit of mesurement use y typesetters n printers in the grphi rts inustry. Tritionlly 72 points equls of n inh. In PostSript, however, 72 points equls 1 inh extly. In some situtions this ifferene n use gret el of troule. If it is importnt tht you mth the tritionl mesurement sle, the oorinte overview of the sis 7

12 Tking Avntge of PostSript system n e hnge so tht 72 points oes equl of n inh. This n e one with the sle opertor (see hpter 10). 2.2 the PostSript progrm must e text file The PostSript progrm must e text file, sometimes known s n ASCII file. A text file n e written y lmost every kin of wor proessor. A text file is n gree on stnr formt of sving wors tht ll omputers n ept n unerstn. Beuse it is onvenient mens to exhnge informtion etween vrious omputers, it nnot ontin speilize formtting tht is hnle ifferently from one wor proessing pplition to nother. A text file nnot ontin vrile font styles, point sizes, or ny grphis. It n ontin rrige returns, n ts re t fixe, regulr intervls. If you re using Mirosoft Wor on the Mintosh, text file woul e sve y first hoosing Sve or Sve As... (if lrey sve) from the File menu. Notie the File Formt... utton t the lower left orner. Choose it. A seon ilog ox will pper. Choose the Text Only option n then OK. The file will e sve s text. MWrite n other progrms hve similr options. You my try text eitor tht only sves n works with text files. Their vntge is they usully ome with fetures gere for esier progrmming. 2.3 PostSript is se sensitive The PostSript lnguge is se sensitive. Cse sensitive mens upperse hrters re seen s ifferent thn lowerse hrters. Tht is, wor is seen s ifferent wor thn WORD or Wor. In some other progrmming 8 overview of the sis

13 Chpter 2 lnguges this is not the se. 2.4 the progrm formt A PostSript progrm n e formtte in ny wy onvenient for legiility using ts, returns, or extr spes etween wors. These re seen s white spe n o not ffet the running of the progrm. For exmple, gsve trnslte grestore is the sme s gsve trnslte grestore whih is the sme s gsve trnslte grestore 2.5 inserting omments Titles n referene omments n e inlue in PostSript progrm y entering them fter the speil hrter % (perent sign). Everything following % n efore the next return or line en is invisile to the PostSript interpreter. The % is lso use for heer informtion (the first lines of progrm) of file tht is written in stnr wy. This will e expline further in hpter 4, EPS Files. The spe etween the oe n the % n either e ts or ny numer of wor spes. It s goo hit to inlue omments in your progrms for future referene. A month from now, you won t rememer why you i wht you i. A few moments of your time now will py off lter when you nee the informtion. Exmples of inserting omments re % move origin one inh gsve trnslte grestore The omment n lso e inserte in this wy, gsve % move origin one inh trnslte grestore or in this wy gsve trnslte % move origin one inh grestore overview of the sis 9

14 Tking Avntge of PostSript 2.6 the grphi stte Mny of the ommns in PostSript esrie some kin of grphi opertion or hnge in the grphi stte. The grphi stte is the set of givens or the environment grphi is rwn in. For exmple, it woul e sfe to ssume the following: The mesurement system equls 72 points to the inh. The origin is t the lower left orner of the pge. The efult olor is lk. The efult line weight is 1 point. There is no efult font. These re some of the efult vlues tht efine the grphi stte tht you egin with. There is possiility tht previous PostSript progrm my hve hnge ll this, ut normlly these efults re in effet. If you rw 72 point fille squre, it will e fille with lk n e 1 inh squre unless efine otherwise. There re severl more efult vlues to e wre of, ut these re enough to get strte with. The importnt onept here is tht s PostSript progrm is interprete y printer, urrent vlues for numer of things (olor, line weight, et.) n e hnge, n persist until nother hnge. These hnges re hnges in the grphi stte. 2.7 the urrent point & urrent pth Grphis n type re ple on the pge y estlishing urrent point. The urrent point is the urrent position of rwing tion. Estlishing urrent point n e thought of s the initil t of positioning penil on pper to egin rwing. The moveto opertor retes the lotion for hrter or the strting point for the rwing of grphi. This is mesure reltive to the origin or 0 0 (zero zero) of the oorinte system. For exmple, moveto estlishes urrent point 2 inhes to the right n 3 inhes up from the lotion of the origin. There is nothing tht will print yet, it is only the strting point or lotion. More on moveto lter in setion 2.9. If line is rwn from this urrent point lote t , moveto lineto urrent pth is rete from the point to the point Agin, nothing will print yet euse it is only pth. The pth will nee to e pinte for something to print. The urrent pth n e pinte s stroke to give it the vlues of the urrent line weight n olor, or the pth my e fille with the urrent olor. As pth is rete, the urrent point is the most reent point on the pth. One 10 overview of the sis

15 Chpter 2 the pth is pinte, the pth is lere or initilize. These re importnt points to rememer. A typil sequene of events oul e: 1 No urrent point or urrent pth 2 Crete urrent point 3 Crete urrent pth 4 stroke or fill the urrent pth 5 Current pth is lere 2.8 the opern stk PostSript is stk se lnguge. An opern stk is like plte ispenser t feteri. The first plte in is the lst plte out n the lst plte in is first plte out. In PostSript, the stk is n re of memory tht vlues, opertors, n other items re pushe onto. The first item in line of PostSript oe will e the first item on the stk n the lst to e use. For exmple, moveto will nee two numers lrey on the stk. In the se of moveto, 144 is on the ottom n 216 is next on top. moveto, the opertor, then omes long on top of the two numers n removes them to go off n mke urrent point. The lines of oe lern PS stk emo moveto lineto oul e seen entering the stk s in figure 2 2 elow moveto lineto figure 2 2 Another wy of looking t moveto lineto woul e to hrt the stk s it hnges. In figure 2 3, eh white retngle represents the stk s vlues re pushe onto it n remove y opertors. overview of the sis 11

16 Tking Avntge of PostSript moveto empty stk lineto empty stk figure 2 3 The progrm oul lso e written like this: moveto lineto It woul proue the sme results n the hrt woul look like figure moveto lineto empty stk figure 2 4 This is not s onvenient wy to write progrm, ut it works. It n e esy to lose trk of whih vlues go with wht opertor. There re numer of PostSript opertors tht help mnipulte the orer of the stk. exh, for exmple, swithes the top two items on the stk. More on this in lter hpters. 2.9 reting urrent point As stte in setion 2.7, moveto is use to rete urrent point n expets two numers on the stk for its x n y lotion on the pge. The syntx for moveto is x y moveto The x n y n e ny two numers, positive or negtive. For exmple, the following n e use: moveto moveto moveto Lter we ll lern to use vriles so we n write over up moveto x1 y2 moveto 12 overview of the sis

17 Chpter 2 1 inh 2 inh moveto or even x 12 y 12 moveto The moveto opertor expets to fin two numers witing for it on the stk. How they rrive there is of no onern to it. figure 2 5 The + s in the grphi in figure 2 5 mrk the lotion of the urrent points t n with moveto n moveto. A vrition of moveto is rmoveto or reltive moveto. rmoveto is use to mke rek in the urrent pth s it is eing onstrute. An exmple of its use will e foun t the en setion reting urrent pth To rete urrent pth, moveto is use to mke strting or urrent point. Then one of the PostSript pth onstrution opertors suh s lineto is use to ientify new point extening from tht point. overview of the sis 13

18 Tking Avntge of PostSript figure To rw 1 inh squre on the pge, we woul first nee to estlish urrent point n then urrent pth. See figure 2 6. The pth oul strt t 0.5 inh up n over 1 inh from the ottom left orner of the pge n move right 1 inh, up 1 inh, left 1 inh, n k own to the strting point. The pth oul lso e rwn in the lokwise iretion s well. The initil urrent oul hve een ny one of the orners. This esription of the squre is the urrent pth; nothing hs een pinte yet. It is the ro mp for pinting tht omes lter. The lineto opertor retes urrent pth to some new point from n existing urrent point. The new point eomes the new urrent point. The syntx for the lineto opertor is: x y lineto where x n y re oorintes on the pge. Also, lineto requires urrent point from either previous moveto or lineto. The PostSript progrm of our squre up to this point woul look like this: moveto lineto lineto lineto lineto This PostSript progrm frgment retes urrent pth. If we were to print t this moment, we woul hve lnk pge. The next step of the progrm is to use the pth either to stroke line or s ontiner for fill. It is lso possile to use the pth s ounry or ookie utter for imges to pper within. This is one with lip, n will e expline in setion pinting the urrent pth One urrent pth hs een onstrute, you hve the hoie of either stroking it or filling it with the urrent olor. The two opertors re stroke n fill. These two opertors pint the urrent pth with the urrent line weight n urrent olor. In ition, the stroke n fill opertors onsume the urrent pth, mening one the pth is pinte, it will no longer exist. Exmples of stroke squre n fille squre with their PostSript progrms follow. 14 overview of the sis

19 Chpter 2 lern PS moveto lineto lineto lineto lineto stroke lern PS moveto lineto lineto lineto lineto fill As mentione in setion 1.4, if you wnt to experiment n print these first two progrms, fin exmples 2 1 n 2 2 in the ExmplePS setion of LernPS. Rememer, the reson these exmples look like this is euse the efult vlue for the urrent olor is lk n the urrent line weight is one point. Those vlues will remin until you hnge them. In the next hpter, we ll run this squre through ll sorts of vritions. The urrent pth oes not nee to e one ontinuous onnete pth. In this exmple, rmoveto is use twie to ontinue the pth fter rek. The rrow in the grphi shows the movement of the urrent point with rmoveto. The point of the rrow is lso rwn using rmoveto lern PS 2 3 %!PS-Aoe-2.0 EPSF-1.2 %%Title:twoLines.eps %%BouningBox: overview of the sis 15

20 Tking Avntge of PostSript 3 setlinewith % prllel lines moveto lineto rmoveto lineto % seon line stroke.25 setlinewith % rrow moveto rlineto 0-6 rmoveto 0 6 rlineto 6 0 rlineto stroke 16 overview of the sis

21 Chpter 2 overview of the sis 17

22 Tking Avntge of PostSript 16 rwing squre

23 Chpter 3 3 hpter rwing squre This hpter overs numer of ifferent methos tht n e use to rw squre. In oing so, vrious strtegies re overe in smll sle tht n e pplie to vriety of progrmming situtions. The PostSript lnguge provies more thn one wy to rete the sme result. The reson to use one over nother will epen on the sitution n your writing style. 3.1 finishing the finl orner of the squre In figure 3 1 elow, the lk line represents the pth for the wie gry line. Notie the line oes not exten eyon the pth. Beuse of this, squre stroke with thik outline woul hve notiele noth t the finl orner. figure 3 1 The preferre wy to write the PostSript progrm for the squre rwn in the lst hpter woul e to inlue the losepth opertor. losepth joins the urrent point on the pth to the first point me y moveto n finishes tht orner. Other exmples of its use will e seen in hpter 6. This exmple pints one squre on top of nother. The lk squre on top uses the losepth opertor to finish the orner t the lotion of the pth s eginning n ening. The PostSript progrm is liste elow. lern PS 3 1 %!PS-Aoe-2.0 EPSF-1.2 %%Title:losepth_1.eps %%BouningBox: setgry 12 setlinewith 6 6 moveto % gry thik line rwing squre 17

24 Tking Avntge of PostSript 72 0 rlineto 0 72 rlineto rlineto 0-72 rlineto stroke % lk squre on top 0 setgry 4 setlinewith 6 6 moveto 72 0 rlineto 0 72 rlineto rlineto losepth stroke This PostSript progrm introues severl new opertors. First, n explntion of the first three lines lle the progrm heer. These three lines re not neessry to rete the tul grphi, ut they re very importnt if the grphi will e ple in nother oument. This will e expline in more etil in the next hpter on EPS files. The new PostSript opertors introue re: setgry hnges the urrent gry vlue. setlinewith hnges the urrent line weight. rlineto rws line reltive to the previous urrent point. setgry expets numer etween 0 n 1 where 0 is lk, 1 is white, n vrious grys re in etween. Therefore, 0.2 is 80% lk, 0.5 is 50%, n 0.9 is 10% lk. setgry hnges the urrent olor use y stroke n fill for pinting. setlinewith hnges the urrent line weight use y stroke n expets positive numer. It n e 0 n s high s 700 or higher. However, it is not visle to use zero. 0 setlinewith pints the line s fine s the printer is ple of prouing. On 300 pi tht woul e 0.24 inhes, whih n e seen esily. But on 2540 pi Linotron, however, it woul e inhes not visile. rlineto is n lterntive to lineto. lineto rws lines to points on the oorinte system reltive to the origin. rlineto rws its lines reltive to the previous urrent point. We hve two wys to rw the pth for squre. There is moveto lineto lineto lineto losepth stroke n moveto 72 0 rlineto 0 72 rlineto rlineto losepth stroke Both of these progrm exmples proue the sme results. Lter, in hpter 18, two new opertors for rwing retngles in PostSript Level 2 will e expline. 18 rwing squre

25 Chpter efining proeures A thir wy to rw the squre is to efine it s proeure. One efine, it n e use s often s neee. The efinition for squre oul look like this, /squre { 72 0 rlineto 0 72 rlineto rlineto losepth } ef n it oul e use like this moveto squre stroke or moveto squre fill The / (slsh) speil hrter ientifies the wor squre s nme. The speil hrters { n } ontin the efinition for the nme. The ef opertor ssoites the efinition with the nme. The proeure s nme or key is store in the PostSript interpreter s user itionry while the progrm is run. When PostSript interpreter enounters nme it oes not reognize, the interpreter sees if there is efinition for it in the user itionry. If there is none present, n error messge will e sent. The PostSript interpreter will ssume tht something ws misspelle. There will e more on user itionries in setions A omplete progrm using the squre proeure n look like this: lern PS 3 2 %!PS-Aoe-2.0 EPSF-1.2 %%Title:squre_ef1.eps %%BouningBox: /squre { 72 0 rlineto 0 72 rlineto rlineto losepth } ef moveto squre fill moveto squre fill rwing squre 19

26 Tking Avntge of PostSript moveto squre fill moveto squre fill 3.3 stroking & filling the sme pth As stte in setion 2.11, the stroke n fill opertors onsume the urrent pth. However, there is wy to use the urrent pth for oth stroke n fill. The urrent pth n e opie to e use twie y sving or y tking snpshot of the grphi stte. The PostSript opertors gsve n grestore sve n restore the grphi stte. The sequene for grphisve n grphirestore woul e: 1 No urrent point or urrent pth 2 Crete urrent pth 3 Sve the urrent pth y sving the grphi stte n mking opy 4 fill the urrent pth 5 Restore the previously sve urrent pth 6 stroke the restore urrent pth 7 Current pth is lere The grphi stte ontins the urrent vlues for the urrent gry, line with, urrent point, urrent pth, lotion of the origin, n numer of other vlues not pplile here. Here s n exmple: lern PS 3 3 %!PS-Aoe-2.0 EPSF-1.2 %%Title:gsve_1.eps %%BouningBox: moveto 72 0 rlineto 0 72 rlineto rlineto losepth gsve % sve pth, vlue lk 0.5 setgry fill % 50% lk & pth fille grestore % sve pth restore 20 rwing squre

27 Chpter 3 stroke % restore pth stroke The gsve sves the urrent pth n the efult vlue of lk. Next, 0.5 setgry fill hnges the urrent vlue to 50% lk n the urrent pth is fille with it. grestore restores the urrent gry k to 100% lk n the urrent pth. Finlly, stroke onsumes the sve opy of the urrent pth. The line weight of the stroke is the efult vlue of one point. 3.4 moving the origin The trnslte opertor moves the origin roun on the pge. For exmple, trnslte moves the lotion of the origin from the lower left orner of the pge to 1 inh up n over. The vntge of moving the origin is tht it my mke it esier to ple numer of grphi ojets on the pge. In n erlier exmple, /squre ws efine to e: 72 0 rlineto 0 72 rlineto rlineto losepth It ws move roun the pge y estlishing urrent point t the esire lotion for the squre, then using the proeure. A seon metho of pling numer of squres on the pge is to hve the urrent point lwys t the origin within the efinition n move the origin roun. For exmple: /squre { 0 0 moveto 72 0 rlineto 0 72 rlineto rlineto losepth fill } ef trnslte squre PS lern 3 4 Sine hnging the position of the origin is hnging the grphi stte, it will e helpful to rket the hnges with gsve n grestore. There n e some unexpete results if the origin is hnge within progrm. It is importnt to emphsize tht using the trnslte opertor oes not rete urrent point, ut trnsforms the oorinte system tht urrent points re me upon. The erlier exmple from setion 3.2, squre_ef1.eps, n e rewritten two wys to emonstrte the use of trnslte. The first rewrite oes not use gsve n grestore. The lotions of the vrious squres re not immeitely pprent n it gets rther iffiult to visulize where they re euse of the wy the origin is hnging its lotion. %!PS-Aoe-2.0 EPSF-1.2 %%Title:squre_ef2.eps %%BouningBox: /squre { 0 0 moveto 72 0 rlineto 0 72 rlineto rlineto losepth fill } ef trnslte squre % from 0 0 = trnslte squre % from = rwing squre 21

28 Tking Avntge of PostSript trnslte squre % from = trnslte squre % from = The seon version ples the squres t the sme lotion on the pge ut the progrm is written ifferently this time y using gsve n grestore. Beuse of this, it is muh esier to keep trk of the lotion of the squres in this exmple. The lotion of the fourth squre t is from the lower left orner of the pge n not from n unknown point somewhere else on the pge euse of hnge in the previous line of oe. lern PS 3 5 %!PS-Aoe-2.0 EPSF-1.2 %%Title:squre_ef3.eps %%BouningBox: /squre { 0 0 moveto 72 0 rlineto 0 72 rlineto rlineto losepth fill } ef gsve % sve lotion of origin trnslte squre % hnge lotion grestore % restore lotion of origin gsve trnslte squre grestore gsve trnslte squre grestore gsve trnslte squre grestore 22 rwing squre

29 Chpter 3 Using gsve n grestore s flexiility to the progrm. Chnges to iniviul squres will not ripple throughout the rest of the progrm. Also, iniviul prts of progrm rkete y gsve n grestore n esily e opie n positione into other progrms. In the next exmple, hnges re me to the first n seon squres. The thir squre is stroke with the efult 1 point line weight n the fourth squre is fille with the efult olor lk. PS lern 3 6 %!PS-Aoe-2.0 EPSF-1.2 %%Title:squre_ef4.eps %%BouningBox: /squre { 0 0 moveto 72 0 rlineto 0 72 rlineto rlineto losepth } ef gsve % sve grphi stte / urrent olor & origin.5 setgry trnslte squre fill grestore % restore grphi stte gsve % sve grphi stte 4 setlinewith trnslte squre stroke grestore % restore grphi stte gsve % sves origin, uses efult olor trnslte squre stroke grestore gsve trnslte squre fill grestore rwing squre 23

30 Tking Avntge of PostSript 3.5 hnging the size The sle opertor mkes the oorinte system lrger or smller. For exmple, 2 2 sle oules the size of the grphi stte. There will lso e more etile isussion of the sle opertor in hpter 10. If the proeure for squre is efine to e 1x1 unit, sle oul e use to enlrge tht squre to whtever size is require. Note in the following exmple tht the squre is 1x1 n sle is use to rete three sizes of the squre. The iniviul squres re rkete y gsve n grestore so the sling will not multiply from squre to squre. PS lern 3 7 %!PS-Aoe-2.0 EPSF-1.2 %%Title:squre+sle_1.eps %%BouningBox: /squre { 0 0 moveto 1 0 rlineto 0 1 rlineto -1 0 rlineto losepth } ef gsve.5 setgry trnslte sle squre fill grestore gsve trnslte sle squre fill grestore gsve.3 setgry trnslte 24 rwing squre

31 Chpter sle squre fill grestore The sequene of the PostSript opertors is very importnt. If you re not reful, you n get yourself some unexpete results. It n mke ifferene if sle is use efore or fter the retion of urrent pth. It will lso mke ifferene whether the pth is stroke or fille. Note where the sle is use for eh squre in the following exmple. lern PS 3 8 %!PS-Aoe-2.0 EPSF-1.2 %%Title:squre+sle_2.eps %%BouningBox: /squre { 0 0 moveto 1 0 rlineto 0 1 rlineto -1 0 rlineto losepth } ef gsve % smll gry squre.5 setgry trnslte sle % sle grphi worl 1 to 72 squre fill grestore gsve 2 setlinewith trnslte sle squre stroke grestore gsve % lower squre % upper squre rwing squre 25

32 Tking Avntge of PostSript trnslte squre sle stroke grestore 26 rwing squre

33 Chpter 3 rwing squre 27

34 Tking Avntge of PostSript 26 EPS files

35 4 hpter Chpter 4 EPS files There re two ifferent types of PostSript files: PostSript files tht re sent to the printer n PostSript files tht will e first inorporte into other ouments efore eing sent to the printer. A goo exmple of this is pge omposition softwre tht imports PostSript illustrtions. PostSript files intene to e inlue into nother oument re known s Enpsulte PostSript Files. The files re known s EPS files or EPSF files. These files my hve n.eps file extension, not require in the Mintosh environment ut use on the NeXT. 4.1.ps files The expettion with PostSript file or text file with.ps extension is tht it will print one or more pges of oument. It my ontin EPS files. It will ontin the showpge opertor. showpge is the PostSript print opertor. It is neessry when sening file to printer. In orer to sve spe, it is not use t the en of the PostSript exmples in this ook. If you use SenPS to ownlo your progrms, you n use the A showpge option uner the options menu to utomtilly showpge to your progrms. 4.2.eps files The expettion with n Enpsulte PostSript File or text file with n.eps extension is tht it is one pge n my ontin the showpge opertor n print preview. By efinition, n EPS file is single imge tht my e eventully ple in nother oument. It lso inlues informtion tht tells the importing softwre wht the imensions re n other informtion tht my e neee. This informtion is ontine in the file s heer or first lines of oe. More on this in the next setion. The showpge opertor is optionl n will use prolems if the importing oument is not set up to neutrlize it. If it s not, the pge will print premturely. This is hnle y temporrily reefining showpge to o nothing until the pge is rey to print. Renming PostSript opertors is overe in more etil in setion Often print preview will e inlue with the Enpsulte PostSript File so it n e seen on the omputer s monitor. The si reson for this is the PostSript informtion use to rete the pge isn t omptile with how imges re forme EPS files 27

36 Tking Avntge of PostSript on omputer s monitor. The exeption is the NeXT omputer, on whih the sme informtion is sent to oth sreen n printer. There is no nee for preview version of the grphi. The Mintosh nees print preview of the PostSript file. On the Mintosh, wht is seen on the sreen is rwn y QuikDrw, Apple Computer s grphis lnguge. Files rete with QuikDrw re known s PICT files (short for PICTure). Even though PICT version is seen on the sreen, Aoe s PostSript version is wht is sent to the printer. Depening on the grphi, the overlp in the two grphi moels will proue rough or very urte QuikDrw preview. In ll ses, wht is seen on the Mintosh sreen is never wht is sent to the printer. The EPS options on the Mintosh re: PostSript informtion / no print preview PostSript informtion / 1 it PICT preview for si positioning PostSript informtion / olor or gry sle PICT preview On IBMs n omptiles, the sme sitution exists s with the Mintosh. Wht is seen on the sreen is ifferent thn wht is sent to the printer. All the EPS files we will write s prt of this ook n in the HyperCr version of the LernPS tutoril will not hve preview for the Mintosh sreen. 4.3 the progrm heer There re two lines tht must e present in PostSript file to mke it Enpsulte PostSript File. It is these lines tht mke n EPS file n EPS file. They re: %!PS-Aoe-2.0 EPSF-1.2 %%BouningBox: There re numer of onventions in writing the eginning of PostSript progrm. The following progrm, 2inSqure.eps, is n exmple using the most ommon omments. They re outline in more etil in Aoe s tehnil oument #PN LPS5002, Enpsulte PostSript Struturing Conventions. The two ove must e there, ut it is goo hit to provie s muh informtion s possile. These omment lines will e efine in setion 4.6. Notie tht ll of the first six lines egin with the % speil hrter. These lines re not re or use y the PostSript interpreter. They ontin informtion use y softwre tht inorporte the file into lrger oument. The softwre is esigne to re this informtion s the file is importe. The following PostSript progrm will look like this isplye on the NeXT or printe on PostSript lser printer. 28 EPS files

37 Chpter 4 EPS file lern PS 4 1 %!PS-Aoe-2.0 EPSF-1.2 %%Title:2inSqure.eps %%Cretor:John F Shermn %%CretionDte:June 1990 %%DoumentFonts:Times-Romn %%BouningBox: moveto lineto lineto lineto losepth fill /Times-Romn finfont 36 slefont setfont 1 setgry moveto (EPS file) show 2inSqure.eps n e ple in numer of Mintosh pplitions s is. Beuse it is only PostSript oe without QuikDrw preview, it will pper on the sreen s n outline ox. The size of this outline ox is tken from the %%BouningBox omment. 2inSqure.eps will print orretly, however, using the PostSript informtion. 4.4 pling EPS files into Mintosh ouments The file, 2inSqure.eps n e ple s is into n Illustrtor or PgeMker oument. In ft, every PostSript exmple in this ook n e ple into ouments in the sme wy. To ple n EPS file into n Illustrtor oument, first rete the text file with ny wor proessor. Its nme oesn t hve to hve the.eps file extension n its nme oesn t even hve to mth the %%Title: omment. When Ple uner the File menu in Aoe Illustrtor is hosen (see figure 4 1), ilog ox will pper to lote n EPS file. The ilog ox will isply TEXT n EPSF file types (more on file types in the next setion). EPS files 29

38 Tking Avntge of PostSript figure 4 1 When file is selete n opene, Illustrtor will hek the eginning of the file to see if the orret heer informtion is present. Speifilly, s mentione in the previous setion, these two lines: %!PS-Aoe-2.0 EPSF-1.2 %%BouningBox: One ple, the ontents of the file nnot e eite, ut it n e move to ny lotion on the pge. In ition, the sle, rotte, reflet, n skew trnsformtion tools of Illustrtor n e use on the file. figure 4 2 The ple 2inSqure.eps will pper like figure 4 2 in Aoe Illustrtor. When this file is printe, the PostSript informtion will e use. In Alus PgeMker, essentilly the sme steps re tken with the Ple menu foun uner the File menu. Selet the EPS file from within the ilog ox in the usul wy. The rrow ursor will eome PS ursor. Clik the PS ursor on the pge where you wnt the PostSript file to e lote (see figure 4 3). 30 EPS files

39 Chpter 4 figure 4 3 Agin, only gry ox will pper on the pge ut notie tht the title, retor, n retion te pper within the ox (see figure 4 4). This will e isplye if those lines re present in the heer of the progrm. figure 4 4 The gry ox for the EPS file n e move wherever it s neee one ple. 4.5 hnging TEXT to n EPSF file type Some Mintosh pplitions n only import EPS files if their file type hs een hnge from TEXT to EPSF. Their file ontents re not ny ifferent, just tg tht tells the importing softwre wht kin of file it is. figure 4 5 Every Mintosh file hs file type n retor ssoite with it. This informtion is use y the Finer to etermine wht ion to isply (file type) n wht pplition to lunh (file retor). In figure 4 5, Files A n B re me y Aoe Illustrtor n Files C n D re me y Mirosoft Wor (the retors). These two pplitions n mke the sme file type. Files A n D re TEXT. Mirosoft Wor (s n option) n Aoe Illustrtor (y efult) n sve their files s TEXT. File B is EPSF n File C is WDBN. This mens you oul open n Illustrtor file with MS Wor n look t the PostSript oe it hs written. It oesn t work the other EPS files 31

40 Tking Avntge of PostSript wy, however; Illustrtor n t open Mirosoft Wor s files. Illustrtor files re PostSript files. Illustrtor gives you the option to inlue preview to mke the file n Enpsulte PostSript File. When this is one, Illustrtor hnges the file type from TEXT to EPSF. Beuse of this, the file will hve ifferent ion. File A is TEXT file, File B is n EPSF. File C is Mirosoft Wor s efult file type WDBN n File D is TEXT file. Also, file types n retors re use in ilog oxes to filter wy file nmes of other progrms. In some other Mintosh pplitions, suh s Letrset s Rey, Set, Go, the file type of 2inSqure.eps will nee to e hnge from TEXT to EPSF. This n e one with numer of utilities, suh s CE s DeskTop or MTools. In Illustrtor n PgeMker, the Ple ilog ox isplys ll TEXT files, EPS formtte or not. In other softwre, the ilog ox isplys EPSF or other grphi file formts, ut not TEXT files. The steps involve in hnging file tht s TEXT file type to n EPSF file type n e one with severl utilities. I ll emonstrte how its one using DiskTop, esk essory from CE Softwre. The proess will e similr with other utilities, suh s MTools from Centrl Point Softwre. figure 4 6 After opening DiskTop, selet the file you wish to hnge. Notie tht in this se the file is of type TEXT n is rete y???? (see figure 4 6). It is???? euse the file ws not originlly written on Mintosh n the Mintosh therefore oesn t know who me it. Your file my show MSWD s the retor if the file ws me y Mirosoft Wor or MACA if it ws written y Clris MWrite. For our purposes, it oes not mtter wht the retor ID is. figure 4 7 Selet Get Info... from the DiskTop menu. In the upper right hn orner you will see two oxes to enter new Type n Cretor IDs (see figure 4 7). figure 4 8 Chnge TEXT to EPSF n sve the hnges (see figure 4 8). The file is now rey 32 EPS files

41 Chpter 4 to e use y progrms suh s Rey, Set, Go or DesignStuio tht look for the EPSF file type. Unfortuntely, you will nee to reverse the steps tken n hnge the file k to TEXT shoul you nee to eit the file. It s importnt to note tht just hnging the file type to EPSF from TEXT oesn t utomtilly mke file n Enpsulte PostSript File. The orret info must e present in the heer of the file. Also, not ll Mintosh softwre will e le to tke vntge of EPS files. Chek the mnul of the softwre in question. 4.6 the progrm heer, line y line Here is rief explntion of eh of the heer lines use in setion 4.3. All of these lines re seen s omments y the PostSript interpreter. They ren t use to mke mrk on the pge, ut to give informtion to either importing softwre or print servers. They o not hve to e in ertin orer exept the following shoul lwys e the first line: %!PS-Aoe-2.0 EPSF-1.2 This line ientifies tht the PostSript progrm onforms to the stnr Aoe struturing onventions. More often thn not, it must e present for the file to e properly use y n pplition. Some progrms will not e le to use the file if it isn t present. %%Title:2inSqure.eps This line is useful, s seen erlier in the PgeMker exmple (figure 4 4). There, the file nme is shown in the gry ox. In other pplitions, it my e liste when informtion is requeste. %%Cretor:John F Shermn This line might re %%Cretor:Aoe Illustrtor 88(TM) 1.6 if it ws rete y Aoe Illustrtor. %%CretionDte:June 1990 This is reor of when the file ws rete. %%DoumentFonts:Times-Romn This line n e very importnt in some print environments. This line my e use to let printer know it hs to get font from its hr isk or server. If more thn one font is eing use in file, it woul e written s follows: %%DoumentFonts:Times-Romn %%+ AvntGre-Demi %%+ Helveti EPS files 33

42 Tking Avntge of PostSript %%BouningBox: This is the most importnt line in the file heer euse it esries the smllest retngle tht the grphi woul fit in. This informtion is use for positioning the EPS file into other files. In the exmple elow, the shpe fits in retngle whose lower left is t x n y n upper right is t Its ouning ox woul therefore e: %%BouningBox: lern PS 4 2 %!PS-Aoe-2.0 EPSF-1.2 %%Title:BBox_1.eps %%CretionDte:June 1990 %%BouningBox: trnslte moveto urveto urveto urveto urveto urveto urveto urveto fill If BBox_1.eps were to e rought into TopDrw on the NeXT omputer, it woul pper s in figure EPS files

43 Chpter 4 figure 4 9 The eight little squres tht surroun the shpe pper when the ojet is selete for n eit in TopDrw. These re hnles tht n e use for strething n sling the piture n ly on the orer tht orrespons to the BouningBox. There is more informtion on the BouningBox in setion D.5. EPS files 35

44 Tking Avntge of PostSript 36 unerstning error messges

45 Chpter 5 5 hpter unerstning error messges As with ny progrmming lnguge, mistkes of ll kins n hppen. There n e misspellings, missing rguments, or opertors out of sequene. The PostSript interpreter provies feek to help the progrmmer lote the mistke. Depening on the mens you re using to ownlo the PostSript file, the error messge n e reeive in numer of ifferent wys. The error messge n e sent to text file on your isk rive or sent to winow on the omputer s monitor. An error messge will look like this: %%[Error: unefine; OffeningCommn: movto]%% It will pper on the Mintosh monitor like this when using SenPS: This messge my pper riefly on the monitor n then e sent to text file on isk uner the nme of the printer. It might e nme LserWriter Log n e foun in the sme foler s SenPS. Following re some of the most ommon error messges n where to look when they our. 5.1 unefine unefine is one of the most ommon error messges to reeive. lern PS 5 1 For exmple, with this PostSript progrm, %!PS %%Title:mistke1.ps movto % moveto is misspelle unerstning error messges 37

46 Tking Avntge of PostSript lineto lineto lineto lineto fill lern PS 5 2 this error messge is sent k: %%[Error: unefine; OffeningCommn: movto]%% This messge oul e re s I nnot run this PostSript progrm euse I on t unerstn movto. In this se, it will e immeitely reognize tht we misspelle moveto. Another exmple is the following: %!PS %%Title:mistke2.ps /Box ox {72 72 moveto lineto lineto lineto lineto fill} ef % Box, not ox, is efine ove The progrm frgment proues this error messge: %%[Error: unefine; OffeningCommn: ox]%% This is sitution similr to the previous error. In oth exmples, when the PostSript interpreter enounters wor it oesn t unerstn, it serhes first the itionry of user efine proeures, n then the system itionry to see if the questionle wor is efine there. If not, the interpreter retes the unefine error. In the first exmple moveto ws misspelle; movto will not e foun in ny itionry. The seon exmple hs the sme si prolem: ox is not the sme s Box, n Box is wht is efine n lote in the user itionry. 5.2 lern PS 5 3 typehek Another ommon mistke is the se when n opertor isn t misspelle ut is missing from ertin PostSript opertor sequene. For exmple: %!PS %%Title:mistke3.ps /Helveti-Bol 100 slefont setfont % finfont is missing moveto (Type) show lern PS 5 4 The progrm frgment proues this error messge: %%[Error: typehek; OffeningCommn: slefont]%% Here, finfont ws forgotten fter the /Helveti-Bol. slefont ws in error euse there wsn t nything to sle. Another exmple is this progrm tht retes pttern. %!PS %%Title:mistke4.ps /wor (LernPS) ef [ ] {wor} imgemsk % oolen not 1 38 unerstning error messges

47 Chpter 5 The progrm frgment proues this error messge: %%[Error: typehek; OffeningCommn: imgemsk]%% The error here is not wht is missing, ut tht the 1 lote fter the shoul e either true or flse. With the relte imge opertor, the 1 woul e orret in tht position. 5.3 lern PS 5 5 stkunerflow The stkunerflow error ours when n opertor oes not hve the expete numer of rguments on the stk. In the following line of PostSript, r nees five numers on the opern stk to o its work n there re only four present witing to e use. %!PS %%Title:mistke5.ps r stroke % missing the vlue for rius The progrm frgment proues this error messge: %%[Error: stkunerflow; OffeningCommn: r]%% lern PS 5 6 In this next exmple, the height rgument is missing for the imge opertor. %!PS %%Title:mistke6.ps /pistr 2 string ef /Mikey {16 1 [ ] % missing height {urrentfile pistr rehexstring pop} imge} ef Mikey FE 0F FD B3 FD 7D F5 F8 F7 F8 F6 D3 80 D3 00 F7 00 CF 06 1F 04 0F 8C 0F FC 0F FC 0F FE 1F The progrm frgment proues this error messge: %%[Error: stkunerflow; OffeningCommn: imge]%% This messge sttes tht one of the rguments for the imge opertor is missing. H the mtrix rry or proeure een missing, the error woul hve een typehek error. 5.4 lern PS 5 7 rngehek The rngehek error is use when n expete vlue is outsie of the require rnge. In the exmple elow, the mtrix rry for the imge opertor is missing the lst zero in the rry, whih shoul re [ ]. %!PS %%Title:mistke7.ps /pistr 2 string ef unerstning error messges 39

48 Tking Avntge of PostSript /Mikey { [ ] % rry missing lst 0 {urrentfile pistr rehexstring pop} imge} ef Mikey FE 0F FD B3 FD 7D F5 F8 F7 F8 F6 D3 80 D3 00 F7 00 CF 06 1F 04 0F 8C 0F FC 0F FC 0F FE 1F The progrm frgment proues this error messge: %%[Error: rngehek; OffeningCommn: imge]%% 5.5 limithek The most ommon reson for limithek error is tht urrent pth hs eome too omplex. For exmple, the mximum numer of points tht n e rete in urrent pth efore n error on the Apple LserWriter Plus is fifteen hunre. This numer will e ifferent epening on the printer. The resolution tht the printer is set to n lso hve ering on whether this error will our. lern PS 5 8 %!PS %%Title:mistke8.ps /Helveti-Bol finfont 100 slefont setfont /fountstring 256 string ef { fountstring exh up put } for trnslte 0 0 moveto (efghijklm) true hrpth lip sle [ ] {fountstring} imge The progrm frgment proues this error messge: %%[Error: limithek; OffeningCommn: lip]%% Wht n e iffiult out this error is ntiipting when it will e me. A PostSript progrm might run error free on n Apple LserWriter ut fil on high resolution Linotron. The progrm mistke8.ps ove, for exmple, fils on n Apple LserWriter Plus ut runs without prolem on NeXT lser printer. There re two solutions when this error ours. In the exmple ove, the lip oul e one in severl prts, lipping first e, then the fghi, n then the jklm. This n e omplishe y using the stringwith opertor. The syntx for stringwith is: string stringwith returning xw yw where string is the string to e mesure, n xw is the returne with of string. The returne yw vlue is usully isre euse the vertil mesurement in romn fonts is lwys zero. 40 unerstning error messges

49 Chpter 5 efghijklm lern PS 5 9 %!PS-Aoe-2.0 EPSF-1.2 %%Title:fix8.eps %%Dte:17 De 1990 %%DoumentFonts:Helveti-Bol %%BouningBox: retstroke /Helveti-Bol finfont 50 slefont setfont /fountstring 256 string ef { fountstring exh up put } for /x1 (e) stringwith pop 12 ef /x2 (efghi) stringwith pop 12 ef gsve moveto (efghijklm) true hrpth lip sle [ ] {fountstring} imge grestore gsve x1 24 moveto (fghi) true hrpth lip sle [ ] {fountstring} imge grestore gsve x2 24 moveto (jklm) true hrpth lip sle [ ] {fountstring} imge grestore The seon wy is to use the setflt opertor. To get the progrm ove to work on the Apple LserWriter Plus, 9 setflt is e to the eginning of the progrm. setflt ontrols the ury of urve pths. The lrger the numer, the orser the urve. In mistke8.ps ove, the etter solution might e to ivie the lipping opertion euse the 9 setflt mkes the letterform s urves very rough. Following is n exmple of wht setion of the print woul look like with setflt use. unerstning error messges 41

50 Tking Avntge of PostSript efgh Another ommon reson for getting limithek error is using the utotre feture of Aoe Illustrtor on the wrong kin of templte. 5.6 lern PS 5 10 nourrentpoint The nourrentpoint error is sent when neee urrent point is missing. It is usully missing moveto. In this exmple, urveto nees n existing urrent point. Unlike r or rn, this line of PostSript must e preee y either moveto or the urrent point on pth eing me. %!PS %%Title:mistke9.ps urveto stroke The progrm frgment proues this error messge: %%[Error: nourrentpoint; OffeningCommn: urveto]%% lern PS 5 11 Another exmple is type positione y moveto. %!PS %%Title:mistke10.ps /Helveti-Bol finfont 72 slefont setfont (Type) show The progrm frgment proues this error messge: %%[Error: nourrentpoint; OffeningCommn: show]%% lern PS 5 12 In this exmple, the lineto nees to egin with moveto. %!PS %%Title:mistke11.ps lineto lineto lineto lineto fill The progrm frgment proues this error messge: %%[Error: nourrentpoint; OffeningCommn: lineto]%% In eh se, lue is provie on where to fin the error. 42 unerstning error messges

51 Chpter lern PS 5 13 syntxerror The typil reson for this error is tht the speil hrters (, [, {, n < re not pire with the orresponing ), ], }, n > in progrm. In this exmple, the losing prenthesis is missing from the string. %!PS %%Title:mistke12.ps /Helveti-Bol finfont 72 slefont setfont moveto (Type show The progrm frgment proues this error messge: %%[Error: syntxerror; OffeningCommn: Type show H the first prenthesis een the one missing inste of the seon, the messge woul e this: %%[Error: syntxerror; OffeningCommn: Type]%% lern PS 5 14 In this exmple, the losing prenthesis is missing from the efinition. %!PS %%Title:mistke13.ps /wor (LernPS ef [ ] {wor} imge The progrm frgment proues this error messge: %%[Error: syntxerror; OffeningCommn: LernPS ef unerstning error messges 43

52 Tking Avntge of PostSript 44 rwing sis

53 6 hpter Chpter 6 rwing sis Up to this point, we hve overe the sis of reting pth for lines n retngles using only the lineto n rlineto opertors. Oviously, there re numer of other pth onstrution opertors for mking other kins of pths. There re five PostSript opertors for mking irles, rs n urves. All of these opertors n e use in omintion with eh other to mke ny shpe possile. One me, the pth n e stroke, fille, or oth. 6.1 reting rs The r n rn opertors re use to rw rs n irles. Their syntx is: x y rius egin finish r x y rius egin finish rn Where: x is the enter of the r/irle on the x xis. y is the enter of the r/irle on the y xis. rius is the rius of the r/irle. egin is the eginning point of the pth. finish is the finishing point of the pth. The ifferene etween r n rn is the iretion of the rwing from egin to finish. See figure 6 1 elow. The irle is ivie into egree points in the ounterlokwise iretion from the three o lok position. The sme points re use y oth r n rn. With r, the iretion of egin to finish is in the ounterlokwise iretion, with rn it is lokwise. The 0 n 360 points shre the three o lok position. Therefore, oth r n rn oul e use to rw irle. Neither r nor rn nees n existing urrent me y moveto the wy lineto oes. However, they n tke vntge of moveto s will e shown lter in r_2.eps. If there is n existing urrent point, it will tth itself with stright line to the egin. To insure ginst n unwnte line, ler the urrent pth with the opertor newpth. rwing sis 45

54 Tking Avntge of PostSript 90 r rius x y 0 & 360 rn 270 figure 6 1 Here re three rs rwn with r. lern PS 6 1 %!PS-Aoe-2.0 EPSF-1.2 %%Title:r_1.eps %%BouningBox: setlinewith r stroke r stroke r stroke Now, the sme progrm gin with the sme rguments use in r_1.eps, ut sustituting rn. The opposite portion of the r is rwn. 46 rwing sis

55 Chpter 6 lern PS 6 2 %!PS-Aoe-2.0 EPSF-1.2 %%Title:rn_1.eps %%BouningBox: rn stroke rn stroke rn stroke The two previous r exmples were rwn without the ustomry estlishing of urrent point. If there is no existing urrent, one is rete t the lotion of egin, the strting point of the r. If there is n existing urrent point, line will e rwn to the point of egin. Notie the ifferene in the following two PostSript progrms when urrent point is me t the enter of the r n losepth is use. lern PS 6 3 %!PS-Aoe-2.0 EPSF-1.2 %%Title:r_2.eps %%BouningBox: moveto r losepth stroke moveto rwing sis 47

56 Tking Avntge of PostSript r losepth stroke moveto r losepth stroke In ll the rs in the previous n next exmple, urrent point is first me t the enter of the r. egin onnets to tht urrent point n therefore rws line. After r, the urrent point will e t finish. Then, losepth rws line to the originl urrent point me with the erlier moveto. In this exmple, oth r n rn re use with fill. PS lern 6 4 %!PS-Aoe-2.0 EPSF-1.2 %%Title:r_3.eps %%BouningBox: setgry moveto r losepth fill.1 setgry moveto rn losepth fill.3 setgry moveto r losepth fill.8 setgry moveto rn losepth fill.5 setgry moveto r losepth fill.8 setgry moveto rn losepth fill 48 rwing sis

57 Chpter mking pie hrt using r Using r to evelop pie hrt is goo exerise in lerning how to mke use of the opern stk n few of the PostSript mth opertors. The pie hrt elow is for the perentges of 43%, 25%, 17%, n 15%. This progrm exmple is written to hnle ny four perentges tht up to 100. The progrm for the fille version of the pie hrt n e foun in hpter 19. PS lern 6 5 %!PS-Aoe-2.0 EPSF-1.2 %%Title:pieChrt_1.eps %%Cretor:John F Shermn %%CretionDte:June 1990 %%BouningBox: setlinewith trnslte % the 4 perentges with spe etween /p1 exh 3.6 mul ef /p2 exh 3.6 mul p1 ef /p3 exh 3.6 mul p2 ef /p4 exh 3.6 mul p3 ef /x 72 ef /y 72 ef /r 72 ef /wege{r losepth stroke} ef x y moveto x y r 0 p1 wege x y moveto x y r p1 p2 wege x y moveto x y r p2 p3 wege x y moveto x y r p3 p4 wege Looking t the first prt of the progrm, re the four perentges with wor spe seprting them. They n e ny four perentges s long s rwing sis 49

58 Tking Avntge of PostSript they up to 100. The four numers re entere onto the stk. /p1 exh 3.6 mul ef efines our first point on the r moving ounterlokwise from the 0 point. If we were to hrt the stk of these two lines of oe, it woul look like figure 6 2. exh 15 mul 54 ef 17 /p1 /p1 3.6 /p /p /p figure In olumn one, the four numers, /p1, n exh re entere onto the stk. exh exhnges the top two items on the stk. Therefore, s we see in olumn two, /p1 n 15 hve swithe ples on the stk. p1 will eventully e the nme for our first point on the r. Next in olumn three, 3.6 n mul re e to the stk. mul multiplies the top two numers on the stk n pushes (puts) the prout onto the stk. We multiply y 3.6 euse our four numers re frtions of 100 n our pie weges will e frtions of 360. In olumn four, 54 is on top from the multiplying of 3.6 y 15. Next omes ef, whih ssoites /p1 with the vlue 54. The steps re then repete in the sme wy for points /p2, /p3, n /p4. However, with those points the new point will lso nee to hve the vlue of the previous point e to it. We o this euse we nee to mke our wy roun the irumferene of the pie. Note tht in efining the vrile p1 the { } re not use. They re only use when efining proeures. The next line of the progrm egins in the sme wy exept for the ition of ing the vlue of p1 to efinition of p2. Strting t where 17 times 3.6 equls 61.2 is pushe onto the stk, the stk woul ontinue s shown in figure ef 25 /p2 p1 (54) /p /p2 43 /p figure 6 3 p1 n re e to the stk. As you might guess, s the top two numers on the stk. We efine p1 in the previous line to e 54. So we then hve in olumn three p1 plus 61.2 equling pushe onto the stk. It is then given the nme p2. Our stk now hs two numers left to proess s p3 n p4. They re one in the sme wy s p2. We now hve these points roun the pie (see figure 6 4). 50 rwing sis

59 Chpter n figure 6 4 The next prt of the progrm is: /x 72 ef /y 72 ef /r 72 ef /wege {r losepth stroke} ef x n y etermine the enter of the pie hrt. They will e use y oth the moveto n r opertors lter in the progrm. r is the rius of the pie hrt. Defining the x, y, n r vriles like this gives us flexiility. We nee to hnge only one numer, not mny, to mke hnge to the hrt. wege is the nme for the proeure {r losepth stroke}. This simplifies the progrm n helps it to e more rele. Next in the progrm omes the tul rwing of the pie hrt using the vlues n proeures efine erlier. x y moveto x y r 0 p1 wege These progrm lines rw the first wege, n so forth. To rewrite the progrm to work with five perentge numers, these lines: /p5 exh 3.6 mul p4 ef n x y moveto x y r p4 p5 wege Follow this sme pttern for eh wege tht will e neee for the hrt. Also, sine we know tht the lst point must e 360, we oul leve out the proess of efining the lst point n put in rwing urves Complex urves re rwn in PostSript with the urveto opertor, whih uses Beziér ui ontrol points. If you hve ever use Aoe Illustrtor, you my lrey hve eome quinte with them when rwing urves. Most omplex urves re iffiult to rw without the i of softwre pkge suh s Aoe Illustrtor, ut some si exmples n e emonstrte. rwing sis 51

60 Tking Avntge of PostSript The syntx of urveto is: 1x 1y 2x 2y x2 y2 urveto Where 1x 1y 2x 2y x2 y2 is the lotion of the first Beziér ontrol point. is the lotion of the seon Beziér ontrol point. is the en of the urve n new urrent point. urveto lso requires n existing urrent point, x1 y1, s strting point, unlike r n rn whih n get y without one. It is importnt to note tht the two points 1x 1y n 2x 2y re not points on the tul pth of the urve. Following is n exmple n igrm. x2 y2 eomes the new urrent point. 2x 2y 72 x1 y1 x2 y2 1x 1y lern PS 6 6 %!PS-Aoe-2.0 EPSF-1.2 %%Title:urveto_1.eps %%BouningBox: setlinewith moveto urveto stroke lern PS urveto emo Beziér ui ontrol points rete urve y using the points x1 y1, 1x 1y, 2x 2y, n x2 y2 to mrk off frme s seen elow in the first frme of figure 6 5. Then eh line segment of the frme is repetely hlve until the urve is forme. Figures 6 5 n 6 6 illustrte this. 1x 1y 2x 2y x1 y1 x2 y2 figure 6 5 The urve of the lst frme is proue y moveto urveto stroke 52 rwing sis

61 Chpter 6 2x 2y 1x 1y x1 y1 x2 y2 figure 6 6 The urve of the lst frme is proue y moveto urveto stroke There is lso the relte rurveto, whih is muh like rlineto. 6.4 the rto opertor An lterntive wy of onstruting rs or urves is the rto opertor. rto rouns off orner me y two lines with n r of speifie rius. The syntx of rto is: x1 y1 x2 y2 rius rto Where: x1 y1 is the en point of the first line n mrks the orner. x2 y2 is the en point of the seon line. rius is the rius of the r rouning off the orner of the two lines. In ition, rto requires urrent point n pushes the new tngent points xt1 yt1 n xt2 yt2 onto the opern stk. In the mjority of ses, these four points re isre. xt2 yt2 eomes the new urrent point. See exmple elow moveto 144 xt1 yt1 enter of r 72 x1 y1 xt2 yt2 x2 y rwing sis 53

62 Tking Avntge of PostSript lern PS 6 7 %!PS-Aoe-2.0 EPSF-1.2 %%Title:rto_1.eps %%CretionDte:June 1990 %%BouningBox: setlinewith moveto rto rto stroke 8 {pop} repet lern PS rto emo In the exmple ove, urrent point is me t n pth is rwn to x1 y1 n then ontinues to x2 y2. The orner of those two lines is then roune y n r with rius of 72. The two points where the r is tngent to the two lines rete the new points xt1 yt1 n xt2 yt2. The urrent point is now xt2 yt2 n the line will ontinue from there. x2 y2 will no longer exist. The reson for the 8 {pop} repet is to remove the tngent points left on the stk. The two sets of tngent points of xt1 yt1 n xt2 yt2 re y-prout of the two rtos n remin on the stk. This is totl of eight numers tht re not neee for nything t this time. In nother sitution, they my e tken vntge of. The opertor pop removes the top most item on the opern stk, n sine we hve eight numers to remove, 8 {pop} repet oes this. It s the sme s writing: pop pop pop pop pop pop pop pop The rto opertor n e use to mke retngles with roune orners. An exmple follows rwing sis

63 Chpter 6 lern PS 6 8 %!PS-Aoe-2.0 EPSF-1.2 %%Title:roune_ret.eps %%BouningBox: /rouneret { /rius exh ef /height exh ef /with exh ef with 2 iv 0 moveto % strt in the mile with 0 with height rius rto % 1st orner with height 0 height rius rto % 2n orner 0 height 0 0 rius rto % 3r orner 0 0 with 0 rius rto losepth % 4th orner 16 {pop} repet } ef % isr tngent points gsve trnslte 2 setlinewith rouneret % 72 wie, 180 high gsve.8 setgry fill grestore stroke grestore gsve trnslte.5 setgry rouneret fill grestore gsve trnslte 3 setlinewith rouneret stroke grestore lern PS roune ret The proeure rouneret is esigne to use three rguments to rw retngle with roune orners. The first two re the with n height of the retngle n the thir is the rius. It woul e use like this: rouneret stroke The first line of rouneret is /rius exh ef /height exh ef /with exh ef This line is how the three rguments re psse on to the rest of rouneret proeure. 72, 144, n 24 re on the opern stk with 24 on top when rouneret rrives. All in one line it woul e /rius exh ef /height exh ef /with exh ef The first exh woul swith 24 /rius /rius 24 ef /height exh ef /with exh ef /rius woul then e efine s /height exh ef /with exh ef The seon exh woul swith 144 /height n so on s efore. The rest of the proeure uses with n height in vrious omintions with 0 n rius s rguments for the rto opertor. rwing sis 55

64 Tking Avntge of PostSript 56 type sis

65 7 hpter Chpter 7 type sis Fonts re store s outlines either in printer s ROM, RAM, or n tthe hr isk. The vntge of outlines is tht the font n e sle to ny size without worry of rgge eges. The PostSript interpreter will fill in the pproprite numer of ots. A it-mp woul not provie the sme flexiility. Eh font is tully itionry of efinitions for eh letterform in the font. Erlier, in hpter 3, we efine the proeure squre to e series of rwing opertions tht rew squre. The proeure squre ws kept in user itionry in the PostSript interpreter while the progrm using it ws run on the printer. In muh the sme wy, eh hrter of the lphet hs series of rwing opertions ssoite with its nme in font itionry. For exmple, within every PostSript lser printer there is font itionry nme Times-Bol. In tht itionry, g woul e efine y series of rwing opertions tht woul rete its outline. 7.1 igrm of letterform In figure 7 1 elow, point mrks the lotion of the origin for Times-Bol g. Point represents oth the with of the letterform n the new urrent point. Point is the lotion of the origin of the next letterform to follow. It s very similr to the ie of mking urrent point, reting pth, n hving the new urrent point t the en of the pth. The lk ox ientifies the smllest retngle the g n fit gin. It is known s the letterform s ouning ox. The mount of spe letterform uses within line of type, the istne etween points n, is slightly more thn its visile with. type sis 57

66 Tking Avntge of PostSript figure pling type on the pge Positioning type on the pge is omplishe in muh the sme wy s rwing tion is strte. A urrent point is first me using the moveto opertor. The ifferene, however, is tht the urrent point when me for type plement oes not represent n tul point on letterform, ut represents its origin on its seline. A letterform s origin is slightly left n on the seline of the hrter. See the g in figure 7 1. The following exmple prints g. The + mrks the lotion of moveto, whih is the hrter s origin. lern PS 7 1 %!PS-Aoe-2.0 EPSF-1.2 %%Title:type plement1.eps %%BouningBox: /Times-Bol finfont 200 slefont setfont moveto (g) show Here s n explntion of the progrm: /Times-Bol finfont lotes the font itionry for Times-Bol. 200 slefont sles the font to 200 point. setfont mkes Times-Bol the urrent font moveto estlishes urrent point. This point will e the hrter s origin n will lso e on the seline. The hrters to e set re ientifie y eing ontine within prentheses. The ( n ) re speil hrters use to ientify wht is known s string or group of hrters to e use for some purpose. In this se, they will e pinte on pge. show pints the hrters hel within the ( n ) in the urrent font with 58 type sis

67 Chpter 7 the urrent olor. In this se, the urrent font is Times-Bol n the urrent olor is the gefult lk. In this exmple, the will e pinte with 70% gry. PS lern 7 2 %!PS-Aoe-2.0 EPSF-1.2 %%Title:type plement2.eps %%BouningBox: /Times-Bol finfont 200 slefont setfont moveto.3 setgry (g) show After show in oth preeing PostSript progrm exmples, the new urrent point is lote t the with of the hrter n on the seline. See point of figure 7 1. To illustrte this, notie how the line is rwn in the next exmple. The eginning of the line is the urrent point lote t the with of the hrter g n on the seline rlineto rws pth 100 points to the right of the urrent point. stroke then pints the pth n initilizes the urrent pth. type sis 59

68 Tking Avntge of PostSript g lern PS 7 3 %!PS-Aoe-2.0 EPSF-1.2 %%Title:type plement3.eps %%BouningBox: /Times-Bol finfont 200 slefont setfont moveto.3 setgry (g) show 0 setgry 2 setlinewith rlineto stroke g When setting series of hrters to form wor, the hrter sping is se on the font s metri file. The font metri file ontins hrter withs. Eh hrter in line to e set referenes the previous hrter. figure 7 2 In figure 7 2 ove, point represents the first urrent point. Point is the new urrent fter the g is set. Point therefore eomes the lotion for the origin of the hrter. After is set, point eomes the new urrent point. 60 type sis

69 Chpter vrious font strtegies Sine it is prole tht numer of ifferent fonts n sizes woul e use on pge, following re numer of ies for swithing from one urrent font to nother. The first metho woul e to sve the grphi stte using gsve n grestore. In this wy, there my e one font tht you will ontinully return to in PostSript progrm. An exmple woul e: BC A lern PS 7 4 %!PS-Aoe-2.0 EPSF-1.2 %%Title:type plement4.eps %%BouningBox: /Helveti finfont 170 slefont setfont 0 0 moveto (A) show gsve /Times-Bol finfont 48 slefont setfont.3 setgry moveto () show grestore (B) show % no moveto, urrent point from A still tive gsve /StoneSerif-Bol finfont 48 slefont setfont.5 setgry moveto () show grestore (C) show % no moveto, urrent point from B still tive gsve /Helveti-Bol finfont 48 slefont setfont.8 setgry moveto () show grestore type sis 61

70 Tking Avntge of PostSript The first gsve sves three key vlues. The urrent font me y /Helveti finfont 170 slefont setfont, the urrent efult vlue of lk, n the new urrent point me fter the (A) show. The urrent font is then hnge to /Helveti-Bol finfont 48 slefont setfont, the urrent vlue is hnge to 0.3 setgry (70%), n new urrent point is me with moveto for the row of s. grestore restores the urrent font k to /Helveti finfont 170 slefont setfont, the urrent vlue k to lk, n the urrent point left fter the (A) show. The whole proess then gets repete for the rows of s n s. A seon strtegy is to give ifferent font settings nme. For exmple, /H18 {/Helveti finfont 18 slefont setfont} ef /H36 {/Helveti finfont 36 slefont setfont} ef /H72 {/Helveti finfont 72 slefont setfont} ef A thir option is to efine /f {finfont exh slefont setfont} ef n use it y writing this: 18 /Helveti f The thir metho is use in this exmple. Note how the plement of iniviul hrters is omplishe. PS lern 7 5 TYPE %!PS-Aoe-2.0 EPSF-1.2 %%Title:TYPE.eps %%BouningBox: /f {finfont exh slefont setfont} ef 68 /Helveti-Bol f 0 0 moveto (T) show 72 /StoneSerif-SemiolItli f (Y) show 74 /Times-Bol f 6 0 rmoveto (P) show % move urrent 6 points right 68 /Helveti-Olique f -8 0 rmoveto (E) show % move urrent -8 points left 62 type sis

71 Chpter 7 Notie how rmoveto is use to kern the type right n left to orret the lettersping. Kerning opertors re expline in more etil in hpter 11, vne type. 7.4 stroking & filling type Inste of using show to pint the type s in ll the previous exmples, the letterform s outline n e otine n me into the urrent pth. Then gsve n grestore n lso e use to sve the urrent pth to oth stroke n fill s ws previously one to the squre in setion 3.3. && lern PS 7 6 %!PS-Aoe-2.0 EPSF-1.2 %%Title:&&.eps %%BouningBox: /StoneSerif-Bol finfont 170 slefont setfont 6 setlinewith moveto (&) true hrpth gsve.5 setgry fill grestore stroke moveto (&) flse hrpth gsve stroke grestore.5 setgry fill Note the ifferene it mkes if the type is stroke seon or first. show is reple with true hrpth. true hrpth mkes the hrter s outline the urrent pth. hrpth is preee with either true or flse. Aoring to the PostSript Lnguge Referene (lso known s the Re Book), type sis 63

72 Tking Avntge of PostSript true hrpth is suitle for filling or lipping, ut not for stroking. The other hoie, flse hrpth, is suitle only for stroking. In the PostSript progrm exmple ove oth re use, oth seem to work orretly. Clipping is expline in setion font nmes If you re working on n Apple LserWriter Plus or the lter LserWriter NT or NTII, there re thirty-five ifferent font outlines tht n e esse in the printer s ROM. Following is list of their nmes written s they woul nee to e written for PostSript progrm. First, the si group of fonts tht re stnr on every PostSript evie: Courier Courier-Bol Courier-Olique Courier-BolOlique Times-Romn Times-Bol Times-Itli Times-BolItli Helveti Helveti-Bol Helveti-Olique Helveti-BolOlique Symol These itionl fonts re known s the Plus Set: AvntGre-Book AvntGre-BookOlique AvntGre-Demi AvntGre-DemiOlique Bookmn-Light Bookmn-LightItli Bookmn-Demi Bookmn-DemiItli Helveti-Nrrow Helveti-Nrrow-Olique Helveti-Nrrow-Bol Helveti-Nrrow-BolOlique NewCenturyShlk-Romn NewCenturyShlk-Itli NewCenturyShlk-Bol NewCenturyShlk-BolItli Pltino-Romn 64 type sis

73 Chpter 7 Pltino-Itli Pltino-Bol Pltino-BolItli ZpfChnery-MeiumItli ZpfDingts There re hunres of fonts ville from Aoe. A progrm to print most of the hrters of font (to see wht they look like) follows. Sustitute the font nme, efore the finfont opertor with the font nme to e set. lern PS 7 7 ABCDE FGHIJ KLMNO PQRST UVWXYZ efgh ijklmno pqrstuv wxyz %!PS-Aoe-2.0 EPSF-1.2 %%Title:quikLook.eps %%BouningBox: /Times-Bol finfont 24 slefont setfont /left 36 ef % left mrgin /newline {show urrentpoint exh pop 30 su left exh moveto} ef left 400 moveto (ABCDE) newline (FGHIJ) newline (KLMNO) newline % lotion of first line % newline ts like rrige % on typewriter type sis 65

74 Tking Avntge of PostSript (PQRST) newline (UVWXYZ) newline (efgh) newline (ijklmno) newline (pqrstuv) newline (wxyz) newline ( ) show.5 setgry moveto rlineto rlineto rlineto losepth stroke 66 type sis

75 Chpter 7 type sis 67

76 Tking Avntge of PostSript 66 the repet & for opertors

77 8 hpter Chpter 8 the repet & for opertors The repet opertor, s its nme implies, repets something speifie numer of times. The for opertor ounts y speifie inrement from given se numer to given limit. Both opertors n e use to rete similr results ut they work in entirely ifferent wys. 8.1 repet The syntx for repet is: numer proeure repet For exmple, 4 {line} repet is the sme s writing line line line line where line my e proeure efine erlier in the progrm to rw line. The proeure n lso e PostSript opertor. A ommon exmple is: 4 {pop} repet This woul remove the top four items on the opern stk. You hve seen this use efore with rto (setion 6.4) n you ll see it use lter with the kshow (setion 11.5) opertor. In the following exmple, repet is use to rw multiple lines. the repet & for opertors 67

78 Tking Avntge of PostSript lern PS 8 1 %!PS-Aoe-2.0 EPSF-1.2 %%Title:repet_1.eps %%BouningBox: /vline {0 0 moveto 0 72 rlineto stroke} ef trnslte 2 setlinewith 36 {6 0 trnslte vline} repet In the progrm ove, vline efines 72 point vertil line from the origin. The origin is then move 6 points right thirty-six times with the 6 0 trnslte efore eh use of the proeure line. It s the sme s writing 6 0 trnslte line thirty-six times. The next exmple is silly the sme thing ut moving up n rwing horizontl lines. 72 PS lern %!PS-Aoe-2.0 EPSF-1.2 %%Title:repet_2.eps %%BouningBox: the repet & for opertors

79 Chpter 8 /hline { 0 0 moveto rlineto stroke} ef trnslte 2 setlinewith 12 {0 6 trnslte hline} repet To omine oth progrms to mke gri, t lest the first repet line shoul e within gsve n grestore so tht the seon repet strts t the proper lotion. Otherwise, the origin will e t fter the first repet, throwing off the lotion of the seon set of lines. Here is how tht oul e written: lern PS 8 3 %!PS-Aoe-2.0 EPSF-1.2 %%Title:repet_1&2.eps %%BouningBox: /vline {0 0 moveto 0 72 rlineto stroke} ef /hline {0 0 moveto rlineto stroke} ef 2 setlinewith trnslte gsve vline 36 {6 0 trnslte vline} repet grestore gsve hline 12 {0 6 trnslte hline} repet grestore The repet n e use with the rotte opertor. See the next exmple. The origin is first move to n then rotte thirty-six times t 10 intervls s eh line is rwn. Then the origin is move over 108 points n rotte ten times t 36 intervls s thiker line is rwn. More on rotte in setion the repet & for opertors 69

80 Tking Avntge of PostSript lern PS 8 4 %!PS-Aoe-2.0 EPSF-1.2 %%Title:repet_3.eps %%BouningBox: /line {0 0 moveto 0 72 rlineto stroke} ef trnslte 36 {10 rotte line} repet 3 setlinewith trnslte 10 {36 rotte line} repet 8.2 for The for opertor ounts up or own to speifie limit y speifie inrement from n initil numer. The syntx for for is: initil inrement limit proeure Where: initil inrement limit proeure is the first numer of the ount. is the inrement of the ount (it n e positive or negtive). is the lst numer of the ount. is the proeure exeute fter every ount. For exmple, { } for is the sme s Sine there is no proeure supplie etween the {}, nothing is exeute fter eh ount from 1 to 10. If proeure h een supplie, it woul e exeute fter eh ount. For exmple, {} for woul e sme s writing: the repet & for opertors

81 Chpter 8 These two lines of oe n e emonstrte further with the following progrm. Sine you n t see wht is hppening insie the PostSript interpreter, this progrm will print the result of the two lines of PostSript oe ove. Prts of this progrm will e expline in more etil in setion lern PS 8 5 %!PS-Aoe-2.0 EPSF-1.2 %%Title:for_test.eps %%BouningBox: /Times-Bol finfont 24 slefont setfont /str 4 string ef % ontiner for 4 hrters moveto {} for % ount from 1 to 6 ing eh to 17 str vs show % put nswer into str, onvert into % string n show /Times-Romn finfont 24 slefont setfont moveto str vs show The for opertor n e use to rw rows of prllel lines muh like the repet exmples isusse in the previous setion. However, it is omplishe y leving numers on the stk to e pike up lter y the moveto opertor. In the next exmple, the for opertor ounts y 6 up to 216. This puts or pushes 0, 6, 12, 18, 24,, 216 onto the opern stk efore the exeution of the proeure line, whih ws efine s {0 moveto 0 72 rlineto stroke}. Notie tht there is only one numer supplie for the moveto opertor within the proeure efinition. After eh ount of the for loop, there will e new numer on the stk to e use with 0 moveto. 72 lern PS %!PS-Aoe-2.0 EPSF-1.2 the repet & for opertors 71

82 Tking Avntge of PostSript %%Title:for_1.eps %%BouningBox: /line {0 moveto 0 72 rlineto stroke} ef trnslte 2 setlinewith {line} for This woul e sme s writing: /line {0 moveto 0 72 rlineto stroke} ef trnslte 2 setlinewith { } for % ll x vlues re pushe onto the stk 0 line 6 line 12 line 18 line 24 line 30 line 36 line 42 line 48 line 54 line 60 line 66 line 72 line 78 line 84 line 90 line 96 line 102 line 108 line 114 line 120 line 126 line 132 line 138 line 144 line 150 line 156 line 162 line 168 line 174 line 180 line 186 line 192 line 198 line 204 line 210 line 216 line A similr tehnique n e use to rw series of horizontl lines. However, the for opertor will e use to supply the y vlue neee y moveto. The line proeure therefore is efine s {0 exh moveto rlineto stroke}. exh swithes the top two items of the opern stk. Therefore, 0 tres ples with the new numer left on the stk. In this wy, 0 n lwys e the x vlue n the new numer is the y lern PS 8 7 %!PS-Aoe-2.0 EPSF-1.2 %%Title:for_2.eps %%BouningBox: /line {0 exh moveto rlineto stroke} ef trnslte 72 the repet & for opertors

83 Chpter 8 2 setlinewith {line} for The following re two exmples where for is use to supply one of the numers for the sle opertor. Sine sle nees two vlues, for oth the x n y sling ftor, up is use to uplite the top item on the stk. In the next exmple, for ounts from 1 to 2.25 y inrements of up uplites eh ount n pushes the opy onto the stk. Therefore, {up sle irle} for is the sme s 1 1 sle irle sle irle sle irle sle irle 2 2 sle irle sle irle lern PS 8 8 %!PS-Aoe-2.0 EPSF-1.2 %%Title:for_3.eps %%BouningBox: newpth /irle{ r stroke} ef trnslte {up sle irle} for In the next version of the progrm, the irle proeure efinition inlues gsve n grestore n therefore hnges the rte of sle the irle reeives. the repet & for opertors 73

84 Tking Avntge of PostSript lern PS 8 9 %!PS-Aoe-2.0 EPSF-1.2 %%Title:for_3.eps %%BouningBox: newpth /irle { r stroke} ef trnslte {gsve up sle irle grestore} for 8.3 using for & put with strings In the previous exmples, the for opertor ws use to proue results tht oul hve een written with the repet opertor. for hs other uses esies eing n lterntive to the repet opertor. for n lso e use with the put opertor to mnipulte strings n rrys. We will onentrte here on the mnipultion of strings. The tehnique will e seen gin lter when we isuss reting fountins with the imge opertor in hpter 13. Its use on rrys is essentilly the sme. In the following exmple, portion of the lphet is printe y ompletely ifferent tehnique thn expline in hpter 7. There, the string to e printe ws enlose within () for the show opertor to pint. Here, the hrters of the string will e rete y the for n put opertors. 74 the repet & for opertors

85 Chpter 8 72!"#$%& ()* lern PS 8 10 %!PS-Aoe-2.0 EPSF-1.2 %%Title:for_4.eps %%BouningBox: /Times-Bol finfont 24 slefont setfont /str 44 string ef {str exh up put} for moveto str show 2 setlinewith moveto 0 24 rlineto stroke Explining the progrm line y line, the first line mkes 24 point Times-Bol the urrent font. In the seon line, str is efine s n empty string with room for 44 hrters. 44 string oul e seen s ( ) The 0s in this string re not the hrter zero, ut represent the ASCII eiml 0, the first entry of the 256 hrter ASCII hrt (see ppenix A). This entry oesn t hve visile hrter ssigne to it n is often referre to s null hrter. Down further on the hrt, you ll note tht eiml 33 is the! or exlmtion point. If str were printe now, the pge woul e lnk. PS lern for emo The thir line, {str exh up put} for silly hnges str from ( ) into ( ) It oes this y ounting from 0 to 43 n while oing so, repling str with the ount. The proeure reples the first 0 (null hrter) of str with 0, the seon 0 of str with 1, the thir 0 of str with 2, the fourth with 3 n so on until the 44th 0 is reple with 43. The ount is from 0 to 43. The string is 44 hrters in length. The first 0 is onsiere in position 0 n the lst 0 is in the 43r position. Looking t the syntx of put will explin this proeure in more etil. string inex integer put the repet & for opertors 75

86 Tking Avntge of PostSript Where: string inex is group of hrters. ientifies position within string; the first hrter is t inex. 0, the seon hrter, is t inex 1, n so on. integer is the integer to e put into position inex of string. In the previous exmple, {str exh up put} for, fter the first ount of for you woul hve 0 str exh up put exh swithes the top two items on the stk, whih gives us str 0 up put up uplites 0, so we now hve str 0 0 put put now puts 0 in inex 0, or position 0 of str. The hnging string str woul look like this fter the first ount: ( ) After the seon ount it woul e ( ) n so on until it is fille: ( ) The next line, moveto str show, pints the string str eginning t the lotion of Nothing ppers till roun euse there re no visile hrters ssigne to hrters 0 31 in the ASCII hrt n hrter 32 is the wor spe. The 33r hrter is the exlmtion point. See ppenix A. The lst two lines of the progrm rw vertil line mrking where the string egn t In the next exmple, getintervl is use to get setion of string. In this se, it is use to otin only the visile portion of the string rete in the previous PostSript exmple. The syntx for getintervl is: string inex ount getintervl returning sustring Where: inex is the strting point into the string. ount is the numer of hrters strting t inex. For exmple, (efg) 2 3 getintervl returns (e) In this exmple, getintervl is efine s the setion of str strting t 33 plus the next 10 hrters ( totl of eleven hrters). 76 the repet & for opertors

87 Chpter 8 72!"#$%& ()* lern PS 8 11 %!PS-Aoe-2.0 EPSF-1.2 %%Title:for_5.eps %%BouningBox: /Times-Bol finfont 36 slefont setfont /str 44 string ef {str exh up put} for /piee {str getintervl} ef moveto piee show the repet & for opertors 77

88 Tking Avntge of PostSript 78 more on rwing

89 9 hpter Chpter 9 more on rwing There is more to o with urrent pths thn just stroke n fill them. The hrter of the stroke n fill n e hnge in vriety of wys. The pth n lso e use s kin of ookie utter or msk to hve imges pper only within its ounries. 9.1 line enings & orners There re three wys to en line. These re shown elow. In ll three, the lk line represents the pth n the gry is its with fter stroking. The first one is lle the utt p. Whtever the line s with, it oesn t ffet the line s length. The other two will inrese the line s length y the thikness. The utt p is the efult setting. 0 setlinep (the efult) 1 setlinep proues the roun p 2 setlinep proues the squre p There re lso three possile orners. 0 setlinejoin the miter join (the efult) 1 setlinejoin roun join 2 setlinejoin evel join Exmples of ll of this follows. Agin, the lk line represents the pth n the gry is its with fter stroking. more on rwing 79

90 Tking Avntge of PostSript lern PS 9 1 %!PS-Aoe-2.0 EPSF-1.2 %%Title:ps&joins.eps %%BouningBox: setlinewith 1 setlinejoin 1 setlinep % ottom.6 setgry moveto lineto lineto lineto stroke 2 setlinejoin 2 setlinep % mile.4 setgry moveto lineto lineto lineto stroke 0 setlinejoin 0 setlinep % top & k to efult.8 setgry moveto lineto lineto lineto stroke 9.2 she lines Dshe lines re rete y using the setsh opertor. The syntx is: rry offset setsh Where: rry is olletion of vlues tht lterntely speifies stroke segment n gp. There nnot e ny negtive vlues in the rry. offset shifts the line left or right. This n e seen in the following exmple. Eh line is 10 points wie n is the sme lternting sh of 20 point stroke n 10 point gp. Wht is ifferent out eh is the offset vlues of 0, 10, n -10 from top to ottom. There re itionl exmples in hpter 19, lirry of exmples. 80 more on rwing

91 Chpter 9 lern PS 9 2 %!PS-Aoe-2.0 EPSF-1.2 %%Title:setsh_1.eps %%BouningBox: /vl {0 0 moveto 0 70 lineto} ef gsve.5 setgry 36 {10 0 trnslte vl} repet stroke grestore 10 setlinewith [20 10] 0 setsh % top 0 55 moveto lineto stroke [20 10] 10 setsh % mile 0 35 moveto lineto stroke [20 10] -10 setsh % ottom 0 15 moveto lineto stroke 9.3 non-zero wining & the even/o rules The non-zero wining n the even/o rules etermine wht is fille or hollow within omplex pths. The most ovious pplition of the non-zero wining rule is in the rwing of letterforms tht hve holes (more preisely known s ounters) within them. Letterforms suh s A, e, n O re exmples. If the pths of the ounter re not rwn in the opposite iretion of the min letterform shpe, the ounter shpe will e fille. In the following exmple, oth irles were rwn with two pths. The intention is to mke one the outsie ege n the other the insie. In the first irle, oth the insie n the outsie pths re rwn in the sme iretion n fille. The pths were rwn gin in lk to show where they were rwn. Sine they were rwn in the sme iretion, oth irles fille. In the seon irle, the insie n outsie pths re rwn in opposite iretions. Sine this is the se, the smller insie pth eomes the insie ege of the irle. The retngle is nother exmple of the insie pth eing rwn in the opposite iretion of the outsie pth. The pths re use seon time n stroke to ientify the pths. A test for whether given point will e insie or outsie of fille re n e one y rwing line from tht point to the outsie. Strting with vlue of zero, when more on rwing 81

92 Tking Avntge of PostSript the line rosses lokwise pth one, n when the line rosses ounterlokwise pth sutrt one. If the result is zero, the point will e outsie the shpe, thus the nme non-zero wining rule. Notie the lines in the two irles in the exmple elow. On the left, the otte line represents the pth of oth irles lern PS 9 3 %!PS-Aoe-2.0 EPSF-1.2 %%Title:winingRule.eps %%BouningBox: % left irle; oth irles rwn in the sme iretion.7 setgry newpth rn % lokwise rn % lokwise fill % right irle; insie irle rwn in opposite iretion newpth losepth rn % lokwise losepth r % ounterlokwise fill % retngle ounterlokwise rwing.5 setgry moveto lineto lineto lineto losepth % lokwise rwing moveto lineto lineto lineto losepth fill The even-o rule is similr to the non-zero rule in tht it too helps to etermine wht prts re n re not fille within omplex pth. In figure 9 1, the letterform g is n exmple. The ounters of the first g re rwn in the opposite iretion of the outsie shpe. In the seon n thir g, the ounters re rwn in the sme 82 more on rwing

93 Chpter 9 lern PS 9 4 iretion. We get the expete results in the seon g, ut the thir ppers orret. The reson is the thir g is fille y using eofill, n lternte for fill. If eofill h een use on the first g, the results woul hve een the sme n een orret figure The even-o rule uses the sme test line, rossing the pths s it leves the shpe. However, one is e every time pth is rosse. In the first n thir g ove, two pths re rosse, n even numer. It oesn t mtter wht iretion the pths re rwn in. In more omplex pths, the results re not s preitle s in figure 9 2. In figure 9 2, the first shpe is fille y fill, the seon y eofill. 72 figure Other exmples of the non-zero wining n the even/o rules n e foun in hpter 19, lirry of exmples. 9.4 lipping Clipping fores ll susequent pinting to pper only within the ounries of more on rwing 83

94 Tking Avntge of PostSript pth. An exmple of lipping re re the mrgins tht form the printle re on lser printer s pge. If something is rwn eyon tht ounry, it s lippe or roppe. All the pth onstrution opertors suh s lineto, r n urveto n e use to rete lipping pth. The lipping tion shoul e ple etween gsve n grestore to prevent it from ffeting ll tht follows in the progrm. The gsve n grestore n e onsiere in sense n on/off swith for the lip. All grphis fter the lip n the next grestore will e roppe y the lippth. lip shoul lso e followe y the newpth opertor. Otherwise, the lipping pth my get stroke or fille. In the exmple elow, the first ox n zigzg re for referene. No lipping is tking ple. In the seon position, the ox lippth followe y newpth lips the zigzg. The thir prt shows wht hppens when newpth is left out. The lippth is lso stroke n hlf its with is lippe wy. newpth initilizes the lippth from pinting ut oes not ffet the lip lern PS 9 5 %!PS-Aoe-2.0 EPSF-1.2 %%Title:lip_3.eps %%BouningBox: /ox /zg {0 0 moveto 72 0 rlineto 0 72 rlineto rlineto losepth} ef {6 setlinewith.333 setgry 0 74 moveto rlineto rlineto rlineto rlineto rlineto rlineto rlineto rlineto} ef trnslte ox stroke zg stroke 1 setlinewith 0 setgry gsve trnslte ox lip newpth zg stroke grestore 84 more on rwing

95 Chpter 9 gsve trnslte ox lip zg stroke grestore Other exmples of lipping n n exmple of the relte eolip n e foun in the lirry of exmples hpter. 9.5 setsreen Gry vlues re simulte on lser printers y rrnging the ots me y the printer into ptterns tht the eye sees s ifferent grys. The ots of the printer re groupe together to form ells. Within given re, if hlf the ots re use in eh ell, 50% gry is proue. The setsreen opertor ontrols the ot shpe of the ell n the frequeny (the numer of ells per inh) for the urrent olor. The efult for the NeXT lser printer, for exmple, is roun ot t 60 ells per inh t 0. The syntx for setsreen is: frequeny ngle proeure setsreen Where: frequeny is the numer of ells per inh. ngle is the ngle of the sreen in egrees. proeure ontrols the ot shpe of the ell. A numer of ifferent shpes re possile inluing squre, ovl n line ots. The size of the ot will epen on the vlue of the urrent olor. If the roun ot efult were hnge from 60 to 10 lines per inh n the ngle from 0 to 45, it woul e written s the following line of PostSript: {up mul exh up mul 1.0 exh su} setsreen It woul look like figure 9 3. figure 9 3 The setsreen opertor ssigns priority vlue to eh pixel of eh ell of the hlftone. The priority etermines the rrngement of pixels for eh ell. The more on rwing 85

96 Tking Avntge of PostSript mount of pixels use will epen on the gry vlue neee. The rker the gry, the more pixels use. If 400 pi lser printer were set to hve 40 ells per inh, eh ell woul e 10x10 or ontin 100 pixels. If you oul see one of those ells n hrt it, it woul look like figure 9 4. The 100 pixels re ivie into n x y xis with its enter s the origin or 0 0. Eh pixel hs n x y vlue. The upper right is lwys 1 1, the lower left is lwys -1-1, n so on. If the ell were 20x20, the intermeite x y lotions woul just oringly. The setsreen proeure uses these x y lotions to etermine n ssign eh pixel s priority figure The esiest setsreen proeure to use s n exmple is {pop}. pop isrs the top numer on the stk. If the pir of numers is.2.4, the.4 woul e the one on top of the stk euse it woul e the lst numer reeive. pop woul isr it leving.2. Looking t the hrt of the ell, pop woul isr ll the y vlues, leving eh pixel s x s the pixel s priority numer. The left row therefore will ll e -1, the next row re ll -.8, n so on own eh row (see figure 9 5) figure more on rwing

97 Chpter 9 Using this priority system, ifferent gry vlues will fill s in figure 9 6. figure % 30% 50% 80% Atul size, it will look like this: Other proeures will luster the pixels in the enter s roun, ovl, or squre ot. There re numer of possile ptterns ville. In ition, the setsreen will ffet hlftone pitures. 9.6 setsreen with hlftones The setsreen opertor will ffet the imging of ll gry vlues, inluing snne gry sle pitures. setsreen oes not ffet 1-it pitures. The ot pttern in this se is lrey etermine. In the two exmples elow, squres pinte with 20%, 40%, 60%, n 80% lk re next to snne gry sle piture. Other setsreen exmples n e foun in hpter 19, lirry of exmples. more on rwing 87

98 Tking Avntge of PostSript {pop} setsreen {up mul exh up mul 1.0 exh su} setsreen pthforll pthforll retrvels urrent pth n exeutes one of four proeures t eh instne of moveto, lineto, urveto, n losepth respetively. The syntx for pthforll is: movetopro linetopro urvetopro losepthpro pthforll Where: 88 more on rwing

99 Chpter 9 movetopro linetopro urvetopro losepthpro returns the x y lotion of the moveto then exeutes the movetopro proeure t every instne of moveto enountere. returns the x y lotion of the lineto then exeutes the linetopro proeure t every instne of lineto or rlineto enountere. returns the x y x 1 y 1 x 2 y 2 of the urveto n exeutes the urvetopro proeure t every instne of urveto or rurveto enountere. If the urve is me y the r, rn, or rto opertors, it will e onverte to the urveto equivlent. exeutes the losepthpro proeure t every instne of losepth. The x y oorintes returne re in user spe. The four proeures n perform ny opertion esire n n use the oorintes pushe on the stk. If the vlues re not use, they shoul e lere from the stk with the pop opertor. In the following exmple, I use pthforll to print the PostSript opertors use up to tht point. The lotion of eh lel is from the oorintes pushe onto the stk y pthforll. Note in the strt proeure the urrentpoint opertor. This pushes the x y oorintes of the urrent point fter the (moveto) show onto the stk to e use lter y the fin proeure. ontrol point 144 lineto urveto lineto 72 ontrol point lineto ontrol point moveto n losepth urveto ontrol point lern PS 9 6 %!PS-Aoe-2.0 EPSF-1.2 %%Title:pthforll_1.eps %%BouningBox: /strt{moveto (moveto) show urrentpoint} ef /line {moveto (lineto) show} ef /urve{moveto (urveto) show /Times-Itli finfont 8 slefont setfont more on rwing 89

100 Tking Avntge of PostSript 90 more on rwing moveto (ontrol point) show moveto (ontrol point) show /Helveti-Bol finfont 10 slefont setfont} ef /fin {moveto( n losepth) show} ef /pth {36 36 moveto lineto urveto 72 0 rlineto rn losepth} ef /Helveti-Bol finfont 10 slefont setfont 3 setlinewith 0.3 setgry pth stroke 0 setgry pth {strt} {line} {urve} {fin} pthforll newpth The following exmple uses pthforll in the sme wy s the esign Blst, foun in the eginning of hpter 2. All the musi notes re lote t the 3 pirs of x y for the urveto opertor generte y pthforll.

101 Chpter 9 lern PS 9 7 %!PS-Aoe-2.0 EPSF-1.2 %%Title:pthBlst.eps %%DoumentFonts:Sont %%BouningBox: moveto lineto lineto lineto losepth stroke / {100 rn exh mo} ef / {100 rn exh mo} ef / {200 rn exh mo} ef / {200 rn exh mo} ef /e {300 rn exh mo} ef /f {300 rn exh mo} ef /note {moveto (q) show} ef.5 setlinewith srn /Sont finfont 10 slefont setfont 0 0 moveto 100 { e f urveto} repet {pop pop}{pop pop}{note note note}{} pthforll stroke more on rwing 91

102 Tking Avntge of PostSript 92 the CTM

103 10 hpter Chpter 10 the CTM CTM is the ronym for the Current Trnsformtion Mtrix. The CTM n e thought of s the oorinte system. A 1 inh squre n e efine n expete to print s 1 inh squre. It will print s 1 inh squre s long s the CTM hs not hnge. If the oorinte system or mtrix is oule in size, the squre will pper to e twie its intene size when use. The sle opertor is one of severl PostSript opertors use to trnsform the mtrix in some wy. The most ommon CTM opertors re: trnslte moves the lotion of the origin or 0 0. sle hnges the size of the oorinte system or mtrix. rotte rottes the oorinte system or mtrix. ont n perform the trnslte, sle, n rotte trnsformtions ll in one ommn. In prtiulr, unerstning the ont opertor will e neessry efore getting into hpters 11, 12, 13, n 14. The onepts overe here will esily pply to those four hpters. Lerning these vrious trnsformtions n provie numer of interesting visul opportunities trnsltion of the origin trnslte ws introue riefly in hpter 3, setion 3.4. There it ws use to position squre t ifferent lotions on the pge. Often, using trnslte to move roun the pge is the est wy to orgnize esign. Hving onsistent referene point to work from n e very hny. It filittes proeures eing use in one esign to e use in nother. It is importnt to rememer tht trnslte trnsforms the CTM, whih is prt of the grphi stte. Consier this exmple. Three squres re ple, the seon n thir using trnslte to move the origin to etermine their plement. Note tht gsve n grestore re not use to sve the grphi stte etween plement of squres. The white retngle represents the pge, the ifferent gri ptterns represent lotions of the CTM y using trnslte. As you n see, you oul hve n imge ple off the pge. When this progrm is printe, s fr s you know, the thir squre oesn t exist. the CTM 93

104 Tking Avntge of PostSript lern PS 10 1 %!PS-Aoe-2.0 EPSF-1.2 %%Title:trnslte_1.eps %%BouningBox: /squre { 0 0 moveto 72 0 rlineto 0 72 rlineto rlineto losepth fill} ef.5 setgry squre trnslte squre trnslte squre By using gsve n grestore to sve n restore the originl CTM etween 94 the CTM

105 Chpter 10 trnsformtions me y the trnslte opertor, grphis n more preitly e ple on the pge sle sle expets two rguments, n x n y vlue where 1 = the existing size, 0.5 = hlf the size, n 2 is twie the size sle woul therefore ompress the x xis y hlf n oule the y xis. sle ws introue riefly in setion 3.5. There the sle opertor ws use to mke squres of vrious sizes. As mentione there, you n get yourself into troule y not refully noting where sle is sequene with other opertors n otin unexpete results. Stuy the following exmple n note on whih line 1 8 sle is entere lern PS %!PS-Aoe-2.0 EPSF-1.2 %%Title:sle_seq.eps %%BouningBox: /squre {0 0 moveto 72 0 lineto lineto 0 72 lineto losepth } ef gsve % first trnslte squre 1 8 sle % fter squre pth & trnslte stroke grestore gsve % seon trnslte 1 8 sle % fter trnslte, efore squre pth squre the CTM 95

106 Tking Avntge of PostSript stroke grestore gsve % thir 1 8 sle % efore trnslte, squre pth, & stroke trnslte % 8 x 4.5 = 36 squre stroke grestore 10.3 rotte As you might expet, rotte rottes the CTM. It expets one numer representing egree of rottion. A positive numer is ounterlokwise rottion n negtive numer is lokwise rottion. 0 is t the three o lok position. In the exmple elow, the first squre is norml, the seon is 45 rotte n the thir is -15 rotte. The rossing gry lines represent the hnge of lotion of the x y xis t the time the pth for squre is me n stroke PS lern %!PS-Aoe-2.0 EPSF-1.2 %%Title:rotte_1.eps %%Cretor:John F Shermn %%CretionDte:June 1990 %%BouningBox: /squre {0 0 moveto 72 0 lineto lineto 0 72 lineto losepth stroke} ef 3 setlinewith gsve trnslte squre grestore 96 the CTM

107 Chpter 10 gsve trnslte 45 rotte squre grestore gsve trnslte -15 rotte squre grestore As ws the se with sle, the sequene in whih rotte is use is very importnt. In the next exmple, rotte is use efore trnslte inste of fter. The sme egrees of rottion n trnsltion re use s in the previous exmple. Note the ifferene. Erlier we move the origin then rotte, now we rotte then move the origin. Agin the rossing gry lines represent the hnge of lotion of the x y xis PS lern 10 4 %!PS-Aoe-2.0 EPSF-1.2 %%Title:rotte_2.eps %%BouningBox: /squre {0 0 moveto 72 0 lineto lineto 0 72 lineto losepth stroke} ef 3 setlinewith gsve trnslte the CTM 97

108 Tking Avntge of PostSript squre grestore gsve 45 rotte trnslte squre grestore gsve -15 rotte trnslte squre grestore It lso mkes ifferene whether the urrent point for grphi is me efore or fter the rottion. Note when rotte is use in the exmple elow. A urrent oes not move with the rottion of the CTM rotte1 rotte2 PS lern %!PS-Aoe-2.0 EPSF-1.2 %%Title:rotte_3.eps %%BouningBox: /Times-Bol finfont 24 slefont setfont trnslte.5 setlinewith gsve % moveto fter rottion of CTM 45 rotte moveto (rotte1) show grestore gsve % moveto efore rottion, ut (rotte2) show is fter moveto 45 rotte (rotte2) show grestore 98 the CTM

109 Chpter ont The mnipultion of the urrent trnsformtion mtrix using ont will lso e useful in unerstning the mkefont, imge, n imgemsk opertors expline in lter hpters. The mtrix n e thought of s n elsti gri tht sles ll grphis to the pge. If the CTM were oule, everything woul print twie the intene size. The trnslte, sle, n rotte opertors hnge the CTM, n their three omine opertions n e one t one with the ont opertor. ont is more powerful ut it s less intuitive thn the other three. In figure 10 1 elow, irle is rwn on gri representing the CTM figure If tht gri ws sle to twie its norml size on the x xis, the with of the irle woul lso e twie its norml size. This oul hve een one with 2 1 sle ut it n lso e one with [ ] ont The first numer of the rry sles the x xis n the fourth numer sles the y xis. If we wnte the height of the irle to e oule, the mtrix rry woul e [ ]. Referring to the first n fourth numers, 1 is 100% or tul size,.5 is 50% n 3 is 300%. If there hs lrey een sle pplie to the CTM, the new trnsformtion will e in ition to the existing CTM. An exmple of the sle irle with ont follows: the CTM 99

110 Tking Avntge of PostSript lern PS 10 6 %!PS-Aoe-2.0 EPSF-1.2 %%Title:irle y2.eps %%BouningBox: setgry 4 setlinewith newpth r stroke 0 setgry [ ] ont newpth r stroke There re other trnsformtions possile with ont. The seon n thir numers skew the CTM up or own n left or right. Figure 10 2 is n exmple of skewing the x xis. The seon numer ontrols the ngle of the x xis n the thir ontrols the ngle of the y xis. Figure 10 2 is n exmple of [ ] ont. The 1 in the seon position of the mtrix rry skews everything up figure H the mtrix een [ ] ont, the shift woul hve een own 45. Unfortuntely, s you n see, the egree of the esire shift is not wht is entere into the mtrix. There is lultion se on the esire ngle θ (egree) tht nees to e one for the seon n thir numers. The tngent of θ is wht is require for the seon n thir positions of the mtrix rry. Appenix B ontins tle of tngent vlues for eh egree for onvenient referene. To rotte the x xis ounterlokwise 30, tn30, whih equls , is entere s the seon numer of the mtrix rry. In the following exmple, the squre is skewe 30 y the ont opertor. The lk line is rotte 30 y using rotte s referene. 100 the CTM

111 Chpter PS lern 10 7 %!PS-Aoe-2.0 EPSF-1.2 %%Title:ont_1.eps %%BouningBox: trnslte gsve % gry ox.5 setgry [ ] ont 0 0 moveto 0 72 lineto lineto 72 0 lineto losepth fill grestore gsve % lk line 3 setlinewith 30 rotte 0 0 moveto lineto stroke grestore If oth xes were skewe the sme egree n iretion, it woul pper tht we h me the equivlent of 30 rottion. Not quite, euse [ ] ont is not the sme s 30 rotte Even though 30 rottion hs ourre, the squre is no longer the sme size. Note the ifferene in the with n height of the squre in ont_1.eps. The with is now greter thn the height. This is esily seen in the next exmple. The sme squre is oule skewe for 30 rottion n norml 30 rottion. the CTM 101

112 Tking Avntge of PostSript PS lern 10 8 %!PS-Aoe-2.0 EPSF-1.2 %%Title:ont_2.eps %%BouningBox: trnslte /squre {0 0 moveto 0 72 lineto lineto 72 0 lineto losepth} ef gsve.5 setgry [ ] ont squre fill grestore gsve 30 rotte squre stroke 3 setlinewith 0 0 moveto lineto stroke grestore The proper metho of rottion with the ont opertor n e omplishe with this syntx: [osθ sinθ -sinθ osθ 0 0] ont whih is in this se [os30 sin30 -sin30 os30 0 0] ont The vlues use for this opertion n e foun in ppenix B. A rottion exmple follows: 102 the CTM

113 Chpter PS lern 10 9 %!PS-Aoe-2.0 EPSF-1.2 %%Title:ont&rotte.eps %%BouningBox: trnslte gsve % 30 egrees.5 setgry [ ] ont 0 0 moveto 0 72 lineto lineto 72 0 lineto losepth fill grestore gsve 3 setlinewith 30 rotte 0 0 moveto lineto stroke grestore A omine sle n rottion n e performe with the ont opertor in one mtrix rry. In the next exmple, the ox is rwn s 1 unit y 1 unit. Using ont, we n sle it to 72 y 72 n rotte it 30. The syntx for this mtrix is [s*osθ s*sinθ s*-sinθ s*osθ 0 0] ont where s is the sle ftor. Clulte, it will e: [ ] ont An exmple follows: the CTM 103

114 Tking Avntge of PostSript lern PS %!PS-Aoe-2.0 EPSF-1.2 %%Title:ont_r&s.eps %%BouningBox: trnslte gsve.5 setgry [ ] ont 0 0 moveto 0 1 lineto 1 1 lineto 1 0 lineto losepth fill grestore gsve 3 setlinewith 30 rotte 0 0 moveto lineto stroke grestore Finlly, the fifth n sixth numers of the mtrix rry perform trnsltion. In the next exmple, the trnslte is use only y the rotte line. The squre is positione y the ont opertor the CTM

115 Chpter 10 PS lern %!PS-Aoe-2.0 EPSF-1.2 %%Title:ont_ll.eps %%BouningBox: gsve.5 setgry [ ] ont 0 0 moveto 0 1 lineto 1 1 lineto 1 0 lineto losepth fill grestore gsve trnslte 3 setlinewith 30 rotte 0 0 moveto lineto stroke grestore the CTM 105

116 Tking Avntge of PostSript 106 vne type

117 11 hpter Chpter 11 vne type The previous hpter on type only overe the sis of working with type. There re numer of powerful PostSript opertors for moifying fonts n kerning fonts. Kerning is performing ustom hrter sping for etter legiility, form, or speil effet. For exmple, the lower se o is spe ifferently in the wors Do n To. Creful ttention to kerning woul tuk the o uner the T for proper lettersping moifying existing fonts As isusse in hpter 7, the outlines of fonts re store s 1 point outlines. To e more preise, they re store within mtrix tht sles it to 1 point squre. This mtrix is inepenent of the CTM, ut ts in muh the sme wy. In hpter 10, we mnipulte the CTM with the ont opertor. The font mtrix is mnipulte with the mkefont opertor. The next two PostSript frgments re equivlent: /Helveti-Bol finfont 100 slefont setfont /Helveti-Bol finfont [ ] mkefont setfont The mkefont opertor expets mtrix rry tht ts in the sme wy s the mtrix rry use with ont. The first numer of the rry represents the x sle, the fourth numer represents the y sle. The other four remining numers lso t the sme s expline in setion TTTT T PS lern 11 1 %!PS-Aoe-2.0 EPSF-1.2 %%Title:mkefont_1.eps %%BouningBox: /Helveti-Bol finfont [ ] mkefont setfont vne type 107

118 Tking Avntge of PostSript 0 0 moveto (T) show /Helveti-Bol finfont [ ] mkefont setfont moveto (T) show /Helveti-Bol finfont 100 slefont setfont moveto (T) show /Helveti-Bol finfont [ ] mkefont setfont moveto (T) show /Helveti-Bol finfont [ ] mkefont setfont moveto (T) show All the Ts ove re Helveti-Bol 100 point, t lest in height. The first is sle 150%, the seon 125%, the thir is norml, the fourth is onense 75%, n the fifth is onense 50%. The Helveti-Nrrow font on the LserWriter Plus is onense in this fshion (see setion 15.3). It is not seprte rwing of Helveti like Helveti Conense, ut mthemtilly onense version of the font. In the next exmple, the thir numer of the mtrix rry is given vlue n the first n fourth re set to 100. The thir numer of the mtrix skews the y xis left n right. The numer unfortuntely oes not represent the ngle tht the mtrix is skewe (see 10.4). It is the prout of this eqution: y tnθ See the preeing hpter for etile informtion on mtrix mnipultion. TTTTT lern PS 11 2 %!PS-Aoe-2.0 EPSF-1.2 %%Title:mkefont_2.eps %%BouningBox: /Helveti-Bol finfont % -45 [ ] mkefont setfont 75 0 moveto (T) show /Helveti-Bol finfont % -20 [ ] mkefont setfont moveto (T) show /Helveti-Bol finfont 100 slefont setfont 108 vne type

119 Chpter moveto (T) show % norml /Helveti-Bol finfont % 20 [ ] mkefont setfont moveto (T) show /Helveti-Bol finfont % 45 [ ] mkefont setfont moveto (T) show All the Ts ove re gin Helveti-Bol 100 point in size. The first T is olique 45, the seon is 20, the thir is norml, the fourth is t 20, n the fifth is t 45. In the next exmple, the letterforms get strethe more rmtilly when the x xis is skewe. Agin, the type is the equivlent of 100 point. Now the seon igit of the mtrix rry is hnge. The numer is rrive t in the sme wy s efore, exept the ngle movement will e up n own. This exmple is written ifferently to help keep trk of where the urrent point is lote for eh T. An X is rwn t eh T s origin for point of referene. Even though the origins of the Ts mke horizontl row, the selines of the Ts in effet rotte euse of the skewing of the x xis. All the Ts elow re gin Helveti-Bol 100 point. The first T is olique 45, the seon is 20, the thir is norml, the fourth is t 20, n the fifth is t 45. T TTTT lern PS 11 3 %!PS-Aoe-2.0 EPSF-1.2 %%Title:mkefont_3.eps %%BouningBox: /x {-6-6 moveto 6 6 lineto stroke -6 6 moveto 6-6 lineto stroke} ef.5 setgry % kgroun 0 0 moveto lineto lineto lineto losepth fill vne type 109

120 Tking Avntge of PostSript trnslte 1 setgry % seline 0 0 moveto rlineto stroke 0 setgry.5 setlinewith /Helveti-Bol finfont % -45 [ ] mkefont setfont x 0 0 moveto (T) show 70 0 trnslte /Helveti-Bol finfont % -20 [ ] mkefont setfont x 0 0 moveto (T) show 70 0 trnslte % norml /Helveti-Bol finfont 100 slefont setfont x 0 0 moveto (T) show 70 0 trnslte /Helveti-Bol finfont % 20 [ ] mkefont setfont x 0 0 moveto (T) show 70 0 trnslte /Helveti-Bol finfont % 45 [ ] mkefont setfont x 0 0 moveto (T) show 11.2 lettersping with show The four PostSript kerning opertors re show, withshow, withshow, n kshow. Eh provies ifferent opportunities. In hpter 18 on PostSript Level 2, there re four itionl type opertors. show provies mens to or sutrt overll hrter sping oth vertilly n horizontlly. The syntx for show is: x y string show Where: x s or sutrts spe horizontlly in the string. y s or sutrts spe vertilly in the string. string is the hrters or wors ffete. In the following exmple, string is tightene, strethe, n shifte vertilly. The vertil justment is typilly use y non-romn fonts. 110 vne type

121 Chpter s 72 spe sutrts spe steps up lern PS 11 4 %!PS-Aoe-2.0 EPSF-1.2 %%Title:show_1.eps %%BouningBox: /Pltino-Romn finfont 36 slefont setfont moveto 6 0 (s spe) show moveto -6 0 (sutrts spe) show moveto 0 6 (steps up) show 11.3 kerning with withshow withshow kerns single hrter within string. Its syntx is: x y hrter string withshow Where: x s or sutrts horizontl spe fter the hrter. y s or sutrts vertil spe fter the hrter. hrter is either ientifie y its eiml or otl hrter oe from the ASCII hrt. See ppenix A. In the next exmple, the spe is reue fter the W, whih therefore rings the A loser. The only ifferene etween the two WASHINGTONs is tht the top W is ientifie y the eiml 87 n the ottom W y the otl 127. The efult ientifition is eiml. If otl oe is use, it nees the 8# prefe s lel. vne type 111

122 Tking Avntge of PostSript 144 WASHINGTON 72 WASHINGTON lern PS 11 5 %!PS-Aoe-2.0 EPSF-1.2 %%Title:withshow_1.eps %%BouningBox: /AvntGre-Demi finfont 48 slefont setfont moveto % Deiml tle (WASHINGTON) withshow moveto % Otl tle #127 (WASHINGTON) withshow 11.4 kerning with withshow withshow is the omintion of show n withshow. It oth kerns single hrter within string n s or sutrts overll hrter sping oth vertilly n horizontlly. Its syntx is: x y hrter x s y s string withshow Where: x y s or sutrts horizontl spe fter the hrter. s or sutrts vertil spe fter the hrter. hrter is either the eiml or otl hrter oe for the hrter. x s y s s or sutrts horizontl spe in the string. s or sutrts vertil spe in the string. In the next exmple, the wor Typogrphy on top is set normlly with show. In the mile n ottom, the spe fter the T is reue to kern the y unerneth n overll hrter sping is tightene y 1 point. Agin, the hrter kerne is ientifie y its eiml or otl hrter oe. 112 vne type

123 Chpter Typogrphy Typogrphy 72 Typogrphy lern PS 11 6 %!PS-Aoe-2.0 EPSF-1.2 %%Title:withshow 1.eps %%BouningBox: /AvntGre-Demi finfont 48 slefont setfont moveto (Typogrphy) show % using Otl tle moveto # (Typogrphy) withshow % using Deiml tle moveto (Typogrphy) withshow 11.5 kshow The kshow opertor hs muh ifferent strtegy for kerning thn the previous three PostSript opertors. Its syntx is: proeure string kshow The proeure is exeute fter the positioning of eh hrter. In the next exmple, two ifferent proeures re performe on the sme wor. In the top wor, the hrter sping of RAINBOW is omplishe y using the proeure -3 0 rmoveto. After R is positione, the new urrent point is move to the right of its hrter with. The proeure -3 0 rmoveto shifts the urrent point left 3 points. Other mnipultions esies the justment of the urrent point n our within vne type 113

124 Tking Avntge of PostSript the proeure. With the RAINBOW on the ottom, the proeure lso hnges the urrent gry etween eh hrter setting. Any numer of tions n e performe fter eh hrter. The intention of this opertor, however, is to give the opportunity to iniviully kern the hrters of string. Thus its nme, kernshow. To omplish this iniviul kerning fter eh hrter of the string (exept the lst), two numers re pushe onto the stk. In the se of RAINBOW, fter the R is set, the eiml oes for R n A re pushe onto the stk. They re 82 n 65. After the A is set, the eiml oes for A n I re pushe onto the stk. This ours fter eh hrter of the string exept for the lst. These numers n e use y the proeure to mke ustom sping eision se on whih two hrters re esie eh other. This omprison is not neee fter the lst hrter. If unuse, these numers re left on the stk: Sine they re not use y the proeure in this exmple, we nee to isr them. This is one with the 12 {pop} repet. The numers n lso e isre within the kshow proeure. RAINBOW RAINBOW PS lern %!PS-Aoe-2.0 EPSF-1.2 %%Title:kshow_1.eps %%BouningBox: /AvntGre-Demi finfont 72 slefont setfont moveto {-3 0 rmoveto} (RAINBOW) kshow 12 {pop} repet.9 setgry moveto {urrentgry.12 su setgry pop pop} (RAINBOW) kshow Another exmple follows: 114 vne type

125 Chpter M*A*S*H PS lern 11 8 %!PS-Aoe-2.0 EPSF-1.2 %%Title:M*A*S*H.eps %%BouningBox: /Helveti-Bol finfont 72 slefont setfont % proeure lowers the sterisk & then returns to seline /putasterisk {0-14 rmoveto (*) show 0 14 rmoveto pop pop} ef moveto {putasterisk} (MASH) kshow vne type 115

126 Tking Avntge of PostSript 116 the imge opertor / sn

127 12 hpter Chpter 12 the imge opertor / sn The imge opertor is use to ontrol pinting snne pitures. It n lso e use to rete vriety of ptterns n lens. Disussion of the imge opertor will e ivie over two hpters. This hpter onentrtes on snne pitures n hpter 13 will fous on reting ptterns n lens. In hpter 14, the imgemsk opertor, vrition of imge, will e expline introution The imge opertor n reeive the t for the piture it retes from numer of soures. The most ovious soure woul e the t from snner of some kin. In setions 12.3 n 12.4, the tritionl use of the imge opertor is expline with first very simple piture of shmrok n then snne piture. The other soure of t n e provie y the progrmmer. The provie t is usully some ritrry hrters tht n rete pttern or the mens to rete smooth len of olor. See hpter 13. In ll ses, either snne t for piture or ritrry hrters for pttern, t quisition proeure of some kin is neee. A t quisition proeure ontrols how the imge opertor reeives or retes the informtion neee to pint piture. The syntx of imge is: with height its mtrix pro imge Where: with is the with of the piture in ells or pixels. height is the height of the piture in ells or pixels. its is the numer of its of informtion per ell or pixel. It n e 1, 2, 4, or 8. mtrix is the piture s oorinte system. pro is the t quisition proeure tht otins or retes the piture t. imge is the PostSript opertor. the imge opertor / sn 117

128 Tking Avntge of PostSript 12.2 simple igitize pitures Snne pitures n e thought of s omplex pint y numer oloring projet iviing piture into little squres. Eh squre, or pixel, woul hve oe ssigne to it se on the vlue or the olor it represents. The pixels woul e rrnge into rows n olumns tht woul e use to esrie the piture s with n height. When the piture is pinte y the imge opertor, imge uses one of four oing shemes to pint the pixel prtiulr vlue. Depening how the piture ws originlly snne, the piture n e pinte s 1-it, 2-it, 4-it, or 8-it piture. This is the oing sheme for lk n white piture. Color pitures woul e multiples of this. The ifferene etween eh of these oing shemes is the numer of ifferent grys they n proue. The size of the file inreses s the numer of its inrese. These re the possile its n wht they n represent: 1-it 2 grys. Atully either lk or white. Vlue is either 0 or 1. 2-it 4 grys. Blk, white, n 2 intermeite grys. Vlue is either 0, 1, 10, or 11 (ounting from eiml 0 to 3 in inry). 4-it 64 grys. Blk, white, n 62 intermeite grys. 8-it 256 grys. Blk, white, n 254 intermeite grys. The its tht we re using to esrie vlue re inry its. Binry is numering system tht only uses 0 n 1. In 1-it oing, the vlue of the pixels will e either 0 or 1. 0 is the oe for lk, 1 the oe for white. We ll ome k to the other its lter. Looking further t 1-it piture, figure 12 1 represents piture ivie into 256 pixels. There re 16 rows n 16 olumns. figure If you follow the oloring ssignments n pint the 0s lk n the 1s white, piture will emerge. See figure the imge opertor / sn

129 Chpter 12 figure It s the jo of the snner to get ll this for you. Otherwise, it woul e mjor jo to onstrut piture. The snner uses the intensity of light reflete k from piture to ssign vlue to eh piture. The numer of its the snner s softwre is set for will etermine how the light is ivie. Appenix A is n ASCII tle of five ifferent oing shemes, eh ifferent wy of ounting from 0 to 255. In prtiulr, we re intereste in ASCII, hexeiml, n inry oe ssignments. The ASCII tle ontins our lphet within the 256 entries. Note tht there isn t visile hrter for ll 256. Hexeiml ounts from 0 to 256 using only the numers 0 9 n the hrters A F. The inry ounts from 0 to 255 in inry (using 0 n 1). The imge opertor uses the inry tle to give pixels vlue. It stores the pixel vlue s either ASCII or hexeiml t. As mentione efore, 0 n 1 re the two possile vlues for it. In the 1-it oing sheme, 0 n 1 represent lk n white. Eh entry of the inry tle of ppenix A ontins 8 its. Therefore, eh entry of the tle n represent 8 pixels of piture using the 1-it oing sheme. The first 8 pixels strting t the lower left of figure 12 2 hve the vlues Consulting ppenix A, will e foun t eiml 255. There isn t visile hrter in the ASCII tle n it s FF in hexeiml. Therefore, the first 8 pixels of figure 12 2 n e sve s either ASCII 255 or hexeiml FF. See figure 12 3 elow. This oing woul ontinue for every row of the piture. figure This inry is represente y ASCII 31 or Hexeiml 1F This inry is represente y ASCII 255 or Hexeiml FF { {1 The ASCII tle ontins the hrters tht my e type from stnr omputer keyor plus mny other speil hrters whose lotion my vry from one system to nother suh s Ë or ß. There re totl of 256 possile hrters. The iffiulty in using the ASCII tle in esigning the shmrok_1.eps exmple ws hving visile ASCII hrter for mny of the prtiulr inry ptterns neee. Therefore, in the next exmple hexeiml ws the imge opertor / sn 119

130 Tking Avntge of PostSript use. However, mny snners sve their files using the ASCII tle euse the file will e hlf the size. At eiml 97, there is the ASCII hrter (1 yte of storge), n the hexeiml 61 (2 ytes of storge). The following is n exmple of how figure 12 2 woul e written s PostSript progrm. It is not snne piture, ut it is written in the sme wy snne piture woul e written, only on smller sle. Setion 12.3 will emonstrte how the sme tehnique is pplie to snne photogrph. lern PS 12 1 imge emo %!PS-Aoe-2.0 EPSF-1.2 %%Title:shmrok_1.eps %%BouningBox: /pistr 2 string ef /shmrok { [ ] {urrentfile pistr rehexstring pop} imge } ef shmrok FF 1F FE 3F 9E 39 0E F F0 0F E0 07 E0 07 F0 0F % frme 0 0 moveto lineto lineto lineto losepth stroke In shmrok_1.eps ove, the proeure /shmrok is efine y the imge opertor n its operns. Figure 12 4 lels the rguments (require informtion for n opertor) for the imge opertor. 120 the imge opertor / sn

131 Chpter pixels wie 16 pixels high 1 it per pixel mtrix:.1 mkes eh pixel 10 points in size figure [ ] {urrentfile pistr rehexstring pop} imge t quisition proeure PostSript opertor Let s look loser t eh rgument for imge: The with n height re the numer of ells wie n high for the piture. In the exmple ove, the piture's with n height is 16 y 16 pixels. The its vlue is 1 sine the piture is 1-it piture. Next is the mtrix rry whih etermines the size of the piture. This mtrix rry opertes ifferently with imge thn for ont (setion 10.4) n mkefont (setion 11.1). With ont n mkefont, if we wnte n ojet lrger, we woul hve use lrger numer in the first n fourth position of the rry. Here it is the opposite; smller numer is use. The lultion is ifferent with imge euse of ifferene in how it hnles pitures. It n e expline in this wy. H the mtrix rry een [ ], the shmrok woul e s shown in figure figure 12 5 Figure 12 5 is this size euse the 1 in the [ ] mtrix rry mens eh pixel is tul size. The 16x16 pixel with n height will mesure 16x16 points. A 16x16 pixel with n height using [ ] mtrix is 160x160 points. This is rrive t y iviing 16 y.1 equling 160, n 160 ivie y 16 equls 10. With imension of 160x160, n the ells with n height eing 16x16, we then know the iniviul pixels will e 10 points squre. If the mtrix rry h een [ ] the pixels woul e 5 points squre. {urrentfile pistr rehexstring pop} is the t quisition proeure for the imge opertor. urrentfile ientifies tht the t for the piture will follow fter shmrok is use in the progrm. /pistr efines spe lrge enough for string two hrters long. pistr is temporry holing ple for the t for eh row of the piture. The first two hrters tht mke up the first row of the shmrok re the two hexeiml hrters FF n 1F. They represent the two sets of inry hrters n rehexstring ientifies tht the t is in hexeiml. pop lers the pistr so the proeure n e repete. The proeure is repete until the 16 rows of t in inrements of two re fille. Writing the progrm in this wy permits ll the t for the piture to follow the PostSript ommns tht ontrol its pinting. In most ses, snne pitures re very lrge files. Hving the t follow PostSript heer permits esier eiting of the progrm. the imge opertor / sn 121

132 Tking Avntge of PostSript 12.3 snne pitures This piture ws otine y using snner n sving the file in PostSript formt y its softwre. I hve eite the PostSript from its originl form supplie y the snning softwre. The originl file h efinitions to ommote numer of ifferent snning situtions n I wish to fous on the si similrity with the previous shmrok exmple. The progrm tht proue the piture follows, minus the piture t to sve spe. It woul hve tken up out eight pges. PS lern 12 2 %!PS-Aoe-2.0 EPSF-1.2 %%Title:relief.eps %%BouningBox: /height 225 ef /with 224 ef /nheight height neg ef /pistr 112 string ef /mkepiture { with height 4 [with 0 0 nheight 0 height] { urrentfile pistr restring pop } imge } ef gsve {1 exh su} settrnsfer with height sle mkepiture ˇˇˇˇˇ fl ªª ª ª ª πógfutvueddugfyzô flfl 25.6K of piture t, et Ì Ì ª ö óyxºããfiˇˇˇˇ à õœˇˇ ºÃÕà º Ôˇ grestore 122 the imge opertor / sn

133 Chpter 12 This progrm is silly the sme s shmrok_1.eps ut with few ifferenes. First, mny of the vlues hve een given nmes suh s height n with. This setion of the progrm is written y the snning softwre so the sme file eginning n e use for every file it retes. height efines the height of the piture to e 225. with efines the with of the piture to e 224. nheight efines height to hve negtive vlue. The reson for this is mny snners igitize from the top own s oppose to from the ottom up. Hving the trnsformtion mtrix e [with 0 0 nheight 0 height] justs for this y flopping the piture. pistr, s isusse t the en of setion 12.2, is holing spe for string. In this efinition, the holing ple is 112. This woul hol enough t for one row of the piture. mkepiture efines the imge opertion s shmrok i for the shmrok_1.eps exmple erlier. with height 4 [with 0 0 nheight 0 height] is the sme s [ ]. The piture is 4-it piture (64 grys) n the mtrix rry mps it, so it is very smll. To get it to the right size, with height sle sles the piture up to {1 exh su} settrnsfer inverts the piture. Without this line, the piture woul pper s negtive. This ompenstes for the wy the snner sns the piture seon version of shmrok The previous exmple, relief.eps, is 4-it piture. To emonstrte how 4-it n 8-it pitures work with their t, the next exmple is version of shmrok written s 2-it piture. A 4-it n 8-it version woul e similr. the imge opertor / sn 123

134 Tking Avntge of PostSript lern PS 12 3 %!PS-Aoe-2.0 EPSF-1.2 %%Title:shmrok_2.eps %%BouningBox: /pistr 4 string ef /shmrok { [ ] {urrentfile pistr rehexstring pop} imge} ef shmrok A A0 2A A9 42 A0 2A A8 2A A A A Figure 12 6 enlrges the first two rows of shmrok_2.eps for etter look t the it vlues. 10 is light gry, 01 is rk gry, 00 is lk, n if there h een 11 it woul e white figure { { This inry is represente y ASCII 064 or Hexeiml 40 This inry is represente y ASCII 085 or Hexeiml the imge opertor / sn

135 Chpter 12 In 1-it piture, 8 its is the t for 8 pixels. In 2-it piture, 8 its is the t for 4 pixels. With 4-it, it s 2 pixels n with 8-it, it s one pixel. This is overe more in the next hpter. When piture is snne, the tre-off will e the size of the file versus the qulity of the piture. Figure 12 7 is photogrph ivie into four vertil segments, 1-it, 2-it, 4-it, n 8-it in orer. The 1-it setion is out 4.5 K n the 8-it is just over 26K. figure 12 7 the imge opertor / sn 125

136 Tking Avntge of PostSript 126 the imge opertor / ptterns

137 Chpter hpter the imge opertor / ptterns In this seon hpter on the imge opertor, it will e shown how imge n e retively use for mking ifferent kins of ptterns n for mking fountins, lso known s lens or rmps. See lso the next hpter on imgemsk whih n lso e use for mking ptterns reting ptterns with the imge opertor shmrok_2.eps oul e written in suh wy s to proue vrious ptterns. In shmrok_2.eps the t for shmrok ws only use one. However, if the height (or numer of rows) were to e oule n nme given to the t for shmrok, the piture oul e use twie to fill the spe. lern PS 13 1 %!PS-Aoe-2.0 EPSF-1.2 %%Title:shmrokTwie_1.eps %%BouningBox: /shmrok < A A0 2A A9 42 A0 2A A8 2A A A A > ef [ ] { shmrok } imge the imge opertor / ptterns 127

138 Tking Avntge of PostSript H the sme thing een one with shmrok_1.eps, isster woul strike. lern PS 13 2 %!PS-Aoe-2.0 EPSF-1.2 %%Title:shmrokTwie_2.eps %%BouningBox: /pistr 2 string ef /shmrok { [ ] {urrentfile pistr rehexstring pop} imge} ef shmrok FF 1F FE 3F 9E 39 0E F F0 0F E0 07 E0 07 F0 0F % frme 0 0 moveto lineto lineto lineto losepth stroke It looks like this euse rehexstring will gole up everything fter shmrok is use, inluing the 0 0 moveto lineto lineto lineto losepth stroke looking for piture t. An error will our euse the t ville n the efine piture size o not mth imgewor.eps Similr to shmroktwie_1.eps, the following is PostSript progrm using the imge opertor to mke pttern: 128 the imge opertor / ptterns

139 Chpter 13 lern PS 13 3 %!PS-Aoe-2.0 EPSF-1.2 %%Title:imgeWor.eps %%BouningBox: /wor (John) ef [ ] { wor } imge In the piture ove, the inry for the wor John is repetely use until retngle 24 y 10 is forme s shown in figure figure 13 1 { { { { J o h n { { The inry for the wor John is: or J or o (two gry then two white) or h or n The wor just one woul look like this: Looking t the progrm gin, the strip ove is use over n over gin until the piture retngle is omplete. If /wor ove were to e reefine to (John S), it woul look like figure figure 13 2 the imge opertor / ptterns 129

140 Tking Avntge of PostSript It ppers stripe euse the 6 hrters of (John S) ivie evenly into the 24 pixel with of the piture. The previous exmples of imgewor.eps use the piture t to mke 2-it imge, mening every pixel of the piture hs 2 its of informtion, or four possile vlues. A pixel is n iniviul squre of vlue. For exmple, the inry for J is n it will e ivie into four prts ontining 2 its eh s The numer 01 represents rk gry, n 10 light gry, 00 represents lk, n 11 is white. A 2-it piture therefore n only hve 4 levels of gry: lk, white, n two grys. Shoul J e use in 1-it piture, J woul look like this: s 1-it piture is lk, white, lk, lk, white, lk, white, lk. A 1-it piture hs 2 possile levels lk n white. The monitor of the Mintosh Plus n SE omputers is 1-it sreen. The pixels on the sreen re either lk or white. MPint retes 1-it pitures. A 4-it piture woul hve 64 gry levels. The inry for J in this se woul e the informtion for two pixels of piture. One woul e 0100 n the other woul e 1010, representing 2 grys out of possile 64. It woul look like this: An 8-it piture woul hve 256 gry levels. The entire woul e use to represent single gry level. Blk is n white is In etween, there woul e 254 ifferent omintions of 0s n 1s for totl of 256 levels of gry lern PS eps The following re hrts for N, e, X, n T showing how the inry for eh hrter woul e pinte s 1, 2, 4, n 8-it piture. The vertil line mrks off the numer of times the letter is use. The PostSript progrm listing for eps n e foun t the en of ppenix A (N)<4E> 1 it 2 it 4 it 8 it (e)<65> 1 it 2 it 4 it 8 it 130 the imge opertor / ptterns

141 Chpter (X)<58> 1 it 2 it 4 it 8 it (T)<54> 1 it 2 it 4 it 8 it 13.4 rnom ptterns Another exmple of t quisition proeure is the progrm tht retes rnom pttern within ertin rnge of grys. PS lern 13 5 %!PS-Aoe-2.0 EPSF-1.2 %%Title:pttern_1.eps %%Cretor:John F Shermn %%CretionDte:July 1989 %%BouningBox: /str 512 string ef /pttern {/light exh ef /rk exh ef /iff light rk su ef the imge opertor / ptterns 131

142 Tking Avntge of PostSript [ ] { {str exh rn iff mo rk put} for str} in imge } ef 222 srn pttern Next is version of the pttern proeure tht limits the vlues to etween 33 n 125. We ll next explin this exmple line y line. A review of the isussion of the for n put opertors in setion 8.3 might e helpful. PS lern 13 6 %!PS-Aoe-2.0 EPSF-1.2 %%Title:expttern1.eps %%BouningBox: /str 20 string ef /pttern {/light exh ef /rk exh ef /iff light rk su ef [ ] { {str exh rn iff mo rk put} for str }imge} ef 178 srn pttern This pttern is n 8-it, 20x4 piture. Sine it is n 8-it piture, eh row is rete y 20 hrters of t. A totl of 80 hrters will e neee for the entire piture. As expline in setion 12.2, eh hrter of the ASCII tle represents gry vlue somewhere etween 0 n is lk n 255 is white. Tht mens hrter 33 woul e the equivlent of.128 setgry or 87.2% lk n hrter 125 woul e 51.2% lk. The jo of the pttern t quisition proeure is to rnomly rete string of 20 hrters tht re lwys etween 33 n 125. I use this rnge euse it is portion of the ASCII tle with visile hrters. The first line /str 20 string ef efines string 20 hrters in length, initilly with the vlue of ( ) Next egins the efinition for the pttern proeure. The first line of the proeure efinition is /light exh ef /rk exh ef whih efines the top two vlues on the opern stk to e light n rk. In this exmple, looking he to the lst line of the progrm, light will e efine s 125 n rk will e will e on top of the stk with 33 elow it. 132 the imge opertor / ptterns

143 Chpter 13 The seon line of the proeure efines iff s the sutrtion of rk from light, whih will in this se e 92. Next, [ ] re the first rguments for the imge opertor, setting up the piture to e 20 y 4 pixels, with eh pixel to hve n 8-it vlue n the mtrix rry etermining the size of the piture. Next is the t quisition proeure: {str exh rn iff mo rk put} for This line retes string 20 hrters in length, eh of whih is hrter tht flls etween 33 n 125 on the ASCII hrt. Breking this line own, fter the first ount of the for loop, 0 then str (whih is ( )) will e on top of the stk. exh will swith those positions so tht 0 is on top. Zero will e use lter s the inex for the put opertor. rn retes rnom numer, whih will e on the first go roun. (Don t worry for now out how I know tht. See hpter 16.) The rnom numers proue here re reprouile sequene of numers se on the 178 srn it lter in the progrm. Tht is, the rnom sequene will lwys e the sme unless 178 is hnge (it my e ifferent repetle sequene on your mhine). Next, iff ws efine erlier to e 92. After tht is the opertor mo, whih returns to the stk the reminer of ivision. In this se, it is the ivision of y 92, whih hs reminer of 82 (roune off). Then omes rk, efine erlier s 33 n whih s the 82 n 33 giving you 115. Cheking the ASCII tle, 115 is the hrter s. The str looks like this fter the first ount of for: ( ) put whih eomes (s ) This proess is repete until str is fille with 20 hrters. Then str is use s t for the first row of the piture y the imge opertor. Speifilly, the first 20 hrters in str woul e: sfy.+g=oqy,/xr4=4 lern PS 13 7 This ws rrive t y printing the string inste of using it s t for the imge opertor. %!PS-Aoe-2.0 EPSF-1.2 %%Title:seepttern1.eps %%BouningBox: /Times-Bol finfont 16 slefont setfont /str 20 string ef /pttern {/light exh ef /rk exh ef /iff light rk su ef {str exh rn iff mo rk put} for} ef 178 srn pttern % rete 20 etween 33 & moveto str show the imge opertor / ptterns 133

144 Tking Avntge of PostSript.25 setlinewith %frme 0 0 moveto lineto lineto 0 30 lineto losepth stroke This progrm woul look like figure figure 13 3 H only the one line, sfy.+g=oqy,/xr4=4, een use for the piture, repeting pttern woul emerge (figure 13 4) euse the sme string woul e use over n over until the with n height were stisfie. figure 13 4 However, the pttern t quisition proeure ontinully retes new 20 hrter string. The proeure h first rete: sfy.+g=oqy,/xr4=4 whih is use to pint 20 pixels in the first row. The proeure then retes: AMsD;,G=#_m`S_,IW-_@ for the 20 pixels of the seon row, looking like figure 13 5 t this point. figure 13 5 An so on until the piture is omplete. The next exmple shows how pttern n look t ifferent vlue rnges. lern PS 13 8 %!PS-Aoe-2.0 EPSF-1.2 %%Title:pttern_y4.eps %%Cretor:John F Shermn 1989 %%CretionDte:July 1989 %%BouningBox: /str 512 string ef /pttern {/light exh ef /rk exh ef /iff light rk su ef [ ] 134 the imge opertor / ptterns

145 Chpter 13 { {str exh rn iff mo rk put} for str} in imge } ef 222 srn 0 75 pttern 80 0 trnslte pttern 80 0 trnslte pttern 80 0 trnslte pttern 13.5 vritions on the ptterns Vritions of the pttern proeure n e hieve y hnging the it vlue for the imge opertor. The onfinement of the piture to e within ertin rnges of gry iminishes s the its level gets smller, ut ifferent textures re proue. Below, the first row of ptterns re 1-it, followe y 2, 4, n 8-it. lern PS 13 9 %!PS-Aoe-2.0 EPSF-1.2 %%Title:ptternVr1.eps %%Cretor:John F Shermn %%BouningBox: the imge opertor / ptterns 135

146 Tking Avntge of PostSript /str 512 string ef /pttern {/light exh ef /rk exh ef /iff light rk su ef 7 7 its [ ] { {str exh rn iff mo rk put} for str} in imge} ef srn /its 8 ef gsve % ottom row 0 75 pttern 80 0 trnslte pttern 80 0 trnslte pttern 80 0 trnslte pttern grestore /its 4 ef gsve % seon row 0 80 trnslte 0 75 pttern 80 0 trnslte pttern 80 0 trnslte pttern 80 0 trnslte pttern grestore /its 2 ef gsve % thir row trnslte 0 75 pttern 80 0 trnslte pttern 80 0 trnslte pttern 80 0 trnslte pttern grestore /its 1 ef gsve % top row trnslte 0 75 pttern 80 0 trnslte pttern 80 0 trnslte pttern 80 0 trnslte pttern grestore You n hnge the mtrix s expline erlier in setion In the next exmple, hving the mtrix e [ ] skews the squre pttern 45 to the right. Then the skewe squre is use eight times s it is rotte in 45 inrements. 136 the imge opertor / ptterns

147 Chpter 13 lern PS %!PS-Aoe-2.0 EPSF-1.2 %%Title:ptternVr2.eps %%Cretor:John F Shermn %%BouningBox: /str 512 string ef /pttern {/light exh ef /rk exh ef /iff light rk su ef [ ] { {str exh rn iff mo rk put} for str} in imge} ef srn retstroke trnslte gsve 8 {45 rotte pttern} repet grestore 13.6 fountins Fountins, lso known s rmps or lens, n e rete with the imge opertor. The t quisition proeure in this se retes single string orere from the the imge opertor / ptterns 137

148 Tking Avntge of PostSript ASCII hrt s eginning to en to rete trnsition of vlue. The first hrter of the hrt is lk, the lst is white. The t quisition proeure is onvenient mens to orer ll 256 hrters. We oul see tht string y printing it inste of using it s the t for the imge opertor. This is silly the sme progrm tht ws seen k in setion 8.3 when the for n put opertors were expline.!"#$%& ()*+,-./ :;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_ efghijklmnopqrstuvwxyz{ }~ ƒ ' «fifl» ` ˆ ˇ Æ ª ŁØŒº æ ı łøœß lern PS %!PS-Aoe-2.0 EPSF-1.2 %%Title:seefountin_1.eps %%BouningBox: setlinewith retstroke /Helveti-Conense finfont 4 slefont setfont /str 256 string ef { str exh up put } for 5 10 moveto str show str stringwith pop 5 /strlength exh ef % mrk eginning 1 setlinewith 5 10 moveto 0 20 rlineto stroke strlength 10 moveto 0 20 rlineto stroke To show the omplete string in this exmple, it s set with 4 point type euse of its length. The vertil lines to the left n right mrk the eginning n en of the string. The! is the first visile hrter t the 33r position. The gps re hrters without rwing within the 256 hrter set. A fountin is silly 256x1 piture sle to whtever size is require. See figure figure 13 6 The sling of the fountin is hnle y oth the imge opertor s mtrix rry n the sle opertor. In the following exmple of si fountin, first note the piture is 256 wie n 1 high. Seon, note the mtrix rry of [ ]. We know from hpter 10 on the mtrix tht this rry will sle the piture y 256 in the x n y 1 in the y. The mtrix of [ ] ompresses the 256x1 piture to 1 y 1 point squre. Without the sle, we proly woul hve iffiult time 138 the imge opertor / ptterns

149 Chpter 13 seeing the fountin. The sle opertor sles the fountin to whtever size esire. Sine we re eginning with 1x1 point squre, the size of the fountin will lso e its sle ftor. Below, the sle lso mens the fountin is 170x170 points in size. lern PS %!PS-Aoe-2.0 EPSF-1.2 %%Title:fountin_1.eps %%Cretor:John F Shermn %%BouningBox: /str 256 string ef { str exh up put } for sle [ ] {str} imge 13.7 hnging the fountin s iretion The iretion of the fountin n e ontrolle y using either 1x256 or 256x1 piture n the mtrix rry use with the imge opertor. In the next exmple, note the hnges me to the [ ] mtrix in the other three fountins. the imge opertor / ptterns 139

150 Tking Avntge of PostSript PS lern %!PS-Aoe-2.0 EPSF-1.2 %%Title:fountin_x4.eps %%Cretor:John F Shermn %%BouningBox: sle /str 256 string ef { str exh up put } for gsve % lower left [ ] { str } imge grestore gsve % lower right 1 0 trnslte % rememer sle [ ] { str } imge % ifferent grestore gsve % upper left 0 1 trnslte [ ] { str } imge % ifferent grestore gsve % upper right 1 1 trnslte [ ] { str } imge % ifferent grestore 140 the imge opertor / ptterns

151 Chpter other fountins There re severl tehniques in reting fountin to permit ifferent trnsitions of gry. Generlly the reson is to ompenste for ifferent printing situtions. lern PS %!PS-Aoe-2.0 EPSF-1.2 %%Title:fountin_2.eps %%BouningBox: /str 256 string ef {str exh up 255 iv sqrt 255 mul vi put} for /fountin { gsve /ury exh ef /urx exh ef /lly exh ef /llx exh ef llx lly ury trnslte urx llx su ury lly su sle [ ]{str} imge grestore } ef fountin lern PS Using vrition of seefountin_1.eps from the eginning of setion 13.6, the rte of hnge n e emonstrte y printing the string. fountin_1.eps is on the ottom for referene. It is lso roppe on the right so we n see the eginning more esily. The vertil lines mrk the eginning. # *-/2479;=?ACEGIJLNOQRTUWXZ[]^_fghiklmnoprstuvwxyz{ }~!"#$%& ()*+,-./ :;<=>?@ABCDEFGHIJKLM the imge opertor / ptterns 141

152 Tking Avntge of PostSript lern PS %!PS-Aoe-2.0 EPSF-1.2 %%Title:fountin_3-1.eps %%BouningBox: /str 256 string ef { str exh up 255 iv 180 mul os neg 2 iv mul vi put} for /fountin { /ury exh ef /urx exh ef /lly exh ef /llx exh ef gsve llx lly trnslte urx llx su ury lly su sle [ ] {str} imge grestore} ef fountin lern PS fountin_2.eps ws shift to the left. You n see elow tht fountin_3-1.eps is shift to the right ompre to fountin_1.eps.!"#$%& )*+, :;=>?ABCEFH!"#$%& ()*+,-./ :;<=>?@ABCDEFGHIJKLM 142 the imge opertor / ptterns

153 Chpter 13 lern PS %!PS-Aoe-2.0 EPSF-1.2 %%Title:fountin_3-2.eps %%BouningBox: /rte 720 ef /str 256 string ef { str exh up 255 iv rte mul os neg 2 iv mul vi put} for /fountin { /ury exh ef /urx exh ef /lly exh ef /llx exh ef gsve llx lly trnslte urx llx su ury lly su sle [ ] {str} imge grestore } ef fountin lern PS This is vrition of fountin_3-1.eps on the previous pge. Note the new vrile title rte use within the for proeure. In fountin_3-1.eps it ws 180. If rte is 360, the fountin woul e lk to white to lk. Below is portion of the string.!%*.39>ciou[gmsz «` Œ ıłøß œø æ ºŁ fi }vpj^xrlfa;61, # #,16;AFLRX^jpv} fi the imge opertor / ptterns 143

154 Tking Avntge of PostSript 144 retive uses of imgemsk

155 14 hpter Chpter 14 retive uses of imgemsk The imgemsk opertor is vrition of the imge opertor. It iffers in tht it n only e use to pint 1-it pitures, it n reverse the piture, n the piture is pinte with the urrent gry. Another feture of this opertor is tht the portion of the piture tht is not pinte is trnsprent. Otherwise it works muh in the sme wy s imge. imgemsk n e use to mke ptterns (see hpter 13). One of the suggeste uses of imgemsk is the retion of it-mp fonts. Sine the unpinte prt of the letterforms is trnsprent, they woul not interfere with imges unerneth them syntx The syntx of imgemsk is: with height invert mtrix pro imge Where: with height invert mtrix pro imgemsk is the with of the piture in ells or pixels. is the height of the piture in ells or pixels. if true, vlues of 1 re pinte with the urrent olor; if flse, vlues of 0 re pinte with the urrent olor. is the piture s oorinte system. is the t quisition proeure tht otins or retes the piture t. is the PostSript opertor shmrok revisite When the invert oolen is flse, the 0s re pinte with the urrent olor n the 1s re ler. A oolen is something tht is either true or flse. When the invert oolen is true, the opposite is the se. The 1s re pinte n the 0s re ler. See figure retive uses of imgemsk 145

156 Tking Avntge of PostSript figure Using the shmrok_1.eps exmple from hpter 12, the primry ifferenes of imgemsk n e emonstrte. In the next PostSript progrm exmple, the piture is ple on top of gry squre. H the imge opertor een use, tht gry squre woul hve een overe with opque white. lern PS 14 1 %!PS-Aoe-2.0 EPSF-1.2 %%Title:shmrok_3.eps %%BouningBox: /S <FF 1F FE 3F 9E 39 0E F F0 0F E0 07 E0 07 F0 0F> ef.5 setgry 0 0 moveto lineto lineto lineto losepth fill 0 setgry flse [ ] {S} imgemsk H true een use in the imgemsk rgument, true [ ] {S} imgemsk 146 retive uses of imgemsk

157 Chpter 14 the sme t woul look like figure The gry shmrok is the gry showing through where the 0s re n the lk is the pinte 1s. figure 14 2 In the next exmple, ifferent olors re use for the piture. The kgroun squre is.666 setgry. The first shmrok is.333 setgry. For the shmrok to the right, the urrent olor is me to setmykolor, rk green. lern PS 14 2 %!PS-Aoe-2.0 EPSF-1.2 %%Title:shmrok_5&6.eps %%BouningBox: /S <FF 1F FE 3F 9E 39 0E F F0 0F E0 07 E0 07 F0 0F> ef.666 setgry % kgroun 0 0 moveto lineto lineto lineto losepth fill.333 setgry flse [ ] {S} imgemsk trnslte setmykolor flse [ ] {S} imgemsk retive uses of imgemsk 147

158 Tking Avntge of PostSript 14.3 with fountin An interesting effet with imgemsk n e hieve with fountin (see previous hpter, setions ) unerneth the piture. Following re two esigns set up silly the sme. Eh hs the sme fountin unerneth the piture of the violin pinte with imgemsk. In the first exmple, violinsq1.eps, the violin is pinte in the efult vlue of lk. PS lern 14 3 %!PS-Aoe-2.0 EPSF-1.2 %%Title:violinSq1.eps %%BouningBox: gsve sle /str 256 string ef { str exh up put } for [ ] { str } imge grestore gsve 0 setgry /pistr1 38 string ef /ret {urrentfile exh rehexstring pop} ef /eginimge {{pistr1 ret} imgemsk} ef sle 148 retive uses of imgemsk

159 Chpter flse [ neg 0 300] eginimge FFFFFFFFFFFFFFCFFFFFFFFFFFFFFFFFFFFEF69FEA800C PICTURE DATA... FFF7FFFFFFFFFFFFFFF7FFFAFBD54ED6AA grestore retstroke In this seon exmple, two hnges hve een me to the file. First, true is use s the invert oolen for imgemsk, mking the opposite pixels e pinte 1s. Seon, the urrent gry is me white with 1 setgry. In this wy, whtever is unerneth will give the violin its olor. This retes the effet tht the violin is eing pinte s fountin. The white is msk overing the fountin elow it. PS lern 14 4 %!PS-Aoe-2.0 EPSF-1.2 %%Title:violinSq2.eps %%BouningBox: gsve sle /str 256 string ef { str exh up put } for [ ] { str } imge grestore retive uses of imgemsk 149

160 Tking Avntge of PostSript gsve 1 setgry /pistr1 38 string ef /ret {urrentfile exh rehexstring pop} ef /eginimge {{pistr1 ret} imgemsk} ef sle true [ neg 0 300] eginimge FFFFFFFFFFFFFFCFFFFFFFFFFFFFFFFFFFFEF69FEA800C PICTURE DATA... FFF7FFFFFFFFFFFFFFF7FFFAFBD54ED6AA grestore retstroke 14.4 s pttern Rnom ptterns n e me with similr proeure use to mke ptterns in setion {str exh rn 255 mo put} for This proeure onverts str into string of 512 rnomly selete hrters. Three overlpping squres re me, eh ifferent vlue. 150 retive uses of imgemsk

161 Chpter 14 PS lern 14 5 %!PS-Aoe-2.0 EPSF-1.2 %%Title:imgemskPt_1.eps %%BouningBox: /str 512 string ef {str exh rn 255 mo put} for true [ ] {str} imgemsk trnslte.333 setgry true [ ] {str} imgemsk trnslte.666 setgry true [ ] {str} imgemsk retive uses of imgemsk 151

162 Tking Avntge of PostSript 152 reting font

163 15 hpter Chpter 15 reting font You n rete unique PostSript font n use it in your PostSript progrms. The PostSript exmples in this hpter will over how to moify n existing font, the retion of mono-spe font, n then vrile-spe font. We will e reting type 3 fonts. The retion of type 1 fonts, however, will not e overe. Type 1 fonts re Aoe s previously enrypte font formt tht ws reently pulishe. These fonts ontin proeures, ommonly known s hints, tht ensure high qulity output on ll resolutions of printers, espeilly smll type on low resolution evies ntomy of font progrm A PostSript font progrm is the retion of font itionry ontining the vlues for numer of font hrteristis, some of whih re ontine in their own itionry within the lrger font itionry. Erlier in hpter 3, you my rememer, we efine squre to e the nme of proeure tht rws squre. Within font itionry, / is the nme of proeure tht rws the hrter. There is more to it thn just this, ut essentilly font is itionry of rwings for eh hrter of the lphet. There re lso other ttriutes of the font efine in the file, suh s the FontType, FontMtrix, FontBBox, the hrter Enoing, n its font metri. The FontType tells the PostSript interpreter how the font ws me so it knows how to hnle the font. The ifferent font types re: 0 Knji or other very lrge font sets. 1 Aoe s enrypte n hinte fonts. 2 Osolete. 3 User efine fonts. 4 Crtrige n isk-se enrypte fonts. 5 ROM-se enrypte fonts. The FontMtrix is the oorinte system within whih the font ws esigne. Usully the font is esigne within 1000x1000 unit spe. It n e thought of s the pge the font ws esigne on. In figure 15 1, the hrters g n M re ple on wht oul e the 1000x1000 unit spe. Eh gri line represents 100 units. A mtrix rry of [ ] will reue the 1000x1000 unit spe to 1x1 unit squre. In other wors, wht ws rwn to e 100 is now.1 n wht ws 1000 is 1. Therefore, when 72 slefont is use with the font, the 1x1 unit squre is sle y ftor of 72. Figure 15 2 explins FontMtrix further. The first lrge squre gri represents reting font 153

164 Tking Avntge of PostSript the 1000x1000 unit spe (reue 10% to sve spe) on whih the font ws rwn. Next to it, lele with n A n with n rrow pointing t it (it s smll) is tht 1000x1000 unit spe reue to 1x1 unit spe y the pplition of the [ ] FontMtrix. B lels wht woul hppen with 72 slefont, C lels 300 slefont enlrgement for etter view. Mg BBox for g is: BBox for M is: BBox for the font is: figure 15 1 figure 15 2 The FontBBox is the smllest retngle into whih ll the hrters of the font will fit. This is epite y the gry retngle in figure A B C The hrter Enoing etermines t wht eiml lotion the hrter nme will resie on the ASCII hrt. See ppenix A. PostSript hs stnr Enoing nme StnrEnoing tht lrey gives every entry of the rry nme. In it, /one is the nme for the numer 1 t eiml 49, / is the nme for the hrter t eiml 97, n so on. The StnrEnoing n e opie or you n rete your own sheme. In the next setion, the StnrEnoing is opie, sving the troule of hving to nme ll the hrter proeures. Lter, in setion 15.4, ustom nmes re given to severl of the hrters n the nme for null proeure (oesn t o nything) to the rest. The ChrPros is itionry ontining ll the proeure efinitions tht rw the iniviul hrters nme in the Enoing rry. Finlly, there is the BuilChr proeure tht uses the informtion previously liste in the progrm to tully rw the hrter. 154 reting font

165 Chpter PS lern 15 1 font templte This next setion hs listing of font file to show how the ove informtion is orgnize into file. All tht is missing re your rwings for iniviul hrters n your hoie for font nme. Not ll 256 entries re inlue. The others n e foun in ppenix A. %!PS-Font %%Title:font_templte.ps /newfont 10 it ef newfont egin % rete itionry % egin filling itionry /FontType 3 ef % user efine font /FontMtrix [ ] ef /FontBBox [ ] ef /Enoing 256 rry ef % opy stnr enoing StnrEnoing Enoing opy pop /ChrPros 20 it ef ChrPros egin % mth # with # of hr pro % itionry of hr proeures /spe { } ef % wor spe /mpersn { % hrter rwing for & } ef /sterisk { % hrter rwing for * } ef /zero /one /two /three /four { % hrter rwing for 0 } ef { % hrter rwing for 1 } ef { % hrter rwing for 2 } ef { % hrter rwing for 3 } ef { % hrter rwing for 4 } ef /A { % hrter rwing for A } ef /B { % hrter rwing for B } ef /C { % hrter rwing for C } ef /D { % hrter rwing for D } ef / { % hrter rwing for } ef / { % hrter rwing for } ef / { % hrter rwing for } ef / { % hrter rwing for } ef en /yen { % hrter rwing for } ef /prgrph { % hrter rwing for } ef /germnls { % hrter rwing for ß } ef /BuilChr % retes hr from info ove { setheevie exh egin Enoing exh get ChrPros exh get exe en} ef reting font 155

166 Tking Avntge of PostSript en % give your font nme repling YourNme /YourNme newfont efinefont pop 15.3 moifying n existing font It s possile to moify n existing font y upliting its font itionry n then pling new entry in the opy. The most ommon hnge is to hnge the font s mtrix. By oing so, the entire font n e onense or expne. The font Helveti-Nrrow foun in mny lser printers is proue y mthemtilly onensing Helveti. Helveti Conense, on the other hn, is seprte rwing from Helveti. In this exmple, we will mke our own Pltino Bol Nrrow. The first setion of oe uplites the Pltino-Bol itionry n isrs the existing FID. A new one will e me with efinefont. While itcopy is on top of the itionry stk, the FontMtrix is reple with new rry. The next line efines Pltino-BNrrow s the font with efinefont. Pltino B Pltino Bol Nrrow lern PS 15 2 %!PS-Aoe-2.0 EPSF-1.2 %%Title:Pltino-BNrrow.eps %%BouningBox: /Pltino-Bol finfont up length it /itcopy exh ef {1 inex /FID ne {itcopy 3 1 roll put} {pop pop} ifelse }forll itcopy /FontMtrix [ ] put /Pltino-BNrrow itcopy efinefont pop 156 reting font

167 Chpter 15 /Pltino-BNrrow finfont 70 slefont setfont moveto (Pltino Bol Nrrow) show /Pltino-Bol finfont 70 slefont setfont moveto (Pltino B) show 15.4 shpefont s mono-spe font To rete our own font from srth, we ll nee to set up ll the neessry informtion. A mono-spe font is simpler thn vrile-spe font euse every hrter uses the sme mount of spe. First, the font itionry is set up with /newfont 10 it ef. newfont is n ritrry nme; use whtever you wnt. It will lter e reple with the tul font nme. The newfont itionry must hve four entries: FontType, FontMtrix, FontBBox n Enoing. These shoul e unerstoo from setion The Enoing this time will e nonstnr rry of 256 nmes. The line {Enoing exh /.notef put} for reples eh position of the lnk Enoing me y the previous line /Enoing 256 rry ef with the key /.notef. This is quik wy to give eh entry of Enoing nme. We pln to nme only 5 of the 256 positions. If hrter without rwing is use, the.notef proeure (whih oes nothing) will e use to prevent n error. Next, the nmes for hrters we wnt in Enoing re put into the position we wnt tht orrespons to key of the keyor. Bsilly, ASCII 97 is the hrter in stnr font n is the hrter squre in shpefont. ChrPros is itionry tht mthes the nme in Enoing with proeure. The proeure efinitions shoul look fmilir to you. Note wht the proeure.notef is efine s. Finlly, there is the efinition for BuilChr. BuilChr is wht gets lle when hrter nees to e pinte. Font hing, performe y the setheevie opertor is use to gin effiieny in printing. When hrter is rwn y BuilChr, its imge is temporrily store in he. Shoul the hrter e use gin, it s there, rey to go PS lern15 3 %!PS-Aoe-2.0 EPSF-1.2 %%Title:shpeFont.eps %%BouningBox: reting font 157

168 Tking Avntge of PostSript /newfont 10 it ef newfont egin /FontType 3 ef /FontMtrix [ ] ef /FontBBox [ ] ef /Enoing 256 rry ef % give nme {Enoing exh /.notef put} for Enoing 97 /squre put % keyor Enoing 98 /tringle put % keyor Enoing 99 /irle put % keyor Enoing 100 /imon put % keyor Enoing 101 /lines put % keyor e /ChrPros 6 it ef ChrPros egin % pro ef for nmes ove /.notef { } ef /squre {0 0 moveto lineto lineto lineto losepth fill} ef /tringle {0 0 moveto lineto lineto losepth fill} ef /irle { r losepth fill} ef /imon {375 0 moveto lineto lineto lineto losepth fill} ef /lines {150 setlinewith 0 75 moveto rlineto stroke moveto rlineto stroke moveto rlineto stroke} ef en /BuilChr { setheevie exh egin Enoing exh get ChrPros exh get exe en} ef en % en newfont /ShpeFont newfont efinefont pop /ShpeFont finfont 70 slefont setfont moveto (e) show 158 reting font

169 Chpter shpefont s vrile-spe font shpefont s vrile-spe font is written muh the sme s in the previous setion. In this version of the font, every hrter n hve its own unique with. The primry ifferene in this font file from the lst setion is the ition of the Metris n BBox itionries. These re use for hrter sping n setting the ounries of font hing respetively. These re use in the BuilChr proeure. If the vlues re hnge in the Metris itionry, the hrter sping of this font will e ifferent. The BBox itionry provies more preise informtion for font hing PS lern 15 4 %!PS-Aoe-2.0 EPSF-1.2 %%Title:shpeFont2.eps %%BouningBox: /newfont 10 it ef newfont egin /FontType 3 ef /FontMtrix [ ] ef /FontBBox [ ] ef /Enoing 256 rry ef {Enoing exh /.notef put} for Enoing 97 /squre put % keyor Enoing 98 /tringle put % keyor Enoing 99 /irles put % keyor Enoing 100 /imon put % keyor Enoing 101 /lines put % keyor e /Metris 6 it ef Metris egin /.notef 0 ef /squre 800 ef /tringle 400 ef /irles 400 ef /imon 800 ef /lines 400 ef en /BBox 6 it ef reting font 159

170 Tking Avntge of PostSript BBox egin /.notef [ ] ef /squre [ ] ef /tringle [ ] ef /irles [ ] ef /imon [ ] ef /lines [ ] ef en /ChrPros 6 it ef ChrPros egin /.notef { } ef /squre {0 0 moveto lineto lineto lineto losepth fill} ef /tringle {0 0 moveto lineto lineto losepth fill} ef /irles { r losepth fill r losepth fill} ef /imon {375 0 moveto lineto lineto lineto losepth fill} ef /lines {150 setlinewith 0 75 moveto rlineto stroke moveto rlineto stroke moveto rlineto stroke} ef en /BuilChr {0 egin /hr exh ef /fontit exh ef /hrnme fontit /Enoing get hr get ef fontit egin Metris hrnme get 0 BBox hrnme get lo pop setheevie ChrPros hrnme get exe en en } ef /BuilChr lo 0 3 it put /UniqueID 1 ef en /ShpeFont2 newfont efinefont pop /ShpeFont2 finfont 70 slefont setfont moveto (e) show 160 reting font

171 Chpter the rbit-romn font The rbit-romn font is n exmple of how the PostSript font mhinery n e use to rete interesting ptterns. It is mono-spe font with no gp etween the hrters. 1CD ABCD lern PS %!PS-Aoe-2.0 EPSF-1.2 %%Title:rBit_font.eps %%Cretor:John F Shermn %%CretionDte:April 1990 %%DoumentFonts:rBit-Romn %%BouningBox: /newfont 10 it ef newfont egin /FontType 3 ef reting font 161

172 Tking Avntge of PostSript /FontMtrix [ ] ef /FontBBox [ ] ef /Enoing 256 rry ef StnrEnoing Enoing opy pop /ChrPros 30 it ef ChrPros egin /.notef { } ef /str 512 string ef /rbit { {ChrPros /str get exe exh rn 255 mo put} for ChrPros /str get exe } ef /spe {0 0 moveto newpth} in ef /zero {48 srn true [ ] {ChrPros /rbit get exe}imgemsk} in ef /one /two {49 srn true [ ] {ChrPros /rbit get exe}imgemsk} in ef {50 srn true [ ] {ChrPros /rbit get exe}imgemsk} in ef /three{51 srn true [ ] {ChrPros /rbit get exe}imgemsk} in ef /four {52 srn true [ ] {ChrPros /rbit get exe}imgemsk} in ef /A {65 srn true [ ] {ChrPros /rbit get exe}imgemsk} in ef /B {66 srn true [ ] {ChrPros /rbit get exe}imgemsk} in ef /C {67 srn true [ ] {ChrPros /rbit get exe}imgemsk} in ef /D {68 srn true [ ] {ChrPros /rbit get exe}imgemsk} in ef 162 reting font

173 Chpter 15 / {97 srn true [ ] {ChrPros /rbit get exe}imgemsk} in ef / {98 srn true [ ] {ChrPros /rbit get exe}imgemsk} in ef / {99 srn true [ ] {ChrPros /rbit get exe}imgemsk} in ef en / {100 srn true [ ] {ChrPros /rbit get exe}imgemsk} in ef /BuilChr { setheevie exh egin Enoing exh get ChrPros exh get exe en} ef en /rbit-romn newfont efinefont pop %% BEGIN DESIGN /rbit-romn finfont 100 slefont setfont gsve 0 0 moveto (1234) show moveto (ABCD) show moveto () show.5 setgry moveto (1C) show.3 setgry (D) show grestore 15.7 how to use your font There re two wys you n use your font. The first wy is to inlue the efinition of the font in the eginning of your progrm. This hs een one in the previous exmples. The vntge of this is tht your progrm n esily e run on ny PostSript printer. Everything is there in the PostSript file rey to go. The seon wy to use your font is to use it only s font file n ownlo it to your lser printer s RAM. Therefter, your PostSript files tht use the font will not nee to ontin the efinition for the font. The min vntge to ownloing your font is tht you n simplify your PostSript files. The isvntges re tht you n lose trk of whih files use whih fonts n there isn t onvenient wy to let Mintosh pplitions use them. reting font 163

174 Tking Avntge of PostSript To e le to ownlo font, you nee to line of oe to the eginning of your font file: serverit egin 0 exitserver This line t the eginning of your file will let your font exist in your printer s RAM until it is turne off. Your file woul look like this. lern PS 15 6 %!PS-Font %%Title:ownlo_rFont.ps serverit egin 0 exitserver /newfont 10 it ef newfont egin /FontType 3 ef /FontMtrix [ ] ef /FontBBox [ ] ef /Enoing 256 rry ef {Enoing exh /.notef put} for Enoing 33 /33 put Enoing 65 /65 put Enoing 97 /97 put Enoing 122 /122 put /ChrPros 7 it ef ChrPros egin /.notef{ } ef /hr {10 setlinewith rn 1000 mo rn 1000 mo moveto rn 1000 mo rn 1000 mo lineto stroke} ef /33 {33 {ChrPros /hr get exe} repet} in ef /65 {65 {ChrPros /hr get exe} repet} in ef /97 {97 {ChrPros /hr get exe} repet} in ef /122 {122 {ChrPros /hr get exe} repet} in ef en /BuilChr { setheevie exh egin Enoing exh get ChrPros exh get exe en} ef en /rfont newfont efinefont pop If the previous progrm hs een sent to the LserWriter, the following progrm 164 reting font

175 Chpter 15 n e sent to the printer n work orretly. zzzzz AAAAA!!!!! lern PS 15 7 %!PS-Aoe-2.0 EPSF-1.2 %%Title:rFont.eps %%BouningBox: /rfont finfont 50 slefont setfont moveto (!!!!!) show moveto () show moveto (AAAAA) show moveto (zzzzz) show Generlly, you ll fin it esier to keep the font efinition within the PostSript file. reting font 165

176 Tking Avntge of PostSript 166 retive uses of rnom numers

177 16 hpter Chpter 16 retive uses of rnom numers The rnom numer genertion of PostSript hs numer of retive pplitions. Most ommon re rnom numers for n x y lotion for moveto or lineto opertor or to set gry vlue. The sequene of rnom numers n e repete if the see numer tht egins the sequene is the sme rn The simplest rnom numer progrm woul e rn = PS lern 16 1 rn retes n pushes rnom numer onto the opern stk. The equl sign (=) pops the numer off the stk n sens it the stnr output file. Depening on the pplition you re using t the time, the stnr output file will e ifferent. On the Mintosh, if you re using SenPS, the stnr output file will e text file on your hr isk nme fter your printer. If you re using Downloer, the output file is rief isply in winow on the monitor. On the NeXT, the stnr output file will e the Console winow foun in the Tools menu uner the min Workspe menu. By running the following, rn = rn = rn = rn = rn = rn = rn = you will sen seven numers to the stnr output file You won t get these numers. It will e ifferent set every time. Another wy to see the numer rete is to print it: retive uses of rnom numers 167

178 Tking Avntge of PostSript lern PS 16 2 %!PS-Aoe-2.0 EPSF-2.0 %%Title:seeRn1.eps %%DoumentFonts:Times-Bol %%BouningBox: /Times-Bol finfont 48 slefont setfont /str 10 string ef moveto rn str vs show 16.2 srn In the previous exmple, every time the progrm is run, ifferent numer will e generte. By using the opertor srn, whih n e unerstoo s seernom numer, repetle series of numers n e rete. The syntx of srn is: integer srn lern PS 16 3 Where integer is the see numer srn rn = rn = rn = rn = rn = rn = rn = Every time this is sent to the PostSript interpreter, the sme seven numers will e generte. Following is n expne version of seern1.eps retive uses of rnom numers

179 Chpter 16 lern PS 16 4 %!PS-Aoe-2.0 EPSF-2.0 %%Title:seeRn2.eps %%DoumentFonts:Times-Bol %%BouningBox: /Times-Bol finfont 18 slefont setfont /str 10 string ef 1734 srn moveto rn str vs show moveto rn str vs show moveto rn str vs show 1734 srn moveto rn str vs show moveto rn str vs show moveto rn str vs show 16.3 rnom x y plement The PostSript rnom numer genertor n e use to supply vlues for the moveto or lineto opertors. The rnom numer rete, however, nees to e onfine to ertin rnge so tht there is resonle expettion of where items will e lote. Otherwise, you ll e off the pge most of the time. Creting rnom numer tht is lwys within ertin rnge n e one with the mo opertor. mo ivies the top two integers on the stk n pushes the ivision s reminer onto the stk. For exmple, mo woul return 7. No mtter wht the first integer is, the reminer will lwys e etween 0 n the ivier minus 1. In the following exmple, 10 rnom numers re generte etween 0 n 100. A ifferent set n e me if the srn vlue is hnge PS lern 16 5 %!PS-Aoe-2.0 EPSF-2.0 %%Title:seeRn3.eps %%DoumentFonts:Times-Bol %%BouningBox: /Times-Bol finfont 36 slefont setfont /str 20 string ef /rnge 100 ef /rnum {rn rnge mo} ef retive uses of rnom numers 169

180 Tking Avntge of PostSript srn moveto rnum str vs show moveto rnum str vs show moveto rnum str vs show moveto rnum str vs show moveto rnum str vs show moveto rnum str vs show moveto rnum str vs show moveto rnum str vs show moveto rnum str vs show moveto rnum str vs show To tke vntge of these numers to mke grphi, you n write: rnum rnum moveto rnum rnum lineto stroke This will rw line from rnom strt to rnom en. The eginning n the en will e within whtever rnge is eie. The next step is to repet the line so tht vrious ptterns or textures n e rete. In the following exmple, the first luster is n exmple of repeting the line of oe ove. The seon luster is n exmple of using the repetition twie with hnge in line weight n vlue. The thir luster of lines emonstrtes how y using srn with the sme see efore rwing the luster of lines, the sme pttern of lines n e me n overlppe PS lern 16 6 %!PS-Aoe-2.0 EPSF-1.2 %%Title:rnLines.eps %%BouningBox: /rnge72 ef /rnum {rn rnge mo} ef trnslte % first luster 25 {rnum rnum moveto rnum rnum lineto stroke} repet trnslte % seon luster.5 setgry 4 setlinewith 170 retive uses of rnom numers

181 Chpter {rnum rnum moveto rnum rnum lineto stroke} repet 0 setgry 1 setlinewith 25 {rnum rnum moveto rnum rnum lineto stroke} repet trnslte % thir luster srn.5 setgry 4 setlinewith 25 {rnum rnum moveto rnum rnum lineto stroke} repet srn 0 setgry 1 setlinewith 25 {rnum rnum moveto rnum rnum lineto stroke} repet Following is similr exmple using the urveto opertor lern PS 16 7 %!PS-Aoe-2.0 EPSF-1.2 %%Title:rnurves.eps %%BouningBox: /n {rn 72 mo} ef trnslte % first srile n n moveto 25 {n n n n n n urveto} repet stroke 72 0 trnslte % seon srile.5 setgry 4 setlinewith n n moveto 25 {n n n n n n urveto} repet stroke 0 setgry 1 setlinewith n n moveto 25 {n n n n n n urveto} repet stroke 72 0 trnslte % thir srile retive uses of rnom numers 171

182 Tking Avntge of PostSript 172 retive uses of rnom numers srn.5 setgry 4 setlinewith n n moveto 25 {n n n n n n urveto} repet stroke srn 0 setgry 1 setlinewith n n moveto 25 {n n n n n n urveto} repet stroke 72 0 trnslte % fourth srile srn % ottom.8 setgry 10 setlinewith n n moveto 25 {n n n n n n urveto} repet stroke srn % mile.5 setgry 5 setlinewith n n moveto 25 {n n n n n n urveto} repet stroke srn % top 0 setgry.25 setlinewith n n moveto 25 {n n n n n n urveto} repet stroke rnom plement of type The rnom plement of type is essentilly omplishe in the sme wy s in the previous setion. Here we generte seprte x n y vlues e e e e e e e e e e e e e e e e e e e e e e e e e e e e ee e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g

183 Chpter 16 lern PS 16 8 %!PS-Aoe-2.0 EPSF-1.2 %%Title:rnAlph1.eps %%BouningBox: /x {rn 288 mo} ef % x will e etween 0 & 288 /y {rn 144 mo} ef % y will e etween 0 & 144 /Pltino-Romn finfont 10 slefont setfont trnslte 100 {x y moveto () show} repet 100 {x y moveto () show} repet 100 {x y moveto () show} repet 100 {x y moveto () show} repet 100 {x y moveto (e) show} repet 100 {x y moveto (f) show} repet 100 {x y moveto (g) show} repet A seon exmple of rnomly pling type introues few helpful vritions of the rnom numer proeure. Hving the proeure /x {rn exh mo} ef use in this wy 100 x y moveto (A) show 200 x y moveto (B) show 300 x y moveto (C) show n give flexiility in the progrm to proue vrile rnges for the vlue of x. In the next exmple, this tehnique is use for the x vlue use y the moveto opertor. The ition of the 12 su to the /x n /y proeures elow shifts the vlues for x n y y 12 so tht the type will e roppe left n ottom EE EE E EEE E D E E E D E E E E D E E E E EE E E E D DD D CCB B C C C D D D CD D C E D CCC E E DD D D D E E D DD D C C A C C BB BB B AB BB CB C A C D E E retive uses of rnom numers 173

184 Tking Avntge of PostSript lern PS 16 9 %!PS-Aoe-2.0 EPSF-1.2 %%Title:rnAlph2.eps %%BouningBox: /x {rn exh mo 12 su} ef /y {rn 130 mo 12 su} ef /AvntGre-Demi finfont 48 slefont setfont trnslte 0 0 moveto rlineto rlineto rlineto losepth lip newpth srn.8 setgry 100 {290 x y moveto (E) show} repet.6 setgry 60 {200 x y moveto (D) show} repet.4 setgry 35 {150 x y moveto (C) show} repet.2 setgry 25 {100 x y moveto (B) show} repet 0 setgry 10 {40 x y moveto (A) show} repet 16.5 rnom gry vlues A rnomly generte numer n e use y the setgry opertor s well. In this se, we nee numer etween 0 n 1. To get the numer, numer etween 0 n 100 is generte with rn 100 mo n then this numer is multiplie y.01 to shift the eiml point. The following exmple is similr to seern2.eps seen erlier in setion In this version, the generte numer is uplite so it n e use twie. The first is use y the setgry opertor, the opy is onverte to string n pinte. Therefore, the numer ppers in its gry vlue PS lern %!PS-Aoe-2.0 EPSF-2.0 %%Title:seeRgry1.eps %%DoumentFonts:Times-Bol %%BouningBox: /Times-Bol finfont 18 slefont setfont /str 10 string ef 174 retive uses of rnom numers

185 Chpter 16 /rg {rn 100 mo.01 mul} ef srn moveto rg up setgry str vs show moveto rg up setgry str vs show moveto rg up setgry str vs show moveto rg up setgry str vs show moveto rg up setgry str vs show moveto rg up setgry str vs show moveto rg up setgry str vs show moveto rg up setgry str vs show moveto rg up setgry str vs show moveto rg up setgry str vs show A vrition of this proeure is to onfine the gry vlues within n even tighter rnge y multiplying y.001 inste of.01 n then ing numer to fill the first eiml spe. The numer otine from the rnom genertion my e 0.027, for exmple. By ing 0.3, it will e See exmple elow. By moving the eiml over three ples inste of two, the numer will lwys e 0.0xx. Whtever numer is then e etermines the nrrow rnge s long s it s etween 0.1 n 0.9. Or, nothing if you wnt to keep it in the to rnge PS lern %!PS-Aoe-2.0 EPSF-2.0 %%Title:seeRgry2.eps %%DoumentFonts:Times-Bol %%BouningBox: /Times-Bol finfont 18 slefont setfont /str 10 string ef /rg {rn 100 mo.001 mul.3 } ef srn moveto rg up setgry str vs show moveto rg up setgry str vs show moveto rg up setgry str vs show moveto rg up setgry str vs show moveto rg up setgry str vs show moveto rg up setgry str vs show moveto rg up setgry str vs show moveto rg up setgry str vs show moveto rg up setgry str vs show moveto rg up setgry str vs show retive uses of rnom numers 175

186 Tking Avntge of PostSript lern PS Another exmple is the listing for the esign on the first pge of this hpter. %!PS-Aoe-2.0 EPSF-1.2 %%Title:qu_.eps %%BouningBox: /Helveti-Bol finfont 12 slefont setfont /n {rn exh mo} ef /nn {rn 200 mo} ef /g {rn 100 mo.01 mul} ef /ox {0 0 moveto lineto lineto lineto losepth} ef srn trnslte ox fill % upper left gsve ox lip newpth / {180 n nn moveto () show} ef / {144 n nn moveto () show} ef / {108 n nn moveto () show} ef / {72 n nn moveto () show} ef /e {36 n nn moveto () show} ef 25 {g setgry 25 {} repet} repet 20 {g setgry 25 {} repet} repet 15 {g setgry 25 {} repet} repet 10 {g setgry 25 {} repet} repet 10 {g setgry 25 {e} repet} repet grestore trnslte ox.5 setgry fill gsve ox lip newpth / {nn 180 n moveto () show} ef / {nn 144 n moveto () show} ef / {nn 108 n moveto () show} ef / {nn 72 n moveto () show} ef /e {nn 36 n moveto () show} ef 25 {g setgry 25 {} repet} repet 20 {g setgry 25 {} repet} repet 15 {g setgry 25 {} repet} repet 10 {g setgry 25 {} repet} repet 10 {g setgry 25 {e} repet} repet grestore trnslte ox.2 setgry fill 176 retive uses of rnom numers

187 Chpter 16 gsve ox lip newpth / {nn 180 n moveto () show} ef / {nn 144 n moveto () show} ef / {nn 108 n moveto () show} ef / {nn 72 n moveto () show} ef /e {nn 36 n moveto () show} ef 25 {g setgry 25 {} repet} repet 20 {g setgry 25 {} repet} repet 15 {g setgry 25 {} repet} repet 10 {g setgry 25 {} repet} repet 10 {g setgry 25 {e} repet} repet grestore trnslte ox.9 setgry fill gsve ox lip newpth / {36 n nn moveto () show} ef / {72 n nn moveto () show} ef / {108 n nn moveto () show} ef / {144 n nn moveto () show} ef /e {180 n nn moveto () show} ef 25 {g setgry 25 {} repet} repet 20 {g setgry 25 {} repet} repet 15 {g setgry 25 {} repet} repet 10 {g setgry 25 {} repet} repet 10 {g setgry 25 {e} repet} repet grestore retive uses of rnom numers 177

188 Tking Avntge of PostSript 178 some vne progrmming ies

189 17 hpter Chpter 17 some vne progrmming ies There re numer of tehniques tht n e use to inrese the performne of your PostSript progrms. The tehniques involve new wys of efining the proeures you write, reefining PostSript opertors, n reting your own user itionry of proeures. After this isussion, I ll explin severl esigns in etil erly ining PostSript is n extensile lnguge, mening ox, s efine in this exmple, /ox { moveto 72 0 rlineto 0 72 rlineto rlineto losepth } ef n e use like ny other PostSript opertor. You hve expne the voulry of the PostSript lnguge. Proeures tht you rete re lote in the userit itionry on itionry stk. PostSript opertors re foun in the systemit itionry elow userit on the stk. When nme or key is enountere, the userit is looke into first, the systemit seon, going own the stk. Every time ox is use, the PostSript interpreter looks first in the user itionry for the mening of ox. Wht is foun there is moveto 72 0 rlineto 0 72 rlineto rlineto losepth. Next, the userit, then the systemit itionries re serhe for the vlue of moveto, rlineto, n losepth. Things oul e spe up if ll this lookup tivity oul e simplifie. This n e one with proess lle erly ining n it s one with the in opertor. All tht looking up proess esrie in the previous prgrph is lle lte ining. The ox proeure using in woul e written like this: /ox { moveto 72 0 rlineto 0 72 rlineto rlineto losepth } in ef Now the lookup is performe when the proeure is first efine. When the key ox is now enountere in progrm, its vlue is exeute without ny lookup. In short progrm, the performne ifferene is negligile. Most of the progrm exmples in this ook woul not enefit from this. It is useful, however, in muh lrger progrms tht tke more time to proess. If proeure nme is use within the efinition of nother proeure, in is only neee in the seon proeure. There is no e enefit in ining oth proeures, nor is there penlty. For exmple, the in use in the R_ox proeure tht follows will lso pply to the ox proeure. some vne progrmming ies 179

190 Tking Avntge of PostSript /ox {0 0 moveto 8 0 rlineto 0 8 rlineto -8 0 rlineto losepth fill} ef /R_ox {100 {10 0 trnslte ox} repet} in ef 17.2 lo Another tehnique to inrese the effiieny of your progrm is to reue its size. Sometimes just the mount of informtion eing sent to the printer is tking up ll the time, not the PostSript interpreter proessing wht ws reeive. Agin, not muh gin is going to e ttine in short progrm. However, if PostSript progrm hs lrge numer of moveto s, lineto s, n stroke s for exmple, its size n e reue signifintly if they were reple with m, l, n s. The opertor lo n e use to renme PostSript opertors. Atully, lineto is the key to the vlue of PostSript opertor tht rws line. The key to this opertor vlue n e hnge. lo pushes the opertor vlue onto the opern stk n in n then e use to tightly ssoite new key or nme to the opertor. Following is n exmple using oth in n lo PS lern 17 1 %!PS-Aoe-2.0 EPSF-1.2 %%Title:3oxDesigns.eps %%BouningBox: / {in ef} in ef /l {lo ef} /lw /setlinewith l /g /setgry l /m /moveto l / /r l /rl /rlineto l /l /lineto l / /urveto l /p /losepth l /s /stroke l /f /fill l 180 some vne progrmming ies

191 Chpter 17 % first ox.5 g m l l l p f 0 g 2 lw s % seon ox.2 g 4 lw m 72 0 rl 0 72 rl rl p f 1 g m s % thir ox.8 g 2 lw m 72 0 rl 0 72 rl rl p f 0 g m rl s m rl s 17.3 PS lern 17 2 mking user itionry The list of efinitions use in the eginning of 3oxDesigns.eps n e forme into user itionry. This is silly mking your own lser printer prep file. The Mintosh Lser Prep file is userit itionry nme m (proly for mintosh itionry). It nees to e in the LserWriter when printing euse Mintosh softwre uses the proeures efine in the m itionry when it sens file to the printer. The m itionry ontins 250 proeure efinitions. You n t open the Lser Prep file, ut it n e exmine in nother wy. Open ny file n selet Print from the File menu. Immeitely fter you lik on OK in the Print ilog ox, press ommn k on the keyor. A text file will e rete on your isk rive of the m itionry plus your file s it woul e sent to the printer. A vrition of this is pressing ommn f. This will rete the sme text file minus the m itionry. The files will e nme PostSript0, PostSript1, n so on up to PostSript9 n then strt over t PostSript0. This PostSript file, if sent to the lser printer, woul resie in the printer s RAM just s the Lser Prep file oes. Note tht this is silly the sme opertion s ownloing font to the printer. See setion %!PS-Aoe-2.0 %%Title:Sherm_it.ps serverit egin 0 exitserver /Sherm 13 it ef Sherm egin % mke it with room for 13 ef % put it on top of it stk / {in ef} in ef /l {lo ef} /lw /setlinewith l /g /setgry l /m /moveto l / /r l /rl /rlineto l /l /lineto l / /urveto l /p /losepth l /s /stroke l /f /fill l some vne progrmming ies 181

192 Tking Avntge of PostSript en % remove s top itionry lern PS 17 3 This version of 3oxDesigns.eps oul then e sent: %!PS-Aoe-2.0 EPSF-1.2 %%Title:withoutDit.eps %%BouningBox: Sherm egin % put it on top of it stk % first ox.5 g m l l l p f 0 g 2 lw s % seon ox.2 g 4 lw m 72 0 rl 0 72 rl rl p f 1 g m s % thir ox.8 g 2 lw m 72 0 rl 0 72 rl rl p f 0 g m rl s m rl s en % remove from top of it stk PS lern 17 4 However, tht wy of hnling your itionry n e inonvenient if you nee to print your files t numer of ifferent lotions. To inrese the portility of your files, your itionry n e inlue in the file. %!PS-Aoe-2.0 EPSF-1.2 %%Title:withDit.eps %%BouningBox: /Sherm 13 it ef Sherm egin / {in ef} in ef /l {lo ef} /lw /setlinewith l /g /setgry l /m /moveto l / /r l /rl /rlineto l /l /lineto l / /urveto l /p /losepth l /s /stroke l /f /fill l % first ox.5 g m l l l p f 0 g 2 lw s % seon ox 182 some vne progrmming ies

193 Chpter 17.2 g 4 lw m 72 0 rl 0 72 rl rl p f 1 g m s % thir ox.8 g 2 lw m 72 0 rl 0 72 rl rl p f 0 g m rl s m rl s en esigns expline, gdesign listing In this n the following two setions I ll explin three of my PostSript esigns in more etil n present my pproh to writing progrm. I generlly egin simply y eiing on formt n the germ of n ie. I lso like working on series, so one ie n fee into nother. I m lwys opying progrm frgments from other PostSript files to get things strte. With this in min, I generlly try to write in suh wy tht this n esily e one. This esign n e foun on the first pge of hpter 7, type sis. We ll strt with the stnr EPS heer info. The originl esign ws intene to e lrger. I egn with.5.5 sle to reue the esign y hlf. I lso reflete the reue size in the %%BouningBox: omment. It use to e some vne progrmming ies 183

194 Tking Avntge of PostSript PS lern 17 5 %!PS-Aoe-2.0 EPSF-1.2 %%Title:gDesign.eps %%Cretor:John F Shermn %%CretionDte:8 Mrh 1989 %%DoumentFonts:Times-Bol %%BouningBox: sle % reue, originlly esigne for linotron % rememer to reflet hnge in BouningBox /Times-Bol finfont 800 slefont setfont % This esign uses the pttern proeure (see hpter 13) written s 2-it piture pttern. As 2-it piture, the onfinement of vlue rnge is still there, ut there re lso other vlues thrown in tht give sprkle effet. I lso use n sx sy sle within the pttern efinition to etermine the pttern s size. sx n sy re efine n reefine four times efore pttern is use throughout the progrm. % /str 512 string ef % use y pttern pro /pttern % ef for rnom pttern {/light exh ef /rk exh ef /iff light rk su ef sx sy sle [ ] { {str exh rn iff mo rk put} for str} imge } in ef % kgroun seen on top n right sies 0 0 moveto lineto lineto lineto losepth fill % 800 point Times-Bol g, outline with 50% gry 4 pt line 4 setlinewith.5 setgry moveto (g) true hrpth stroke gsve % lrge pttern /sx 700 ef /sy 700 ef 0 50 pttern grestore gsve % 1 y 2 ner ottom /sx 100 ef /sy 200 ef trnslte pttern grestore 184 some vne progrmming ies

195 Chpter 17 gsve % 1 y 1 ner top /sx 100 ef /sy 100 ef trnslte pttern grestore gsve % pttern in g moveto (g) true hrpth lip /sx 700 ef /sy 700 ef pttern % pttern for lip grestore 1 setgry 2 setlinewith moveto (g) true hrpth stroke /Times-Bol finfont 400 slefont setfont 0 setgry moveto (G) show some vne progrmming ies 185

196 Tking Avntge of PostSript 17.5 PS lern 17 6 sontclef listing Here s the stnr EPS heer info: %!PS-Aoe-2.0 EPSF-2.0 %%Title:sontClef.eps %%CretionDte:9 July 1988 rev 7 August 1989 %%Cretor:John F Shermn %%DoumentFonts:Sont %%BouningBox: some vne progrmming ies

197 Chpter 17 % The lines of oe elow set the pge size for the Linotron. It is written in this wy so tht if it is printe on something other thn Linotron, suh s proof on n Apple LserWriter, the file oesn t fil. The sttusit is speil itionry tht ontins things suh s the printer s efult pge size, the printer s nme, whether or not the printer prints test pge, n numer of other persistent vlues. egin mkes sttusit the urrent itionry. /prout lo returns or gets the vlue of prout for the lser printer. In the se of n Apple LserWriter, /prout lo returns LserWriter; with Linotron L300, it returns Linotype. Therefore, epening on whih printer you re using, this line woul re LserWriter Linotype eq or re Linotype Linotype eq. eq looks to see if the top two items on the stk re equl n returns either true or flse (known s oolen). On the LserWriter we ll get flse, on the L300 we ll get true. In the next line, { setpgeprms} if, etween the { } is proeure tht sets the pge size to 840 wie, 1850 high, n n offset of 12 points from the ege s vertil pge (0 is lnspe). if is ontrol opertor tht will exeute the pge size proeure if the oolen from the previous line is true. If it s flse, the pge size oesn t hnge. In short, if this file is eing printe on Linotron, use these pge prmeters. If not, isregr them. % sttusit egin /prout lo (Linotype) eq { setpgeprms} if en % This next setion of the progrm is user itionry nme Sherms ontining opertor reefinitions n proeures. The purpose of Sherms is to hopefully gin some performne, ut mostly it is typing onveniene. It is esier to type m inste of moveto, l for lineto, n so on. If the files were very lrge, performne woul e more esily seen. See setion % /Sherms 35 it ef Sherms egin / {in ef} in ef /l {lo ef} /m /moveto l / /urveto l /rl /rlineto l /l /lineto l /s /show l /S /stroke l /r /repet l some vne progrmming ies 187

198 Tking Avntge of PostSript urx ury 0 0 moveto llx lly % The purpose of the following lines of oe is to otin four numers. The four numers re the ouning ox of the lef hrter of the Sont font. The ouning ox is the x y lotions of the lower left n upper right orners. I nee these numers so I n utomtilly rete pttern the sme size s the lef hrter s ouning ox. One I get the four numers, I ll nee to just them euse the lower left orner will hve negtive y vlue. Note where the 0 0 moveto is lote in this rwing. I etermine the size of the lef y tril n error using seebbox1.ps foun in setion D.5. % /Sont finfont [ ] mkefont setfont 0 0 m (&) true hrpth % get hr pth flttenpth % reues urves to stright lines pthox % get BBox numers /ury exh ef /urx exh ef /lly exh ef /llx exh ef newpth % ler pth /str 512 string ef /y lly neg ury vi ef /x urx vi ef /pttern { /rk exh ef /lite exh ef /if rk lite su ef x y sle % x n y from ove, size of pttern x y 8 [ x 0 0 y 0 0 ] { {str exh rn if mo lite put} for str} imge} /n {rn exh mo vr} /gry {100 n.01 mul.1 } /r1 {800 n 1200 n m (e) s} % rnom notes /r2 {400 n 400 n m (e) s} /r3 {400 n 400 n m (h) s} /r4 {400 n 400 n m (w) s} % newpth % frme 0 setgry 0 0 m l l l losepth 6 setlinewith S 222 srn gsve % pttern ehin everything 3 3 sle pttern 188 some vne progrmming ies

199 Chpter 17 grestore gsve 20 setflt % to prevent limithek error 3 3 sle llx lly s m % ple lef (&) true hrpth lip pttern % pttern in lip lef grestore % rnom notes /Sont finfont 18 slefont setfont srn gsve trnslte 20 {gry setgry 10 {r1} r } r 10 {gry setgry 10 {r3} r } r grestore gsve trnslte 5 {gry setgry 10 {r2} r } r 5 {gry setgry 10 {r4} r } r grestore % stff setlinewith.5 setgry m rl S m rl S m rl S m rl S m rl S % urve setlinewith 1 setgry m l S m some vne progrmming ies 189

200 Tking Avntge of PostSript l S m rl S m rl S m rl S S % lrge note /Sont finfont 300 slefont setfont m.9 setgry (e) s en % for sherms it showpge 190 some vne progrmming ies

201 Chpter symphony, opus 1 listing This esign is the first pnel of triptyh entitle Symphony, opus 1. It egins with the efinition of rbit-romn, font expline in more etil in This esign inlues two smll snne imges. These snne imges were rete using Ion on the NeXT for wnt of nything else t the time. If you re using the M, I use Aoe PhotoShop to mke your pitures. Also, I woul get goo text eitor (I use QUED) if you now use MSWor or MWrite to write your text files. Files with snne imges ten to e ig; MSWor n MWrite on t hnle lrge files very well. The size of your file my lso e limite y the mount of RAM you hve in your omputer. some vne progrmming ies 191

202 Tking Avntge of PostSript PS lern 17 7 %!PS-Aoe-2.0 EPSF-1.2 %%Title:symphony, opus 1.1 %%Cretor:John F Shermn University of Notre Dme %%CretionDte: opyright Jn 1990 %%DoumentFonts:Sont %%BouningBox: sttusit % For Linotron printing egin /prout lo (Linotype) eq { setpgeprms} if en /newfont 10 it ef newfont egin /FontType 3 ef /FontMtrix [ ] ef /FontBBox [ ] ef /Enoing 256 rry ef StnrEnoing Enoing opy pop /ChrPros 30 it ef ChrPros egin /.notef{ } ef /str 512 string ef /rbit { {ChrPros /str get exe exh rn 255 mo put} for ChrPros /str get exe } ef /spe{0 0 moveto newpth} in ef /zero {48 srn true [ ] {ChrPros /rbit get exe}imgemsk} in ef /one /two {49 srn true [ ] {ChrPros /rbit get exe}imgemsk} in ef {50 srn true [ ] {ChrPros /rbit get exe}imgemsk} in ef /three{51 srn true [ ] {ChrPros /rbit get exe}imgemsk} in ef /four {52 srn true [ ] {ChrPros /rbit get exe}imgemsk} in ef 192 some vne progrmming ies

203 Chpter 17 /five {53 srn true [ ] {ChrPros /rbit get exe}imgemsk} in ef /six {54 srn true [ ] {ChrPros /rbit get exe}imgemsk} in ef /seven{55 srn true [ ] {ChrPros /rbit get exe}imgemsk} in ef /eight{56 srn true [ ] {ChrPros /rbit get exe}imgemsk} in ef /nine {57 srn true [ ] {ChrPros /rbit get exe}imgemsk} in ef /A {65 srn true [ ] {ChrPros /rbit get exe}imgemsk} in ef /B {66 srn true [ ] {ChrPros /rbit get exe}imgemsk} in ef /C {67 srn true [ ] {ChrPros /rbit get exe}imgemsk} in ef /D {68 srn true [ ] {ChrPros /rbit get exe}imgemsk} in ef /E {69 srn true [ ] {ChrPros /rbit get exe}imgemsk} in ef /F {70 srn true [ ] {ChrPros /rbit get exe}imgemsk} in ef / {97 srn true [ ] {ChrPros /rbit get exe}imgemsk} in ef / {98 srn true [ ] {ChrPros /rbit get exe}imgemsk} in ef / {99 srn some vne progrmming ies 193

204 Tking Avntge of PostSript true [ ] {ChrPros /rbit get exe}imgemsk} in ef / {100 srn true [ ] {ChrPros /rbit get exe}imgemsk} in ef /e {101 srn true [ ] {ChrPros /rbit get exe}imgemsk} in ef /f {102 srn true [ ] {ChrPros /rbit get exe}imgemsk} in ef en /BuilChr { setheevie exh egin Enoing exh get ChrPros exh get exe en} ef en /rbit-romn newfont efinefont pop % PROCEDURES % These proeures re efine to simplify typing. / {in ef} in ef /l {lo ef} /m /moveto l /sg /setgry l /s /show l /fstr 256 string ef % BEGIN DESIGN ONE Sine rbit-romn is mono-spe font, I n set up gri pttern se on its point size of 100. A hrter n spe re eh 100 points squre. Notie my m or moveto ommns re in 100 point intervls up the pge. Lter on you ll see spes use to rek up the pttern. % /rbit-romn finfont 100 slefont setfont gsve trnslte.9 sg 0 0 m ( ) s m ( ) s m ( ) s m ( ) s m ( ) s m ( ) s 194 some vne progrmming ies

205 Chpter m ( ) s m ( ) s m ( ) s m ( ) s m ( ) s m ( ) s m ( ) s m ( ) s m ( ) s m ( ) s m ( ) s m ( ) s grestore gsve % fountin -21 rotte { fstr exh up put } for sle [ ] { fstr} imge grestore % This tringle shpe ws the prout of n ient. I ment to mke retngle. I entere the oorintes wrong, ut like the result. The tringle shpe is fille lk n is use s lipping pth for the reverse fountin n rbit-romn hrters. % gsve % lrge tringle 0 sg moveto lineto lineto losepth lip fill.1 sg m ( ) s m ( ) s m ( ) s m ( ) s gsve {1 exh su} settrnsfer % reverses fountin -21 rotte { fstr exh up put } for sle [ ] { fstr} imge grestore.2 sg m ( ) s m ( ) s m ( ) s m ( ) s grestore some vne progrmming ies 195

206 Tking Avntge of PostSript % One of the hrteristis of rbit-romn is tht you n see through it. This is euse the imgemsk opertor is use inste of imge. This next setion rws the hlf irle tht lips the fountin with the rbit-romn hrters over it. % gsve trnslte m r losepth lip newpth gsve { fstr exh up put } for sle [ ] { fstr } imge grestore.2 sg 0 0 m () s m () s m () s m () s m () s m () s grestore m% 3.8 sg() s m% 4 (A )s.7 sg (e) s m.2 sg (B ) s.5 sg (1) s.3 sg (1) s m.1 sg (1) s 0 sg % vio3 /pistr 25 string ef gsve trnslte sle [ neg 0 100] {urrentfile pistr rehexstring pop} imge AAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAA 196 some vne progrmming ies

207 Chpter 17 AAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4 06 5K of snne t AAAAAAAAA9A AAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAA9A grestore % vio1 /pistr 50 string ef gsve trnslte sle [ neg 0 200] {urrentfile pistr rehexstring pop} imge BFBBA00FBBA4002D55101C AAAAAAAAAAAAAA K of snne t AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA A AAAAAAAAAAAAAA AAgrestore showpge some vne progrmming ies 197

208 Tking Avntge of PostSript 198 PostSript Level 2

209 18 hpter Chpter 18 PostSript Level 2 The PostSript lnguge hs evolve from its first introution in When introue, it ws primrily oneive s pge esription lnguge for lk n white lser printers. Sine then, extensions hve een me for olor printers, omputer isplys n new tehnologies n fetures ville for iniviul lser printers. PostSript Level 2 rings ll these extensions n new imge opportunities into one unifie implementtion. This hpter will onentrte on some of the PostSript Level 2 opertors tht were originlly rete s extensions for Disply PostSript n olor printers. PostSript Level 2 is so new, not ll printers will e equippe with it, so you my not e le to experiment with some of the opertors presente in this hpter. If you hve ess to NeXT, ll the exmples in this hpter n e trie n experimente with. They will work on oth the lk n white n olor NeXT omputers. If you re Mintosh user, you will either nee Level 2 lser printer to use ll these exmples or olor printer for the olor exmples. If you only hve n Apple LserWriter, some of the olor exmples will work, some will not. For exmple, setrgolor will work on n Apple LserWriter, setmykolor will not. Some of the Disply PostSript opertors, suh s retfill n retstroke, n e simulte with Level 1 opertors retfill In PostSript Level 2, there re two new opertors for rwing squres or retngles. They re retfill n retstroke. They originte from the Disply PostSript extensions. retfill is the omintion of moveto, rlineto, n fill. Its syntx is: x y with height retfill where x y is the lotion of the lower left orner of the retngle on the pge reltive to the origin n with height is the istne from the x y to the upper right orner. x y n e thought of s the equivlent of the urrent point me y moveto when using n rlineto. Unlike rlineto, retfill oes not nee the estlishment of urrent point. In the next exmple, three squres re rwn n pinte. The first is rwn in the onventionl wy, the seon n thir re rwn using retfill. PostSript Level 2 199

210 Tking Avntge of PostSript lern PS 18 1 %!PS-Aoe-2.0 EPSF-1.2 %%Title:retfill_1.eps %%BouningBox: moveto % first squre 72 0 rlineto 0 72 rlineto rlineto losepth fill retfill % seon squre trnslte % thir squre.5 setgry retfill lern PS 18 2 As expline erlier, mny lser printers will not e le to unerstn retfill. If you re using suh printer, retfill_1.eps n e rewritten to work on Level 1 lser printer. %!PS-Aoe-2.0 EPSF-1.2 %%Title:retfill_2.eps %%BouningBox: % simulte retfill on Level 1 lser printer /retfill { /ury exh ef /urx exh ef /lly exh ef /llx exh ef llx lly moveto urx 0 rlineto 0 ury rlineto urx neg 0 rlineto losepth fill } ef moveto % first squre 72 0 rlineto 0 72 rlineto rlineto losepth fill retfill % seon squre trnslte % thir squre.5 setgry retfill 200 PostSript Level 2

211 Chpter retstroke retstroke is the omintion of moveto, rlineto, n stroke. Its syntx is: x y with height retstroke where x y is the lotion of the lower left orner of the retngle on the pge reltive to the origin n with height is the istne from the x y to the upper right orner. Unlike retfill, n optionl mtrix n lso e supplie. x y with height mtrix retstroke mtrix will perform trnsformtion on the retngle s line weight, ut not on the pth itself. This is euse the trnsformtion ours fter the onstrution of the pth. retstroke is muh like retfill, s n e seen in the next exmple. This exmple is silly the sme progrm s retfill_1.eps lern PS 18 3 %!PS-Aoe-2.0 EPSF-1.2 %%Title:retstroke_1.eps %%BouningBox: % first squre 3 setlinewith moveto 72 0 rlineto 0 72 rlineto rlineto losepth stroke % seon squre retstroke % thir squre trnslte retstroke The following exmple is rewrite of retstroke_1.eps for Level 1 lser printer. It is essentilly simple vrition of retfill_2.eps from the previous pge. However, it is not omplete sustitute for retstroke. This simultion will not work for the lter exmples of retstroke tht inlue mtrix. A PostSript Level 2 201

212 Tking Avntge of PostSript lern PS 18 4 more etile explntion of the onsiertions involve in emulting Level 2 opertors n e foun in Appenix D: Comptiility Strtegies, in the PostSript Lnguge Referene Mnul, seon eition. %!PS-Aoe-2.0 EPSF-1.2 %%Title:retstroke_2.eps %%BouningBox: % simulte retstroke on Level 1 lser printer /retstroke { /ury exh ef /urx exh ef /lly exh ef /llx exh ef llx lly moveto urx 0 rlineto 0 ury rlineto urx neg 0 rlineto losepth stroke } ef % first squre 3 setlinewith moveto 72 0 rlineto 0 72 rlineto rlineto losepth stroke % seon squre retstroke % thir squre trnslte retstroke As outline in the eginning of this setion, mtrix n e inlue in the retstroke rguments. The trnsformtion ffets the line weight of the retngle. Following re some exmples of how this vrition of retstroke n e use. Note tht the trnsformtions o not hnge the grphi stte lern PS 18 5 %!PS-Aoe-2.0 EPSF-1.2 %%Title:retstroke_3.eps %%BouningBox: setlinewith 202 PostSript Level 2

213 Chpter 18 % first squre [ ] retstroke % seon squre [ ] retstroke % thir squre [ ] retstroke The result of using mtrix with retstroke n e simulte with Level 1 opertors. In this exmple, the seon n thir retngles omplish the sme result s with retstroke use for the first lern PS 18 6 %!PS-Aoe-2.0 EPSF-1.2 %%Title:retstroke_4.eps %%BouningBox: setlinewith % first squre [ ] retstroke gsve % seon squre moveto 72 0 rlineto 0 72 rlineto rlineto losepth 1 4 sle stroke grestore gsve % thir squre moveto 72 0 rlineto 0 72 rlineto rlineto losepth [ ] ont stroke grestore The oorintes of the retngles me y retfill n retstroke n e supplie s n rry. These two lines re the sme: PostSript Level 2 203

214 Tking Avntge of PostSript retfill n [ ] retfill The rry n e given nme so tht the sme imensions of retngle n e use severl times lern PS 18 7 %!PS-Aoe-2.0 EPSF-1.2 %%Title:othRet_1.eps %%BouningBox: /size [ ] ef /m [ ] ef 3 setlinewith % first squre gsve trnslte.5 setgry size retfill 0 setgry size retstroke grestore % seon squre gsve trnslte.5 setgry size retfill 0 setgry size m retstroke grestore 18.3 new type opertors There re severl new font n hrter opertors in PostSript Level 2 tht lso 204 PostSript Level 2

215 Chpter 18 originte from the Disply PostSript extensions. Some re for onveniene, others provie new typogrphi ontrol. The new opertors re: seletfont xshow yshow xyshow seletfont is onsiere onveniene opertor in tht it omines the funtions of the finfont, slefont, n setfont or the finfont, mkefont, n setfont opertors. Inste of writing, /Times-Bol finfont 42 slefont setfont this n e use: /Times-Bol 42 seletfont Inste of writing, /Times-Bol finfont [ ] mkefont setfont this n e use: /Times-Bol 42 [ ] seletfont Exmples of the uses of seletfont n e foun in the type exmples tht follow. xshow, yshow, n xyshow re new opertors tht provie new strtegies for ustom lettersping. xshow permits the iniviul sping of hrters in string long the x xis. yshow iniviully spes hrters long the y xis n xyshow is the omintion of xshow n yshow. Their syntx re: string spingarry xshow string spingarry yshow string spingarry xyshow where spingarry is n rry of numers tht is the sping for eh hrter. In the following exmple, the first rry, [ ], is the sping vlues for T, y, p, n e respetively. If the with of T is hnge from 30 to 34, the ype woul shift to the right 4 points. The e ws given with of 0 only euse nothing is following. If no sping informtion is provie for the lst hrter, n error will our. 72 Type Type PostSript Level 2 205

216 Tking Avntge of PostSript lern PS 18 8 %!PS-Aoe-2.0 EPSF-1.2 %%Title:xshow&.eps %%BouningBox: /Times-Bol 72 seletfont moveto (Type) [ ] xshow /Times-Bol [ ] seletfont moveto (Type) [ ] xshow The following re exmples of xyshow. In this se, the rry is pir of numers for eh hrter s x n y sping within the string. 144 Type 72 Type lern PS 18 9 %!PS-Aoe-2.0 EPSF-1.2 %%Title:type_xy1.eps %%BouningBox: /Helveti-Bol 70 seletfont moveto (Type) show % Level moveto (Type) [ ] xyshow % Level 2 72 T y pe PostSript Level 2

217 Chpter 18 PS lern18 10 %!PS-Aoe-2.0 EPSF-1.2 %%Title:type_xy2.eps %%BouningBox: /Helveti-Bol 70 seletfont moveto (Type) [ ] xyshow Following is n exmple using yshow E P T Y YPE T YP T YPE T E PS lern %!PS-Aoe-2.0 EPSF-1.2 %%Title:type_y1.eps %%BouningBox: /Helveti-Bol 72 seletfont moveto (TYPE) [ ] yshow moveto (TYPE) [ ] yshow /Helveti-Bol 36 seletfont moveto (TYPE) [ ] yshow moveto (TYPE) [ ] yshow Next is n exmple of using xyshow. Note tht the rry is roken over four lines, eh line for wor in the string. PostSript Level 2 207

218 Tking Avntge of PostSript 72 t h e w i n i s l o w i n g lern PS %!PS-Aoe-2.0 EPSF-1.2 %%Title:winy.eps %%BouningBox: /AvntGre-Demi 12 seletfont moveto (the win is lowing) [ ] xyshow 18.4 olor opertors There re three opertors use to speify olor. They re: hue sturtion rightness sethsolor Level 1 re green lue setrgolor Level 1 yn mgent yellow lk setmykolor Level 2 Where in eh se, the rguments re numers etween 0 n 1. Eh opertor is se on ifferent metho of ientifying olor. The first two ove re se on mixing light, the thir is se on mixing inks. In the following exmple, the sme olor is me using eh opertor PostSript Level 2

219 Chpter 18 PS lern18 13 %!PS-Aoe-2.0 EPSF-1.2 %%Title:smeColor.eps %%BouningBox: /squre {moveto 72 0 rlineto 0 72 rlineto rlineto losepth fill} ef setrgolor squre sethsolor squre setmykolor squre setrgolor n sethsolor re oth se on itive olor mixing using light. Re, green, n lue light when mixe equl white. White on TV or white lous in the sky re the result of ll olors of light mixe together. Figure 18 1 shows n itive olor wheel. itive re green lue figure 18 1 PS lern olor emo setmykolor is se on sutrtive olor mixing using pint. Mgent, yn, n yellow pigment when mixe equl lk, t lest in theory. Blk is usully inlue in the mix euse goo totl lk is hr to get without help. Figure 18 2 shows sutrtive olor wheel. PostSript Level 2 209

220 Tking Avntge of PostSript sutrtive mgent yn yellow figure 18 2 Of the two methos, sutrtive olor mixing is the more intuitive wy of speifying olor. It mkes sense tht mixing yn n yellow pint will give green. It n e iffiult, though, to visulize tht re n green light will mke yellow olor pitures Color pitures re me y the olorimge opertor. Its syntx is: with height its mtrix s 0...s n s/ms omp olorimge where: with height its mtrix re the sme s with imge. s 0...s n re one or more t soures. All the olor omponents my e mixe together into one soure or seprte, for exmple, into iniviul re, green, n lue omponents. s/ms is oolen whether the t is from single soure (flse) or multiple soures (true). omp is numer representing the numer of t soures. The following exmple is simplifie version of file me y Aoe PhotoShop. 210 PostSript Level 2

221 Chpter 18 lern PS %!PS-Aoe-2.0 EPSF-1.2 %%Title:Shmrok.eps %%BouningBox: /pistr1 16 string ef /pistr2 16 string ef /pistr3 16 string ef /pistr4 16 string ef /ret {urrentfile exh rehexstring pop} ef /shmrok{ [ ] {pistr1 ret} {pistr2 ret} {pistr3 ret pistr4 ret pop} true 3 olorimge} ef gsve shmrok CCCCCCCCCC000000CCCCCCCCCCCCCCCC olor t C423C603C423C grestore 18.6 overview of new opertors in Level 2 PostSript Level 2 offers numer of new fetures n visul opportunities. It will tke while for ll of these new opertors to mke their wy into printers n omputer isplys. Some things to look forwr to re: Ptterns PostSript Level 2 will hve new opertors to rete ptterns. These ptterns n then e use s the pint for fills n strokes. One pttern ptternnme is rete, it n e use y writing ptternnme setpttern within progrm. Forms Forms n e use to rete the repeting grphis on multiple pge oument or s the nme suggests, on form to e fille out. One the form formnme is efine, it n e use y writing formnme exeform within progrm. Snne pitures Snne pitures will e hnle more effiiently n fster. Snne pitures will e store in ompresse form n e pinte fster. Also, 12-it per pixel lk n white or 36-it olor pitures will e possile. A 12-it piture hs 4096 possile vlues. Color There will e expne support to insure requeste olors will remin onsistent from ifferent snners, to ifferent monitors, to vrious kins of print output. PostSript Level 2 211

222 Tking Avntge of PostSript %!PS-Aoe-2.0 EPSF-2.0 %%Title:grss.eps %%BouningBox: / {rn 50 mo} ef % numer etween 0 & 50 / {rn 100 mo} ef % numer etween 0 & 100 / {rn 150 mo} ef % & so on / {rn 200 mo} ef % see hp 16 /e {rn 250 mo} ef /f {rn 300 mo} ef srn % see rnom # to set sequene.8 setgry % 20% gry retfill % retngle, Level 2 opertor 0 setgry % set olor to lk % rw 34 urve lines % eh ifferent euse of rn numer 34 {0 0 moveto e f urveto stroke} repet 212 lirry of exmples

223 19 hpter Chpter 19 lirry of exmples The purpose of this hpter is to provie itionl progrmming exmples. Some emonstrte ifferent visul ie thn presente in the text, others re exmples of opertors use in ifferent wy. &M1.eps 244 &M2.eps 245 &M3.eps 246 r&type_1.eps 227 r&type_2.eps 228 rto_2.eps 229 rto_3.eps 230 s-relief.eps 275 kgri.eps 253 ox ef1.eps 222 ox ef2.eps 223 ox ef4.eps 224 rnh2.eps 278 rnh3.eps 279 rnh4.eps 280 lip 1.eps 247 lip 2.eps 248 losepth_2.eps 220 ont_3.eps 225 urvetoloops.eps 270 urveto_2.eps 231 urveto_3.eps 232 shpttern1.eps 217 shpttern2.eps 218 shpttern3.eps 219 exite1.eps 262 exite2.eps 263 exploe.eps 264 flower.eps 265 fountin 3-3.eps 241 fountin_lsreen.eps 259 fountinline.eps 273 gesture.eps 261 grss.eps 212 grychrt.eps 271 grychrtrev.eps 272 linep.eps 215 line.eps 214 petl2.eps 266 pie_hrt2.eps 226 rnjzz.eps 260 repet_ox1.eps 234 repet_ox2.eps 235 rottefount.eps 242 rottefount2.eps 243 setsh2.eps 216 setflt.eps 233 setlinejoin2.eps 221 setsreen1-2.eps 255 setsreen3-4.eps 256 setsreen5-6.eps 257 setsreen7-8.eps 258 slinky.eps 281 slinky2.eps 282 str lip.eps 249 str eolip.eps 250 str eofill.eps 251 str fill.eps 252 str2.eps 274 stringwith.eps 240 TCpos&rev.eps 283 theres3.eps 254 3D-Line1.eps 267 3D-Line2.eps 268 3D-LineStr.eps 269 type_1.eps 236 type_2.eps 237 type_3.eps 238 type_4.eps 239 unenoing1.eps 276 unenoing2.eps 277 lirry of exmples 213

224 Tking Avntge of PostSript Here re two wys of rwing line: On top, the finish lotion is reltive to the strt lotion. Below, strt n finish lotions re reltive to the origin %!PS-Aoe-2.0 EPSF-1.2 %%Title:line.eps %%BouningBox: setlinewith moveto lineto stroke moveto rlineto stroke 214 lirry of exmples

225 Chpter 19 The setlinep opertor is use to finish line enings. 0 setlinep is the efult %!PS-Aoe-2.0 EPSF-1.2 %%Title:linep.eps %%BouningBox: setlinewith % ottom n efult moveto lineto stroke % mile 1 setlinep moveto lineto stroke % top 2 setlinep moveto lineto stroke lirry of exmples 215

226 Tking Avntge of PostSript The setsh opertor retes she line %!PS-Aoe-2.0 EPSF-1.2 %%Title:setsh2.eps %%BouningBox: setlinewith 2 2 sle [1] 0 setsh moveto rlineto stroke [1] 2 setsh moveto rlineto stroke [2] 2 setsh moveto rlineto stroke [1 2] 2 setsh moveto rlineto stroke [ ] 0 setsh moveto rlineto stroke [ ] 2 setsh moveto rlineto stroke [ ] 3 setsh moveto rlineto stroke [ ] 4 setsh moveto rlineto stroke 216 lirry of exmples

227 Chpter 19 %!PS-Aoe-2.0 EPSF-1.2 %%Title:shPttern1.eps %%BouningBox: /line {0.5 trnslte 0 0 moveto 36 0 rlineto stroke} ef /sh [ ] ef.5 setlinewith trnslte sle 0 setgry sh 0 setsh line.1 setgry sh 1 setsh line.2 setgry sh 2 setsh line.3 setgry sh 3 setsh line.4 setgry sh 4 setsh line.5 setgry sh 5 setsh line.6 setgry sh 6 setsh line.7 setgry sh 7 setsh line.8 setgry sh 8 setsh line.9 setgry sh 9 setsh line 0 setgry sh 10 setsh line.1 setgry sh 9 setsh line.2 setgry sh 8 setsh line.3 setgry sh 7 setsh line.4 setgry sh 6 setsh line.5 setgry sh 5 setsh line.6 setgry sh 4 setsh line.7 setgry sh 3 setsh line.8 setgry sh 2 setsh line.9 setgry sh 1 setsh line lirry of exmples 217

228 Tking Avntge of PostSript %!PS-Aoe-2.0 EPSF-1.2 %%Title:shPttern2.eps %%BouningBox: /line {0.5 trnslte 0 0 moveto 36 0 rlineto stroke} ef /sh [ ] ef /x -1 ef.5 setlinewith trnslte sle /pttern{ {} for 10 {setgry sh x 1 up /x exh ef setsh line} repet {} for 10 {setgry sh x 1 su up /x exh ef setsh line} repet } ef 3 {pttern} repet 218 lirry of exmples

229 Chpter 19 %!PS-Aoe-2.0 EPSF-1.2 %%Title:shPttern3.eps %%BouningBox: /line {0 4 trnslte 0 0 moveto 40 0 rlineto stroke} ef /sha [ ] ef /shb [ ] ef 4 setlinewith 0-10 trnslte 5 5 sle gsve {} for 10 {setgry shb 0 setsh line} repet grestore gsve {} for 10 {setgry sha 0 setsh line} repet grestore lirry of exmples 219

230 Tking Avntge of PostSript The losepth opertor is use to finish off the finl orner of pth when the en of pth onnets with its eginning. The ifferene losepth mkes is espeilly notiele when the pths re stroke with thik line. Both squres elow hve een rwn the sme size, ut the first oes not use losepth n the seon oes %!PS-Aoe-2.0 EPSF-1.2 %%Title:losepth_2.eps %%BouningBox: setlinewith moveto lineto lineto lineto lineto stroke moveto lineto lineto lineto losepth stroke 220 lirry of exmples

231 Chpter 19 The setlinejoin opertor is use to finish orners. 0 setlinejoin is the efult %!PS-Aoe-2.0 EPSF-1.2 %%Title:setlinejoin2.eps %%BouningBox: /ret {54 0 rlineto 0 72 rlineto rlineto losepth stroke} ef 18 setlinewith 1 setlinejoin % left, roune moveto ret 2 setlinejoin % mile, evele moveto ret 0 setlinejoin % right, miter moveto ret lirry of exmples 221

232 Tking Avntge of PostSript Here s n exmple of efining proeure. The oxes elow re rwn with the rlineto opertor, or reltivelineto. Eh line is rwn se on the lotion of the previous urrent point %!PS-Aoe-2.0 EPSF-1.2 %%Title:ox ef1.eps %%BouningBox: /ox { moveto 72 0 rlineto 0 72 rlineto rlineto losepth } ef 3 setlinewith ox stroke ox stroke 222 lirry of exmples

233 Chpter 19 This ox proeure is efine using the lineto opertor. Note tht the plement for the ox is ontrolle y moving the origin using the trnslte opertor. The gsve n grestore sve n restore the grphi stte %!PS-Aoe-2.0 EPSF-1.2 %%Title:ox ef2.eps %%BouningBox: /ox { 0 0 moveto 72 0 lineto lineto 0 72 lineto losepth } ef 3 setlinewith gsve trnslte ox stroke grestore gsve trnslte ox stroke grestore lirry of exmples 223

234 Tking Avntge of PostSript The ox proeure is now fille with vlue. 0 equls lk (the efult) n 1 equls white. Note tht the seon ox is lk euse the efult is in fore %!PS-Aoe-2.0 EPSF-1.2 %%Title:ox ef4.eps %%BouningBox: /ox { 0 0 moveto 72 0 lineto lineto 0 72 lineto losepth } ef 3 setlinewith gsve.3 setgry trnslte ox fill grestore gsve trnslte ox fill grestore gsve.8 setgry trnslte ox fill grestore 224 lirry of exmples

235 Chpter 19 The ont opertor is use to skew the ox %!PS-Aoe-2.0 EPSF-1.2 %%Title:ont_3.eps %%BouningBox: /ox {0 0 moveto 0 36 rlineto 36 0 rlineto 0-36 rlineto losepth stroke} ef 2 setlinewith trnslte [ ] ont ox trnslte [ ] ont ox trnslte [ ] ont ox lirry of exmples 225

236 Tking Avntge of PostSript The following is vrition of the pie hrt exmple from setion %!PS-Aoe-2.0 EPSF-1.2 %%Title:pieChrt_2.eps %%BouningBox: setlinewith trnslte % perentges with spe in etween /p1 exh 3.6 mul ef /p2 exh 3.6 mul p1 ef /p3 exh 3.6 mul p2 ef /p4 exh 3.6 mul p3 ef /x 72 ef /y 72 ef /r 72 ef /wege {setgry r losepth gsve fill grestore 0 setgry stroke} ef x y moveto x y r 0 p1.2 wege x y moveto x y r p1 p2.4 wege x y moveto x y r p2 p3.6 wege x y moveto x y r p3 p4.8 wege 226 lirry of exmples

237 Chpter 19 The show opertor oes not initilize the urrent point. Therefore, the r tthes itself y line to the urrent point fter the wor r. losepth returns the line. 72 r %!PS-Aoe-2.0 EPSF-1.2 %%Title:r&type_1.eps %%BouningBox: setlinewith /Helveti-Bol finfont 24 slefont setfont moveto (r) show r losepth stroke lirry of exmples 227

238 Tking Avntge of PostSript newpth initilizes the urrent point left fter the wor r. The urrent point is then the eginning of the r. This is why losepth rws line from the eginning to the en of the r. 72 r %!PS-Aoe-2.0 EPSF-1.2 %%Title:r&type_2.eps %%BouningBox: setlinewith /Helveti-Bol finfont 24 slefont setfont moveto (r) show newpth r losepth stroke 228 lirry of exmples

239 Chpter %!PS-Aoe-2.0 EPSF-1.2 %%Title:rto_2.eps %%BouningBox: setlinewith moveto rto rto rto losepth stroke 12 {pop} repet lirry of exmples 229

240 Tking Avntge of PostSript %!PS-Aoe-2.0 EPSF-1.2 %%Title:rto_3.eps %%BouningBox: setlinewith moveto rto 4 {pop} repet lineto stroke 230 lirry of exmples

241 Chpter 19 In this exmple, the Beziér ontrol points re mrke to lel the urveto syntx elow: x1 y1 x2 y2 x2 y2 urveto urveto requires the existing urrent point x1 y1. x2 y2 72 x1 y1 x2 y2 x1 y %!PS-Aoe-2.0 EPSF-1.2 %%Title:urveto_2.eps %%BouningBox: setlinewith moveto urveto stroke lirry of exmples 231

242 Tking Avntge of PostSript This is nother, more involve urve, emonstrting how omplex pths n e rete %!PS-Aoe-2.0 EPSF-1.2 %%Title:urveto_3.eps %%BouningBox: setlinewith moveto lineto urveto urveto stroke 232 lirry of exmples

243 Chpter 19 This progrm emonstrtes how the setflt opertor n ffet the ury of urve s rwing. The finl result will epen on the resolution of the printer euse this opertor is resolution epenent %!PS-Aoe-2.0 EPSF-1.2 %%Title:setflt.eps %%BouningBox: /urve { moveto urveto urveto urveto urveto urveto urveto urveto urveto urveto urveto } ef trnslte gsve % thik gry line.6 setgry 12 setlinewith 90 setflt urve stroke grestore urve stroke % thin lk line lirry of exmples 233

244 Tking Avntge of PostSript The rotte opertor rottes the urrent trnsformtion mtrix or CTM. By repeting tht rottion, this esign n e me %!PS-Aoe-2.0 EPSF-1.2 %%Title:repet_ox1.eps %%BouningBox: /ox { 0 0 moveto 0 72 rlineto 72 0 rlineto 0-72 rlineto losepth stroke } ef trnslte 2 setlinewith 10 { 36 rotte ox } repet 234 lirry of exmples

245 Chpter 19 This is vrition of the previous exmple using fille n stroke squre %!PS-Aoe-2.0 EPSF-1.2 %%Title:repet_ox2.eps %%BouningBox: /ox { 0 0 moveto 0 72 rlineto 72 0 rlineto 0-72 rlineto losepth gsve.5 setgry fill grestore stroke } ef trnslte 2 setlinewith 10 { 36 rotte ox} repet lirry of exmples 235

246 Tking Avntge of PostSript The show opertor in the exmple elow pints string of hrters strting t urrent point, with the urrent font, in the urrent olor. moveto estlishes the urrent point, /fontnme finfont pointsize slefont setfont estlishes the urrent font, n vlue setgry estlishes the urrent olor. 144 typogrphy 72 Type %!PS-Aoe-2.0 EPSF-1.2 %%Title:type_1.eps %%BouningBox: /Helveti-Bol finfont 100 slefont setfont moveto (Type) show /Times-BolItli finfont 48 slefont setfont moveto.5 setgry (typogrphy) show 236 lirry of exmples

247 Chpter 19 The show opertor oes not initilize the urrent point. In the exmple elow, rmoveto justs the hrter sping of the wor Type y moving the urrent point left fter the setting of the T. 72 Type %!PS-Aoe-2.0 EPSF-1.2 %%Title:type_2.eps %%BouningBox: /Helveti-Bol finfont 100 slefont setfont moveto (T) show rmoveto (ype) show lirry of exmples 237

248 Tking Avntge of PostSript The progrm elow ontins exmples of the mkefont opertor. 144 Type 72 Type Type %!PS-Aoe-2.0 EPSF-1.2 %%Title:type_3.eps %%BouningBox: % top /Helveti-Bol finfont [ ] mkefont setfont moveto (Type) show % ottom left /Helveti-Bol finfont [ ] mkefont setfont moveto (Type) show % ottom right norml /Helveti-Bol finfont [ ] mkefont setfont moveto (Type) show 238 lirry of exmples

249 Chpter 19 Here re more exmples of the mkefont opertor. 144 Type Type 72 Type %!PS-Aoe-2.0 EPSF-1.2 %%Title:type_4.eps %%BouningBox: % top /Helveti-Bol finfont [ ] mkefont setfont moveto (Type) show % ottom left /Helveti-Bol finfont [ ] mkefont setfont moveto (Type) show % ottom right norml /Helveti-Bol finfont [ ] mkefont setfont moveto (Type) show lirry of exmples 239

250 Tking Avntge of PostSript The following is n exmple of the stringwith opertor. 72 this this lineupthis %!PS-Aoe-2.0 EPSF-1.2 %%Title:stringwith.eps %%BouningBox: /Times-Bol finfont 36 slefont setfont /with 36 (lineup) stringwith pop ef.5 setgry moveto (lineup) show 0 setgry (this) show with 72 moveto (this) show with 108 moveto (this) show 240 lirry of exmples

251 Chpter 19 %!PS-Aoe-2.0 EPSF-1.2 %%Title:fountin_3-3.eps %%BouningBox: /fountin { /str 256 string ef { str exh up 255 iv hnge mul os neg 2 iv mul vi put } for /ury exh ef /urx exh ef /lly exh ef /llx exh ef gsve llx lly trnslte urx llx su ury lly su sle [ ] {str} imge grestore } ef /hnge 720 ef fountin /hnge 360 ef fountin /hnge 180 ef fountin /hnge 1440 ef fountin lirry of exmples 241

252 Tking Avntge of PostSript %!PS-Aoe-2.0 EPSF-1.2 %%Title:rotteFount.eps %%Cretor:John F Shermn %%BouningBox: /str 256 string ef { str exh up put } for retstroke trnslte gsve 8 {45 rotte gsve sle [ ] {str} imge grestore} repet grestore 242 lirry of exmples

253 Chpter 19 %!PS-Aoe-2.0 EPSF-1.2 %%Title:rotteFount2.eps %%Cretor:John F Shermn %%BouningBox: /str 256 string ef { str exh up put } for retstroke trnslte gsve 8 {45 rotte gsve sle [ ] {str} imge grestore} repet grestore lirry of exmples 243

254 M Tking Avntge of PostSript The following is logo vrition emonstrting lipping with type. %!PS-Aoe-2.0 EPSF-1.2 %%Title:&M1.eps %%BouningBox: % is fille % M is fille /insie /Times-Bol finfont 525 slefont ef /outline /Helveti-Bol finfont 375 slefont ef 0 20 trnslte 0 0 moveto outline setfont (M) true hrpth lip.2 setgry fill.5 setgry 0 9 moveto insie setfont () show 244 lirry of exmples

255 Chpter 19 MM %!PS-Aoe-2.0 EPSF-1.2 %%Title:&M2.eps %%BouningBox: % oth letterforms re outline /insie /Times-Bol finfont 525 slefont ef /outline /Helveti-Bol finfont 375 slefont ef 0 20 trnslte 0 0 moveto outline setfont (M) true hrpth lip newpth 0 9 moveto insie setfont () true hrpth stroke 2 setlinewith 0 0 moveto outline setfont (M) true hrpth stroke lirry of exmples 245

256 Tking Avntge of PostSript MM %!PS-Aoe-2.0 EPSF-1.2 %%Title:&M3.eps %%BouningBox: % is fille % M is outline /insie /Times-Bol finfont 525 slefont ef /outline /Helveti-Bol finfont 375 slefont ef 0 20 trnslte 0 0 moveto outline setfont (M) true hrpth lip newpth.5 setgry 0 9 moveto insie setfont () show 0 setgry 2 setlinewith 0 0 moveto outline setfont (M) true hrpth stroke 246 lirry of exmples

257 Chpter %!PS-Aoe-2.0 EPSF-1.2 %%Title:lip_1.eps %%BouningBox: moveto rlineto rlineto rlineto losepth lip newpth r.5 setgry fill r.2 setgry fill r.8 setgry fill lirry of exmples 247

258 Tking Avntge of PostSript ND %!PS-Aoe-2.0 EPSF-1.2 %%Title:lip_2.eps %%BouningBox: trnslte 0 0 moveto /Helveti-Bol finfont 200 slefont setfont (ND) true hrpth lip /str 256 string ef { str exh up put } for sle [ ] {str} imge 248 lirry of exmples

259 Chpter rs rs rst StrStrStrStr StrStrStrStr rstrstrs StrStr rstrstr rst StrS rs rs %!PS-Aoe-2.0 EPSF-1.2 %%Title:str lip.eps %%BouningBox: /str (StrStrStrStr) ef /leing { urrentpoint 22 exh pop 0 exh moveto } ef /kgroun { str show leing } ef /Helveti-Bol finfont 30 slefont setfont 36 0 trnslte % str 45 0 moveto lineto lineto lineto lineto 45 0 lineto losepth lip 0 0 moveto 10 {kgroun} repet lirry of exmples 249

260 Tking Avntge of PostSript The following is n exmple of eolip %!PS-Aoe-2.0 EPSF-1.2 %%Title:str eolip.eps %%BouningBox: /str (StrStrStrStr) ef /leing { urrentpoint 22 exh pop 0 exh moveto } ef /kgroun { str show leing } ef /Helveti-Bol finfont 30 slefont setfont 36 0 trnslte rs rs rst StrStrStrStr StrSt trstr rst rs St Str rstrstr rst StrS rs rs % str 45 0 moveto lineto lineto lineto lineto 45 0 lineto losepth eolip 0 0 moveto 10 {kgroun} repet 250 lirry of exmples

261 Chpter 19 The following is n exmple of eofill %!PS-Aoe-2.0 EPSF-1.2 %%Title:str eofill.eps %%BouningBox: trnslte % str 45 0 moveto lineto lineto lineto lineto 45 0 lineto losepth eofill lirry of exmples 251

262 Tking Avntge of PostSript %!PS-Aoe-2.0 EPSF-1.2 %%Title:str fill.eps %%BouningBox: trnslte % str 45 0 moveto lineto lineto lineto lineto 45 0 lineto losepth fill 252 lirry of exmples

263 Chpter 19 This is the kgroun gri for mny of the exmples %!PS-Aoe-2.0 EPSF-1.2 %%Title:kGri.eps %%Cretor:John F Shermn %%BouningBox: /vline{0 0 moveto lineto stroke} ef /hline{0 0 moveto lineto stroke} ef.3 setgry 6 setlinewith moveto 3 3 lineto lineto stroke.5 setgry 1 setlinewith 6 6 trnslte gsve 7 {36 0 trnslte vline} repet grestore gsve 3 {0 36 trnslte hline} repet grestore 0 setgry /Helveti finfont 8 slefont setfont 2 2 moveto (0 0) show 75 2 moveto (72) show moveto (144) show moveto (216) show 2 75 moveto (72) show lirry of exmples 253

264 Tking Avntge of PostSript In this exmple, the setsreen is ommente out for omprison with the other setsreen exmples. Most of the snne imge is elete to sve spe. efult setsreen %!PS-Aoe-2.0 EPSF-1.2 %%Title:theres3.eps %%BouningBox: /ox {moveto 72 0 rlineto 0 72 rlineto rlineto losepth fill} ef /Helveti-Bol finfont 10 slefont setfont moveto (efult setsreen) show.8 setgry ox.6 setgry ox.4 setgry ox.2 setgry ox % snne piture %%Title: Theres.eps... heer info mul iv up ols mul exh rows mul sle ols rows 8 [ols 0 0 rows neg 0 rows] eginimge 0B0A0D0A070E0F0B090D0D110F0E B17181A141D1A B t A A31607E797B6D5B4D4A514E4C4B4D4E51564C F51 565D5D616D F3F352C grestore en 254 lirry of exmples

265 Chpter {exh pop} setsreen {pop} setsreen %!PS-Aoe-2.0 EPSF-1.2 %%Title:setsreen1-2.eps %%BouningBox: /Helveti finfont 10 slefont setfont /ox {moveto 50 0 rlineto 0 50 rlineto rlineto losepth fill} ef {exh pop} setsreen moveto (20 45 {exh pop} setsreen) show.8 setgry ox.6 setgry ox.4 setgry ox.2 setgry ox 0 setgry {pop} setsreen moveto (20 45 {pop} setsreen) show.8 setgry ox.6 setgry ox.4 setgry ox.2 setgry ox lirry of exmples 255

266 Tking Avntge of PostSript {mul.1 } setsreen { 2 iv} setsreen %!PS-Aoe-2.0 EPSF-1.2 %%Title:setsreen3-4.eps %%BouningBox: /Helveti finfont 10 slefont setfont /ox {moveto 50 0 rlineto 0 50 rlineto rlineto losepth fill} ef {mul.1 } setsreen moveto (20 45 {mul.1 } setsreen) show.8 setgry ox.6 setgry ox.4 setgry ox.2 setgry ox 0 setgry { 2 iv} setsreen moveto (20 45 { 2 iv} setsreen) show.8 setgry ox.6 setgry ox.4 setgry ox.2 setgry ox 256 lirry of exmples

267 Chpter {up mul exh up mul 2 iv 1 exh su sqrt 1 exh su} setsreen {s exh s 2 opy gt {pop}{exh pop} ifelse 1 exh su} setsreen %!PS-Aoe-2.0 EPSF-1.2 %%Title:setsreen5-6.eps %%BouningBox: /Helveti finfont 9 slefont setfont /ox {moveto 50 0 rlineto 0 50 rlineto rlineto losepth fill} ef {up mul exh up mul 2 iv 1 exh su sqrt 1 exh su} setsreen moveto (20 45 {up mul exh up mul 2 iv 1 exh su sqrt 1 exh su} setsreen) show.8 setgry ox.6 setgry ox.4 setgry ox.2 setgry ox 0 setgry {s exh s 2 opy gt {pop}{exh pop} ifelse 1 exh su} setsreen moveto (20 45 {s exh s 2 opy gt {pop}{exh pop} ifelse 1 exh su} setsreen) show.8 setgry ox.6 setgry ox.4 setgry ox.2 setgry ox lirry of exmples 257

268 Tking Avntge of PostSript {exh pop s 1 exh su} setsreen { s 2 iv 1 exh su } setsreen %!PS-Aoe-2.0 EPSF-1.2 %%Title:setsreen7-8.eps %%BouningBox: /Helveti finfont 10 slefont setfont /ox {moveto 50 0 rlineto 0 50 rlineto rlineto losepth fill} ef {exh pop s 1 exh su} setsreen moveto (20 45 {exh pop s 1 exh su} setsreen) show.8 setgry ox.6 setgry ox.4 setgry ox.2 setgry ox 0 setgry { s 2 iv 1 exh su} setsreen moveto (20 45 { s 2 iv 1 exh su} setsreen) show.8 setgry ox.6 setgry ox.4 setgry ox.2 setgry ox 258 lirry of exmples

269 Chpter 19 %!PS-Aoe-2.0 EPSF-1.2 %%Title:fountin_LSreen.eps %%Cretor:John F Shermn %%BouningBox: /str 256 string ef { str exh up put } for {pop} setsreen sle [ ] {str} imge lirry of exmples 259

270 Tking Avntge of PostSript jzz jzz jzz jzz jzz jzz jzz jzz jzz jzz jzz jzz jzz jzz jzz jzz jzz jzz jzz jzz jzz jzz jzz jzz jzz jzz jzz jzz jzz jzz jzz jzz jzz jzz jzz jzz jzz jzzjzz jzz jzz jzz jzzjzz jzzjzz jzz jzz jzz jzz jzz jzz jzz jzz jzz jzz jzz jzz jzz jzz jzz jzz jzz jzz jzz jzz jzz jzz jzz jzz jzz jzz jzz jzz jzz jzz jzz jzzjzz jzz jzz jzz jzz jzz jzz jzz jzz jzz jzz %!PS-Aoe-2.0 EPSF-1.2 %%Title:rnJzz.eps %%BouningBox: /n {rn exh mo} ef /gry {100 n.01 mul} ef srn trnslte /Helveti finfont 18 slefont setfont 25 {gry setgry 25 {300 n 150 n moveto (jzz) show} repet} repet /Helveti finfont 36 slefont setfont 0 setgry 25 {250 n 125 n moveto (jzz) show} repet /Helveti finfont 72 slefont setfont 2 setlinewith 1 setgry 5 {250 n 100 n moveto (jzz) true hrpth stroke} repet 260 lirry of exmples

271 Chpter %!PS-Aoe-2.0 EPSF-1.2 %%Title:gesture.eps %%BouningBox: /n 85 ef /nnn n 3 mul 1 su ef /x1 {rn 50 mo} in ef /x2 {rn 25 mo} in ef trnslte.25 setlinewith x1 x1 moveto 0 1 nnn {} for n {x1 x1 x1 urveto} repet stroke trnslte.25 setlinewith x2 x2 moveto 0 1 nnn {} for n {x2 x2 x2 urveto} repet stroke lirry of exmples 261

272 Tking Avntge of PostSript %!PS-Aoe-2.0 EPSF-1.2 %%Title:exite1.eps %%BouningBox: retstroke /x {rn 300 mo} in ef x x moveto 50 {x x x x x x urveto} repet stroke 262 lirry of exmples

273 Chpter 19 %!PS-Aoe-2.0 EPSF-1.2 %%Title:exite2.eps %%BouningBox: retstroke /x {rn 300 mo} in ef /exit{ x x moveto 50 {x x x x x x urveto} repet stroke} ef 5 setlinewith.5 setgry exit 1 setlinewith 0 setgry exit lirry of exmples 263

274 Tking Avntge of PostSript %!PS-Aoe-2.0 EPSF-1.2 %%Title:exploe.eps %%BouningBox: / {50 rn exh mo} in ef / {100 rn exh mo} in ef / {200 rn exh mo} in ef / {300 rn exh mo} in ef /e {400 rn exh mo} in ef /f {500 rn exh mo} in ef retlip.5 setgry retfill.25 setlinewith 0 setgry trnslte 8 {45 rotte 0 0 moveto 100 { e f urveto} repet stroke retstroke } repet 264 lirry of exmples

275 Chpter 19 %!PS-Aoe-2.0 EPSF-1.2 %%Title:flower.eps %%BouningBox: retlip.5 setgry retfill trnslte 1 setgry 10 { 36 rotte 0 0 moveto urveto fill} repet 0 setgry.25 setlinewith 10 { 36 rotte {} for 0 0 moveto 85 { urveto} repet stroke } repet lirry of exmples 265

276 Tking Avntge of PostSript %!PS-Aoe-2.0 EPSF-1.2 %%Title:petl2.eps %%BouningBox: trnslte.25 setlinewith {} for 0 0 moveto 85 { urveto} repet stroke 266 lirry of exmples

277 Chpter %!PS-Aoe-2.0 EPSF-1.2 %%Title:3D-Line1.eps %%BouningBox: /line {25 0 rlineto} ef 30 rotte 1 setlinewith 0 0 moveto 16 {urrentlinewith 1 setlinewith line urrentpoint stroke moveto} repet lirry of exmples 267

278 Tking Avntge of PostSript %!PS-Aoe-2.0 EPSF-1.2 %%Title:3D-Line2.eps %%BouningBox: /line {25 0 rlineto} ef 1 setlinewith 1 setlinep 1 setgry 0 0 moveto /L {/length exh ef gsve /setions {length 25 iv vi} ef /v 1 setions iv ef setions { urrentlinewith 1 setlinewith line urrentpoint stroke moveto urrentgry v su setgry} repet grestore} ef 20 rotte 200 L 10 rotte 400 L 10 rotte 250 L 268 lirry of exmples

279 Chpter 19 %!PS-Aoe-2.0 EPSF-1.2 %%Title:3D-LineStr.eps %%BouningBox: sle.666 setgry retlip retfill /line {25 0 rlineto} ef trnslte 10 rotte 1 setlinewith 1 setlinep 1 setgry 0 0 moveto /L { /length exh ef gsve /setions {length 25 iv vi} ef /v 1 setions iv ef setions {urrentlinewith 1 setlinewith line urrentpoint stroke moveto urrentgry v su setgry} repet grestore} ef 10 { 13 rotte 200 L 11 rotte 500 L 10 rotte 250 L 10 rotte 400 L 10 rotte 250 L 10 rotte 275 L} repet lirry of exmples 269

280 Tking Avntge of PostSript %!PS-Aoe-2.0 EPSF-1.2 %%Title:urvetoLoops.eps %%BouningBox: setgry 6 setlinewith moveto urveto stroke 0 setgry 1 setlinewith moveto urveto stroke moveto urveto stroke 270 lirry of exmples

281 Chpter 19 %!PS-Aoe-2.0 EPSF-1.2 %%Title:gryChrt.eps %%BouningBox: /ox /oxx {0 0 moveto 22 0 rlineto 0 22 rlineto rlineto losepth fill} ef {10 {25 0 trnslte urrentgry.01 setgry ox} repet} ef 0 25 trnslte oxx 9 { trnslte oxx} repet lirry of exmples 271

282 Tking Avntge of PostSript %!PS-Aoe-2.0 EPSF-1.2 %%Title:gryChrtRev.eps %%BouningBox: /ox /oxx {0 0 moveto 22 0 rlineto 0 22 rlineto rlineto losepth fill} ef {10 {25 0 trnslte urrentgry.01 setgry ox} repet} ef {1 exh su} settrnsfer 0 25 trnslte oxx 9 { trnslte oxx} repet 272 lirry of exmples

283 Chpter %!PS-Aoe-2.0 EPSF-1.2 %%Title:fountinLine.eps %%BouningBox: /line {0 0 moveto lineto stroke} ef trnslte 99 {0.75 trnslte urrentgry.01 setgry line} repet 99 {0.75 trnslte urrentgry.01 su setgry line} repet lirry of exmples 273

284 Tking Avntge of PostSript %!PS-Aoe-2.0 EPSF-1.2 %%Title:str2.eps %%BouningBox: /strsie {72 0 lineto urrentpoint trnslte -144 rotte} ef /str {moveto urrentpoint trnslte 4 {strsie} repet losepth gsve setgry fill grestore stroke} ef gsve str grestore gsve str grestore gsve str grestore gsve.5 setgry str grestore 274 lirry of exmples

285 Chpter 19 s-relief %!PS-Aoe-2.0 EPSF-1.2 %%Title:s-relief.eps %%BouningBox: retstroke /nme { 0 0 moveto (s-relief) show} ef /Helveti-Bol finfont 72 slefont setfont trnslte {setgry nme -1.5 trnslte} for 0 setgry nme lirry of exmples 275

286 Tking Avntge of PostSript 72 Vmos l ño? fçe %!PS-Aoe-2.0 EPSF-1.2 %%Title:unenoing1.eps %%BouningBox: /BseFont /Times-Romn finfont ef /newfont BseFont length it ef newfont egin BseFont {1 inex up /FID ne exh /FID ne exh /Enoing ne n {ef}{pop pop} ifelse }in forll /Enoing 256 rry ef StnrEnoing Enoing opy pop Enoing 1 /ntile put Enoing 2 /eill put en /Times-RomnAent newfont efinefont pop /Times-RomnAent finfont 30 slefont setfont moveto (\277Vmos l \1o?) show moveto (f\2e) show 276 lirry of exmples

287 Chpter (N)<4E> 1 it 2 it 4 it 8 it %!PS-Aoe-2.0 EPSF-1.2 %%Title:unenoing2.eps %%BouningBox: /BseFont /Pltino-Romn finfont ef /newfont BseFont length it ef newfont egin BseFont {1 inex up /FID ne exh /FID ne exh /Enoing ne n {ef}{pop pop} ifelse }in forll /Enoing 256 rry ef StnrEnoing Enoing opy pop Enoing 1 /opyright put Enoing 2 /registere put Enoing 3 /tremrk put en /Times-RomnAent newfont efinefont pop /Times-RomnAent finfont 30 slefont setfont moveto (\ Aoe) show moveto (PostSript\2 Lnguge\3) show lirry of exmples 277

288 Tking Avntge of PostSript %!PS-Aoe-2.0 EPSF-1.2 %%Title:rnh2.eps %%BouningBox: /epth 0 ef /mx 4 ef /own {/epth epth 1 ef} in ef /up {/epth epth 1 su ef} in ef /line % vertil line {0 100 rlineto urrentpoint stroke trnslte 0 0 moveto} in ef /rnh {gsve.7.7 sle own line epth mx 2 iv setgry epth mx le {60 rotte rnh -45 rotte rnh -30 rotte rnh -20 rotte -30 rotte rnh} if up grestore} in ef retstroke 10 setlinewith moveto rnh stroke moveto rnh stroke 278 lirry of exmples

289 Chpter 19 %!PS-Aoe-2.0 EPSF-1.2 %%Title:rnh3.eps %%BouningBox: /epth 0 ef /mx 6 ef /own {/epth epth 1 ef} in ef /up {/epth epth 1 su ef} in ef /line {0 75 rlineto urrentpoint stroke trnslte 0 0 moveto} in ef /rnh {gsve.7.7 sle own line epth mx le {60 rotte rnh -150 rotte rnh} if up grestore} in ef retstroke trnslte moveto rnh stroke [ ] ont moveto rnh stroke [ ] ont moveto rnh stroke [ ] ont moveto rnh stroke lirry of exmples 279

290 Tking Avntge of PostSript %!PS-Aoe-2.0 EPSF-1.2 %%Title:rnh4.eps %%BouningBox: /epth 0 ef /mx 8 ef /own {/epth epth 1 ef} in ef /up {/epth epth 1 su ef} in ef /line % vertil line {0 100 rlineto urrentpoint stroke trnslte 0 0 moveto} in ef /rnh{gsve.7.7 sle own line epth mx le {45 rotte rnh -90 rotte rnh} if up grestore} in ef.8 setgry retfill 0 setgry moveto rnh trnslte 180 rotte moveto rnh stroke 280 lirry of exmples

291 Chpter %!PS-Aoe-2.0 EPSF-1.2 %%Title:slinky.eps %%BouningBox: trnslte /slope.2 ef /irle {10 0 moveto r stroke} ef gsve {8 exh slope mul trnslte irle} for grestore /slope.5 ef gsve {8 exh slope mul trnslte irle} for grestore /slope 1 ef gsve {8 exh slope mul trnslte irle} for grestore /slope 3 ef gsve {8 exh slope mul trnslte irle} for grestore /slope 8 ef gsve {8 exh slope mul trnslte irle} for grestore lirry of exmples 281

292 Tking Avntge of PostSript %!PS-Aoe-2.0 EPSF-1.2 %%Title:slinky2.eps %%BouningBox: trnslte /slope.2 ef /irle {0 0 moveto urveto stroke} ef gsve {8 exh slope mul trnslte irle} for grestore /slope.5 ef gsve {8 exh slope mul trnslte irle} for grestore /slope 1 ef gsve {8 exh slope mul trnslte irle} for grestore /slope 3 ef gsve {8 exh slope mul trnslte irle} for grestore /slope 8 ef gsve {8 exh slope mul trnslte irle} for grestore 282 lirry of exmples

293 Chpter 19 %!PS-Aoe-2.0 EPSF-1.2 %%Title:TCpos&rev.eps %%BouningBox: gsve 0 setgry /rows 72 ef /ols 72 ef /pistr1 72 string ef /ret {urrentfile exh rehexstring pop} ef /eginimge {{pistr1 ret} imge} ef mul iv up ols mul exh rows mul sle ols rows 8 [ols 0 0 rows neg 0 rows] eginimge 191F1F1E1F piture t C9A836D55 grestore gsve trnslte {1 exh su} settrnsfer eginimge 191F1F1E1F piture t C9A836D55 grestore en lirry of exmples 283

294 Tking Avntge of PostSript 284 lirry of olor exmples

295 20 hpter Chpter 20 lirry of olor exmples Some of these progrms will work on lk n white printer. Some of the opertors use re prt of PostSript Level 2, whih mens you ll hve to try them on olor lser printer. The files rgboxes.eps n hsboxes.eps will work on n Apple LserWriter, the file mykboxes.eps will not. Pttern1.eps 291 fountin_1.eps 295 -imgewor1.eps 289 -imgewor2.eps 290 mykboxes.eps 288 olorrnotes.eps 292 RLines1.eps 293 RLines2.eps 294 hsboxes.eps 287 rgboxes.eps 286 lirry of olor exmples 285

296 Tking Avntge of PostSript setrgolor re green lue lern PS 20 1 %!PS-Aoe-2.0 EPSF-1.2 %%Title:rgBoxes.eps %%BouningBox: /ox {moveto 50 0 rlineto 0 50 rlineto rlineto losepth fill} ef /lk {0 setgry} ef /Helveti-Olique finfont 10 slefont setfont moveto (re green lue) show /Helveti-Bol finfont 10 slefont setfont moveto (setrgolor) show moveto ( ) show setrgolor ox lk moveto (0.4.7) show setrgolor ox lk moveto (.8.4.7) show setrgolor ox lk moveto (.8.6.4) show setrgolor ox lk moveto (.7.7.7) show setrgolor ox lk moveto (.5.5.5) show setrgolor ox lk moveto (.1.4.5) show setrgolor ox lk moveto (0 1.7) show setrgolor ox 286 lirry of olor exmples

297 Chpter sethsolor hue sturtion rightness PS lern 20 2 %!PS-Aoe-2.0 EPSF-1.2 %%Title:hsBoxes.eps %%BouningBox: /ox {moveto 50 0 rlineto 0 50 rlineto rlineto losepth fill} ef /lk {0 setgry} ef /Helveti-Olique finfont 10 slefont setfont moveto (hue sturtion rightness) show /Helveti-Bol finfont 10 slefont setfont moveto (sethsolor) show moveto ( ) show sethsolor ox lk moveto (0.4.7) show sethsolor ox lk moveto (.8.4.7) show sethsolor ox lk moveto (.8.6.4) show sethsolor ox lk moveto (.7.7.7) show sethsolor ox lk moveto (.5.5.5) show sethsolor ox lk moveto (.1.4.5) show sethsolor ox lk moveto (0 1.7) show sethsolor ox lirry of olor exmples 287

298 Tking Avntge of PostSript setmykolor yn mgent yellow lk lern PS 20 3 %!PS-Aoe-2.0 EPSF-1.2 %%Title:mykBoxes.eps %%BouningBox: /ox {moveto 50 0 rlineto 0 50 rlineto rlineto losepth fill} ef /lk {0 setgry} ef /Helveti-Olique finfont 10 slefont setfont moveto (yn mgent yellow lk) show /Helveti-Bol finfont 10 slefont setfont moveto (setmykolor) show moveto ( ) show setmykolor ox lk moveto ( ) show setmykolor ox lk moveto ( ) show setmykolor ox lk moveto ( ) show setmykolor ox lk moveto ( ) show setmykolor ox lk moveto ( ) show setmykolor ox lk moveto ( ) show setmykolor ox lk moveto ( ) show setmykolor ox 288 lirry of olor exmples

299 Chpter lern PS 20 4 %!PS-Aoe-2.0 EPSF-1.2 %%Title:-imgeWor1.eps %%Cretor:John F Shermn %%CretionDte:De 1990 %%BouningBox: /wor (John, Crolyn, Willim, Ptrik & Theres) ef trnslte [ ] {wor} true 1 olorimge trnslte [ ] {wor} flse 4 olorimge lirry of olor exmples 289

300 Tking Avntge of PostSript The ifferene etween this PostSript exmple n the exmple on the previous pge is tht these two squres re 8-it ptterns n the previous squres re 4-it PS lern 20 5 %!PS-Aoe-2.0 EPSF-1.2 %%Title:-imgeWor2.eps %%Cretor:John F Shermn %%CretionDte:De 1990 %%BouningBox: /wor (John, Crolyn, Willim, Ptrik & Theres) ef trnslte [ ] {wor} true 1 olorimge trnslte [ ] {wor} flse 4 olorimge 290 lirry of olor exmples

301 Chpter PS lern 20 6 %!PS-Aoe-2.0 EPSF-1.2 %%Title:Pttern1.eps %%BouningBox: /str 512 string ef /it 4 ef /Pttern { / exh ef / exh ef /iff su ef 7 7 it [ ] { {str exh rn iff mo put} for str} flse 4 olorimge} ef 222 srn trnslte 0 75 Pttern 80 0 trnslte Pttern 80 0 trnslte Pttern 80 0 trnslte Pttern /it 8 ef trnslte 0 75 Pttern 80 0 trnslte Pttern 80 0 trnslte Pttern 80 0 trnslte Pttern lirry of olor exmples 291

302 Tking Avntge of PostSript 292 lirry of olor exmples %!PS-Aoe-2.0 EPSF-1.2 %%Title:olorRNotes.eps %%BouningBox: /Sont finfont 24 slefont setfont /n {rn exh mo 6 su} ef /g {rn 100 mo.01 mul} ef /lipbox {/ury exh ef /urx exh ef /lly exh ef /llx exh ef llx lly moveto urx lly lineto urx ury lineto llx ury lineto losepth lip} ef srn gsve lipbox / {360 n 180 n moveto (&) show} ef / {250 n 180 n moveto (e) show} ef / {200 n 180 n moveto (e) show} ef / {150 n 180 n moveto (e) show} ef /e {100 n 180 n moveto (e) show} ef 10 {g g g 0 setmykolor 25 {} repet} repet 10 {g g g 0 setmykolor 25 {} repet} repet 10 {g g g 0 setmykolor 25 {} repet} repet 10 {g g g 0 setmykolor 25 {} repet} repet 10 {g g g 0 setmykolor 25 {e} repet} repet grestore 20 7 PS lern

303 Chpter 20 PS lern 20 8 %!PS-Aoe-2.0 EPSF-1.2 %%Title:RLines1.eps %%Cretor:John F Shermn %%CretionDte:De 1990 %%BouningBox: /n {rn exh mo} ef /g {rn 100 mo.01 mul} in ef srn retlip gsve / {400 n 36 n moveto rlineto stroke} ef / {300 n 36 n moveto rlineto stroke} ef / {100 n 36 n moveto rlineto stroke} ef 10 {g g g 0 setmykolor 7 {} repet} repet 10 {g g g 0 setmykolor 7 {} repet} repet 10 {g g g 0 setmykolor 7 {} repet} repet grestore lirry of olor exmples 293

304 Tking Avntge of PostSript PS lern 20 9 %!PS-Aoe-2.0 EPSF-1.2 %%Title:RLines2.eps %%BouningBox: /n {rn exh mo} in ef /g {rn 100 mo.01 mul} in ef srn.8 setgry retfill gsve / {300 n 18 n moveto rlineto stroke} ef / {200 n 18 n moveto rlineto stroke} ef / {100 n 18 n moveto rlineto stroke} ef 3 setlinewith 10 {g g g 0 setmykolor 7 {} repet} repet 1 setlinewith 10 {g g g 0 setmykolor 7 {} repet} repet 10 {g g g 0 setmykolor 7 {} repet} repet grestore 294 lirry of olor exmples

305 Chpter 20 PS lern %!PS-Aoe-2.0 EPSF-1.2 %%Title:fountin_1.eps %%Cretor:John F Shermn %%BouningBox: /fountstring 256 string ef { fountstring exh up put } for sle [ ] { fountstring } flse 4 olorimge lirry of olor exmples 295

306 Tking Avntge of PostSript 296 gllery of esigns Mike s Romne

307 21 hpter Chpter 21 gllery of esigns This hpter ontins numer of exmples of esigns tht emonstrte the potentil of PostSript imge mking. gllery of esigns 297

308 Tking Avntge of PostSript fter the Romne 298 gllery of esigns

309 Chpter 21 AA A B AA B B A B1 it o Romne gllery of esigns 299

310 Tking Avntge of PostSript 300 gllery of esigns violynn

311 Chpter A A A A A B A A A B A A A exite gllery of esigns 301

312 Tking Avntge of PostSript violin Swith 302 gllery of esigns

313 Chpter 21 rclef gllery of esigns 303

Lecture 6: Coding theory

Lecture 6: Coding theory Leture 6: Coing theory Biology 429 Crl Bergstrom Ferury 4, 2008 Soures: This leture loosely follows Cover n Thoms Chpter 5 n Yeung Chpter 3. As usul, some of the text n equtions re tken iretly from those

More information

Factorising FACTORISING.

Factorising FACTORISING. Ftorising FACTORISING www.mthletis.om.u Ftorising FACTORISING Ftorising is the opposite of expning. It is the proess of putting expressions into rkets rther thn expning them out. In this setion you will

More information

Counting Paths Between Vertices. Isomorphism of Graphs. Isomorphism of Graphs. Isomorphism of Graphs. Isomorphism of Graphs. Isomorphism of Graphs

Counting Paths Between Vertices. Isomorphism of Graphs. Isomorphism of Graphs. Isomorphism of Graphs. Isomorphism of Graphs. Isomorphism of Graphs Isomorphism of Grphs Definition The simple grphs G 1 = (V 1, E 1 ) n G = (V, E ) re isomorphi if there is ijetion (n oneto-one n onto funtion) f from V 1 to V with the property tht n re jent in G 1 if

More information

Surds and Indices. Surds and Indices. Curriculum Ready ACMNA: 233,

Surds and Indices. Surds and Indices. Curriculum Ready ACMNA: 233, Surs n Inies Surs n Inies Curriulum Rey ACMNA:, 6 www.mthletis.om Surs SURDS & & Inies INDICES Inies n surs re very losely relte. A numer uner (squre root sign) is lle sur if the squre root n t e simplifie.

More information

Project 6: Minigoals Towards Simplifying and Rewriting Expressions

Project 6: Minigoals Towards Simplifying and Rewriting Expressions MAT 51 Wldis Projet 6: Minigols Towrds Simplifying nd Rewriting Expressions The distriutive property nd like terms You hve proly lerned in previous lsses out dding like terms ut one prolem with the wy

More information

CS 491G Combinatorial Optimization Lecture Notes

CS 491G Combinatorial Optimization Lecture Notes CS 491G Comintoril Optimiztion Leture Notes Dvi Owen July 30, August 1 1 Mthings Figure 1: two possile mthings in simple grph. Definition 1 Given grph G = V, E, mthing is olletion of eges M suh tht e i,

More information

18.06 Problem Set 4 Due Wednesday, Oct. 11, 2006 at 4:00 p.m. in 2-106

18.06 Problem Set 4 Due Wednesday, Oct. 11, 2006 at 4:00 p.m. in 2-106 8. Problem Set Due Wenesy, Ot., t : p.m. in - Problem Mony / Consier the eight vetors 5, 5, 5,..., () List ll of the one-element, linerly epenent sets forme from these. (b) Wht re the two-element, linerly

More information

CSE 332. Sorting. Data Abstractions. CSE 332: Data Abstractions. QuickSort Cutoff 1. Where We Are 2. Bounding The MAXIMUM Problem 4

CSE 332. Sorting. Data Abstractions. CSE 332: Data Abstractions. QuickSort Cutoff 1. Where We Are 2. Bounding The MAXIMUM Problem 4 Am Blnk Leture 13 Winter 2016 CSE 332 CSE 332: Dt Astrtions Sorting Dt Astrtions QuikSort Cutoff 1 Where We Are 2 For smll n, the reursion is wste. The onstnts on quik/merge sort re higher thn the ones

More information

1 PYTHAGORAS THEOREM 1. Given a right angled triangle, the square of the hypotenuse is equal to the sum of the squares of the other two sides.

1 PYTHAGORAS THEOREM 1. Given a right angled triangle, the square of the hypotenuse is equal to the sum of the squares of the other two sides. 1 PYTHAGORAS THEOREM 1 1 Pythgors Theorem In this setion we will present geometri proof of the fmous theorem of Pythgors. Given right ngled tringle, the squre of the hypotenuse is equl to the sum of the

More information

2.4 Theoretical Foundations

2.4 Theoretical Foundations 2 Progrmming Lnguge Syntx 2.4 Theoretil Fountions As note in the min text, snners n prsers re se on the finite utomt n pushown utomt tht form the ottom two levels of the Chomsky lnguge hierrhy. At eh level

More information

I 3 2 = I I 4 = 2A

I 3 2 = I I 4 = 2A ECE 210 Eletril Ciruit Anlysis University of llinois t Chigo 2.13 We re ske to use KCL to fin urrents 1 4. The key point in pplying KCL in this prolem is to strt with noe where only one of the urrents

More information

Numbers and indices. 1.1 Fractions. GCSE C Example 1. Handy hint. Key point

Numbers and indices. 1.1 Fractions. GCSE C Example 1. Handy hint. Key point GCSE C Emple 7 Work out 9 Give your nswer in its simplest form Numers n inies Reiprote mens invert or turn upsie own The reiprol of is 9 9 Mke sure you only invert the frtion you re iviing y 7 You multiply

More information

CS 2204 DIGITAL LOGIC & STATE MACHINE DESIGN SPRING 2014

CS 2204 DIGITAL LOGIC & STATE MACHINE DESIGN SPRING 2014 S 224 DIGITAL LOGI & STATE MAHINE DESIGN SPRING 214 DUE : Mrh 27, 214 HOMEWORK III READ : Relte portions of hpters VII n VIII ASSIGNMENT : There re three questions. Solve ll homework n exm prolems s shown

More information

Lecture 2: Cayley Graphs

Lecture 2: Cayley Graphs Mth 137B Professor: Pri Brtlett Leture 2: Cyley Grphs Week 3 UCSB 2014 (Relevnt soure mteril: Setion VIII.1 of Bollos s Moern Grph Theory; 3.7 of Gosil n Royle s Algeri Grph Theory; vrious ppers I ve re

More information

for all x in [a,b], then the area of the region bounded by the graphs of f and g and the vertical lines x = a and x = b is b [ ( ) ( )] A= f x g x dx

for all x in [a,b], then the area of the region bounded by the graphs of f and g and the vertical lines x = a and x = b is b [ ( ) ( )] A= f x g x dx Applitions of Integrtion Are of Region Between Two Curves Ojetive: Fin the re of region etween two urves using integrtion. Fin the re of region etween interseting urves using integrtion. Desrie integrtion

More information

CARLETON UNIVERSITY. 1.0 Problems and Most Solutions, Sect B, 2005

CARLETON UNIVERSITY. 1.0 Problems and Most Solutions, Sect B, 2005 RLETON UNIVERSIT eprtment of Eletronis ELE 2607 Swithing iruits erury 28, 05; 0 pm.0 Prolems n Most Solutions, Set, 2005 Jn. 2, #8 n #0; Simplify, Prove Prolem. #8 Simplify + + + Reue to four letters (literls).

More information

GM1 Consolidation Worksheet

GM1 Consolidation Worksheet Cmridge Essentils Mthemtis Core 8 GM1 Consolidtion Worksheet GM1 Consolidtion Worksheet 1 Clulte the size of eh ngle mrked y letter. Give resons for your nswers. or exmple, ngles on stright line dd up

More information

THE PYTHAGOREAN THEOREM

THE PYTHAGOREAN THEOREM THE PYTHAGOREAN THEOREM The Pythgoren Theorem is one of the most well-known nd widely used theorems in mthemtis. We will first look t n informl investigtion of the Pythgoren Theorem, nd then pply this

More information

2.4 Linear Inequalities and Interval Notation

2.4 Linear Inequalities and Interval Notation .4 Liner Inequlities nd Intervl Nottion We wnt to solve equtions tht hve n inequlity symol insted of n equl sign. There re four inequlity symols tht we will look t: Less thn , Less thn or

More information

Intermediate Math Circles Wednesday, November 14, 2018 Finite Automata II. Nickolas Rollick a b b. a b 4

Intermediate Math Circles Wednesday, November 14, 2018 Finite Automata II. Nickolas Rollick a b b. a b 4 Intermedite Mth Circles Wednesdy, Novemer 14, 2018 Finite Automt II Nickols Rollick nrollick@uwterloo.c Regulr Lnguges Lst time, we were introduced to the ide of DFA (deterministic finite utomton), one

More information

SIMPLE NONLINEAR GRAPHS

SIMPLE NONLINEAR GRAPHS S i m p l e N o n l i n e r G r p h s SIMPLE NONLINEAR GRAPHS www.mthletis.om.u Simple SIMPLE Nonliner NONLINEAR Grphs GRAPHS Liner equtions hve the form = m+ where the power of (n ) is lws. The re lle

More information

CS 573 Automata Theory and Formal Languages

CS 573 Automata Theory and Formal Languages Non-determinism Automt Theory nd Forml Lnguges Professor Leslie Lnder Leture # 3 Septemer 6, 2 To hieve our gol, we need the onept of Non-deterministi Finite Automton with -moves (NFA) An NFA is tuple

More information

22: Union Find. CS 473u - Algorithms - Spring April 14, We want to maintain a collection of sets, under the operations of:

22: Union Find. CS 473u - Algorithms - Spring April 14, We want to maintain a collection of sets, under the operations of: 22: Union Fin CS 473u - Algorithms - Spring 2005 April 14, 2005 1 Union-Fin We wnt to mintin olletion of sets, uner the opertions of: 1. MkeSet(x) - rete set tht ontins the single element x. 2. Fin(x)

More information

PYTHAGORAS THEOREM WHAT S IN CHAPTER 1? IN THIS CHAPTER YOU WILL:

PYTHAGORAS THEOREM WHAT S IN CHAPTER 1? IN THIS CHAPTER YOU WILL: PYTHAGORAS THEOREM 1 WHAT S IN CHAPTER 1? 1 01 Squres, squre roots nd surds 1 02 Pythgors theorem 1 03 Finding the hypotenuse 1 04 Finding shorter side 1 05 Mixed prolems 1 06 Testing for right-ngled tringles

More information

Let s divide up the interval [ ab, ] into n subintervals with the same length, so we have

Let s divide up the interval [ ab, ] into n subintervals with the same length, so we have III. INTEGRATION Eonomists seem muh more intereste in mrginl effets n ifferentition thn in integrtion. Integrtion is importnt for fining the epete vlue n vrine of rnom vriles, whih is use in eonometris

More information

Now we must transform the original model so we can use the new parameters. = S max. Recruits

Now we must transform the original model so we can use the new parameters. = S max. Recruits MODEL FOR VARIABLE RECRUITMENT (ontinue) Alterntive Prmeteriztions of the pwner-reruit Moels We n write ny moel in numerous ifferent ut equivlent forms. Uner ertin irumstnes it is onvenient to work with

More information

Section 2.1 Special Right Triangles

Section 2.1 Special Right Triangles Se..1 Speil Rigt Tringles 49 Te --90 Tringle Setion.1 Speil Rigt Tringles Te --90 tringle (or just 0-60-90) is so nme euse of its ngle mesures. Te lengts of te sies, toug, ve very speifi pttern to tem

More information

Lesson 2: The Pythagorean Theorem and Similar Triangles. A Brief Review of the Pythagorean Theorem.

Lesson 2: The Pythagorean Theorem and Similar Triangles. A Brief Review of the Pythagorean Theorem. 27 Lesson 2: The Pythgoren Theorem nd Similr Tringles A Brief Review of the Pythgoren Theorem. Rell tht n ngle whih mesures 90º is lled right ngle. If one of the ngles of tringle is right ngle, then we

More information

Equivalent fractions have the same value but they have different denominators. This means they have been divided into a different number of parts.

Equivalent fractions have the same value but they have different denominators. This means they have been divided into a different number of parts. Frtions equivlent frtions Equivlent frtions hve the sme vlue ut they hve ifferent enomintors. This mens they hve een ivie into ifferent numer of prts. Use the wll to fin the equivlent frtions: Wht frtions

More information

Total score: /100 points

Total score: /100 points Points misse: Stuent's Nme: Totl sore: /100 points Est Tennessee Stte University Deprtment of Computer n Informtion Sienes CSCI 2710 (Trnoff) Disrete Strutures TEST 2 for Fll Semester, 2004 Re this efore

More information

Area and Perimeter. Area and Perimeter. Solutions. Curriculum Ready.

Area and Perimeter. Area and Perimeter. Solutions. Curriculum Ready. Are n Perimeter Are n Perimeter Solutions Curriulum Rey www.mthletis.om How oes it work? Solutions Are n Perimeter Pge questions Are using unit squres Are = whole squres Are = 6 whole squres = units =

More information

Probability The Language of Chance P(A) Mathletics Instant Workbooks. Copyright

Probability The Language of Chance P(A) Mathletics Instant Workbooks. Copyright Proility The Lnguge of Chne Stuent Book - Series L-1 P(A) Mthletis Instnt Workooks Copyright Proility The Lnguge of Chne Stuent Book - Series L Contents Topis Topi 1 - Lnguge of proility Topi 2 - Smple

More information

Algorithm Design and Analysis

Algorithm Design and Analysis Algorithm Design nd Anlysis LECTURE 5 Supplement Greedy Algorithms Cont d Minimizing lteness Ching (NOT overed in leture) Adm Smith 9/8/10 A. Smith; sed on slides y E. Demine, C. Leiserson, S. Rskhodnikov,

More information

Solutions for HW9. Bipartite: put the red vertices in V 1 and the black in V 2. Not bipartite!

Solutions for HW9. Bipartite: put the red vertices in V 1 and the black in V 2. Not bipartite! Solutions for HW9 Exerise 28. () Drw C 6, W 6 K 6, n K 5,3. C 6 : W 6 : K 6 : K 5,3 : () Whih of the following re iprtite? Justify your nswer. Biprtite: put the re verties in V 1 n the lk in V 2. Biprtite:

More information

CS311 Computational Structures Regular Languages and Regular Grammars. Lecture 6

CS311 Computational Structures Regular Languages and Regular Grammars. Lecture 6 CS311 Computtionl Strutures Regulr Lnguges nd Regulr Grmmrs Leture 6 1 Wht we know so fr: RLs re losed under produt, union nd * Every RL n e written s RE, nd every RE represents RL Every RL n e reognized

More information

MCH T 111 Handout Triangle Review Page 1 of 3

MCH T 111 Handout Triangle Review Page 1 of 3 Hnout Tringle Review Pge of 3 In the stuy of sttis, it is importnt tht you e le to solve lgeri equtions n tringle prolems using trigonometry. The following is review of trigonometry sis. Right Tringle:

More information

Chapter 8 Roots and Radicals

Chapter 8 Roots and Radicals Chpter 8 Roots nd Rdils 7 ROOTS AND RADICALS 8 Figure 8. Grphene is n inredily strong nd flexile mteril mde from ron. It n lso ondut eletriity. Notie the hexgonl grid pttern. (redit: AlexnderAIUS / Wikimedi

More information

Finite State Automata and Determinisation

Finite State Automata and Determinisation Finite Stte Automt nd Deterministion Tim Dworn Jnury, 2016 Lnguges fs nf re df Deterministion 2 Outline 1 Lnguges 2 Finite Stte Automt (fs) 3 Non-deterministi Finite Stte Automt (nf) 4 Regulr Expressions

More information

The University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 2 MODULE, SPRING SEMESTER MACHINES AND THEIR LANGUAGES ANSWERS

The University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 2 MODULE, SPRING SEMESTER MACHINES AND THEIR LANGUAGES ANSWERS The University of ottinghm SCHOOL OF COMPUTR SCIC A LVL 2 MODUL, SPRIG SMSTR 2015 2016 MACHIS AD THIR LAGUAGS ASWRS Time llowed TWO hours Cndidtes my omplete the front over of their nswer ook nd sign their

More information

6.5 Improper integrals

6.5 Improper integrals Eerpt from "Clulus" 3 AoPS In. www.rtofprolemsolving.om 6.5. IMPROPER INTEGRALS 6.5 Improper integrls As we ve seen, we use the definite integrl R f to ompute the re of the region under the grph of y =

More information

Nondeterministic Finite Automata

Nondeterministic Finite Automata Nondeterministi Finite utomt The Power of Guessing Tuesdy, Otoer 4, 2 Reding: Sipser.2 (first prt); Stoughton 3.3 3.5 S235 Lnguges nd utomt eprtment of omputer Siene Wellesley ollege Finite utomton (F)

More information

Momentum and Energy Review

Momentum and Energy Review Momentum n Energy Review Nme: Dte: 1. A 0.0600-kilogrm ll trveling t 60.0 meters per seon hits onrete wll. Wht spee must 0.0100-kilogrm ullet hve in orer to hit the wll with the sme mgnitue of momentum

More information

CS 360 Exam 2 Fall 2014 Name

CS 360 Exam 2 Fall 2014 Name CS 360 Exm 2 Fll 2014 Nme 1. The lsses shown elow efine singly-linke list n stk. Write three ifferent O(n)-time versions of the reverse_print metho s speifie elow. Eh version of the metho shoul output

More information

Improper Integrals. The First Fundamental Theorem of Calculus, as we ve discussed in class, goes as follows:

Improper Integrals. The First Fundamental Theorem of Calculus, as we ve discussed in class, goes as follows: Improper Integrls The First Fundmentl Theorem of Clculus, s we ve discussed in clss, goes s follows: If f is continuous on the intervl [, ] nd F is function for which F t = ft, then ftdt = F F. An integrl

More information

Spacetime and the Quantum World Questions Fall 2010

Spacetime and the Quantum World Questions Fall 2010 Spetime nd the Quntum World Questions Fll 2010 1. Cliker Questions from Clss: (1) In toss of two die, wht is the proility tht the sum of the outomes is 6? () P (x 1 + x 2 = 6) = 1 36 - out 3% () P (x 1

More information

Grade 6. Mathematics. Student Booklet SPRING 2008 RELEASED ASSESSMENT QUESTIONS. Assessment of Reading,Writing and Mathematics, Junior Division

Grade 6. Mathematics. Student Booklet SPRING 2008 RELEASED ASSESSMENT QUESTIONS. Assessment of Reading,Writing and Mathematics, Junior Division Gre 6 Assessment of Reing,Writing n Mthemtis, Junior Division Stuent Booklet Mthemtis SPRING 2008 RELEASED ASSESSMENT QUESTIONS Plese note: The formt of these ooklets is slightly ifferent from tht use

More information

NON-DETERMINISTIC FSA

NON-DETERMINISTIC FSA Tw o types of non-determinism: NON-DETERMINISTIC FS () Multiple strt-sttes; strt-sttes S Q. The lnguge L(M) ={x:x tkes M from some strt-stte to some finl-stte nd ll of x is proessed}. The string x = is

More information

H SERIES. Algebra Basics. Algebra Basics. Solutions. Curriculum Ready.

H SERIES. Algebra Basics. Algebra Basics. Solutions. Curriculum Ready. Alger Bsis H SERIES Alger Bsis Curriulum Rey www.mthletis.om Copyright 009 P Lerning. All rights reserve. First eition printe 009 in Austrli. A tlogue reor for this ook is ville from P Lerning Lt. ISBN

More information

Exam Review. John Knight Electronics Department, Carleton University March 2, 2009 ELEC 2607 A MIDTERM

Exam Review. John Knight Electronics Department, Carleton University March 2, 2009 ELEC 2607 A MIDTERM riting Exms: Exm Review riting Exms += riting Exms synhronous iruits Res, yles n Stte ssignment Synhronous iruits Stte-Grph onstrution n Smll Prolems lso Multiple Outputs, n Hrer omintionl Prolem riting

More information

WORKSHOP 7 PARASOLID SOLID EXAMPLE

WORKSHOP 7 PARASOLID SOLID EXAMPLE WORKSHOP 7 PARASOLID SOLID EXAMPLE WS7-1 WS7-2 Workshop Ojetives Lern some of the steps tht n e use to rete B-rep soli, i.e. extrue surfe, shell, n ege len. Then, rete the finite element moel. Anlyze the

More information

Lesson 2.1 Inductive Reasoning

Lesson 2.1 Inductive Reasoning Lesson 2.1 Inutive Resoning Nme Perio Dte For Eerises 1 7, use inutive resoning to fin the net two terms in eh sequene. 1. 4, 8, 12, 16,, 2. 400, 200, 100, 50, 25,, 3. 1 8, 2 7, 1 2, 4, 5, 4. 5, 3, 2,

More information

Lesson 2.1 Inductive Reasoning

Lesson 2.1 Inductive Reasoning Lesson 2.1 Inutive Resoning Nme Perio Dte For Eerises 1 7, use inutive resoning to fin the net two terms in eh sequene. 1. 4, 8, 12, 16,, 2. 400, 200, 100, 50, 25,, 3. 1 8, 2 7, 1 2, 4, 5, 4. 5, 3, 2,

More information

How do we solve these things, especially when they get complicated? How do we know when a system has a solution, and when is it unique?

How do we solve these things, especially when they get complicated? How do we know when a system has a solution, and when is it unique? XII. LINEAR ALGEBRA: SOLVING SYSTEMS OF EQUATIONS Tody we re going to tlk out solving systems of liner equtions. These re prolems tht give couple of equtions with couple of unknowns, like: 6= x + x 7=

More information

4.5 THE FUNDAMENTAL THEOREM OF CALCULUS

4.5 THE FUNDAMENTAL THEOREM OF CALCULUS 4.5 The Funmentl Theorem of Clculus Contemporry Clculus 4.5 THE FUNDAMENTAL THEOREM OF CALCULUS This section contins the most importnt n most use theorem of clculus, THE Funmentl Theorem of Clculus. Discovere

More information

Outline Data Structures and Algorithms. Data compression. Data compression. Lossy vs. Lossless. Data Compression

Outline Data Structures and Algorithms. Data compression. Data compression. Lossy vs. Lossless. Data Compression 5-2 Dt Strutures n Algorithms Dt Compression n Huffmn s Algorithm th Fe 2003 Rjshekr Rey Outline Dt ompression Lossy n lossless Exmples Forml view Coes Definition Fixe length vs. vrile length Huffmn s

More information

System Validation (IN4387) November 2, 2012, 14:00-17:00

System Validation (IN4387) November 2, 2012, 14:00-17:00 System Vlidtion (IN4387) Novemer 2, 2012, 14:00-17:00 Importnt Notes. The exmintion omprises 5 question in 4 pges. Give omplete explntion nd do not onfine yourself to giving the finl nswer. Good luk! Exerise

More information

] dx (3) = [15x] 2 0

] dx (3) = [15x] 2 0 Leture 6. Double Integrls nd Volume on etngle Welome to Cl IV!!!! These notes re designed to be redble nd desribe the w I will eplin the mteril in lss. Hopefull the re thorough, but it s good ide to hve

More information

Algorithm Design and Analysis

Algorithm Design and Analysis Algorithm Design nd Anlysis LECTURE 8 Mx. lteness ont d Optiml Ching Adm Smith 9/12/2008 A. Smith; sed on slides y E. Demine, C. Leiserson, S. Rskhodnikov, K. Wyne Sheduling to Minimizing Lteness Minimizing

More information

Basic Derivative Properties

Basic Derivative Properties Bsic Derivtive Properties Let s strt this section by remining ourselves tht the erivtive is the slope of function Wht is the slope of constnt function? c FACT 2 Let f () =c, where c is constnt Then f 0

More information

Comparing the Pre-image and Image of a Dilation

Comparing the Pre-image and Image of a Dilation hpter Summry Key Terms Postultes nd Theorems similr tringles (.1) inluded ngle (.2) inluded side (.2) geometri men (.) indiret mesurement (.6) ngle-ngle Similrity Theorem (.2) Side-Side-Side Similrity

More information

Activities. 4.1 Pythagoras' Theorem 4.2 Spirals 4.3 Clinometers 4.4 Radar 4.5 Posting Parcels 4.6 Interlocking Pipes 4.7 Sine Rule Notes and Solutions

Activities. 4.1 Pythagoras' Theorem 4.2 Spirals 4.3 Clinometers 4.4 Radar 4.5 Posting Parcels 4.6 Interlocking Pipes 4.7 Sine Rule Notes and Solutions MEP: Demonstrtion Projet UNIT 4: Trigonometry UNIT 4 Trigonometry tivities tivities 4. Pythgors' Theorem 4.2 Spirls 4.3 linometers 4.4 Rdr 4.5 Posting Prels 4.6 Interloking Pipes 4.7 Sine Rule Notes nd

More information

Eigenvectors and Eigenvalues

Eigenvectors and Eigenvalues MTB 050 1 ORIGIN 1 Eigenvets n Eigenvlues This wksheet esries the lger use to lulte "prinipl" "hrteristi" iretions lle Eigenvets n the "prinipl" "hrteristi" vlues lle Eigenvlues ssoite with these iretions.

More information

Proportions: A ratio is the quotient of two numbers. For example, 2 3

Proportions: A ratio is the quotient of two numbers. For example, 2 3 Proportions: rtio is the quotient of two numers. For exmple, 2 3 is rtio of 2 n 3. n equlity of two rtios is proportion. For exmple, 3 7 = 15 is proportion. 45 If two sets of numers (none of whih is 0)

More information

Automata and Regular Languages

Automata and Regular Languages Chpter 9 Automt n Regulr Lnguges 9. Introution This hpter looks t mthemtil moels of omputtion n lnguges tht esrie them. The moel-lnguge reltionship hs multiple levels. We shll explore the simplest level,

More information

INTRODUCTION TO AUTOMATA THEORY

INTRODUCTION TO AUTOMATA THEORY Chpter 3 INTRODUCTION TO AUTOMATA THEORY In this hpter we stuy the most si strt moel of omputtion. This moel els with mhines tht hve finite memory pity. Setion 3. els with mhines tht operte eterministilly

More information

Welcome. Balanced search trees. Balanced Search Trees. Inge Li Gørtz

Welcome. Balanced search trees. Balanced Search Trees. Inge Li Gørtz Welome nge Li Gørt. everse tehing n isussion of exerises: 02110 nge Li Gørt 3 tehing ssistnts 8.00-9.15 Group work 9.15-9.45 isussions of your solutions in lss 10.00-11.15 Leture 11.15-11.45 Work on exerises

More information

Trigonometry Revision Sheet Q5 of Paper 2

Trigonometry Revision Sheet Q5 of Paper 2 Trigonometry Revision Sheet Q of Pper The Bsis - The Trigonometry setion is ll out tringles. We will normlly e given some of the sides or ngles of tringle nd we use formule nd rules to find the others.

More information

Part I: Study the theorem statement.

Part I: Study the theorem statement. Nme 1 Nme 2 Nme 3 A STUDY OF PYTHAGORAS THEOREM Instrutions: Together in groups of 2 or 3, fill out the following worksheet. You my lift nswers from the reding, or nswer on your own. Turn in one pket for

More information

Introduction to Olympiad Inequalities

Introduction to Olympiad Inequalities Introdution to Olympid Inequlities Edutionl Studies Progrm HSSP Msshusetts Institute of Tehnology Snj Simonovikj Spring 207 Contents Wrm up nd Am-Gm inequlity 2. Elementry inequlities......................

More information

CSC2542 State-Space Planning

CSC2542 State-Space Planning CSC2542 Stte-Spe Plnning Sheil MIlrith Deprtment of Computer Siene University of Toronto Fll 2010 1 Aknowlegements Some the slies use in this ourse re moifitions of Dn Nu s leture slies for the textook

More information

For a, b, c, d positive if a b and. ac bd. Reciprocal relations for a and b positive. If a > b then a ab > b. then

For a, b, c, d positive if a b and. ac bd. Reciprocal relations for a and b positive. If a > b then a ab > b. then Slrs-7.2-ADV-.7 Improper Definite Integrls 27.. D.dox Pge of Improper Definite Integrls Before we strt the min topi we present relevnt lger nd it review. See Appendix J for more lger review. Inequlities:

More information

Lecture 4: Graph Theory and the Four-Color Theorem

Lecture 4: Graph Theory and the Four-Color Theorem CCS Disrete II Professor: Pri Brtlett Leture 4: Grph Theory n the Four-Color Theorem Week 4 UCSB 2015 Through the rest of this lss, we re going to refer frequently to things lle grphs! If you hen t seen

More information

ILLUSTRATING THE EXTENSION OF A SPECIAL PROPERTY OF CUBIC POLYNOMIALS TO NTH DEGREE POLYNOMIALS

ILLUSTRATING THE EXTENSION OF A SPECIAL PROPERTY OF CUBIC POLYNOMIALS TO NTH DEGREE POLYNOMIALS ILLUSTRATING THE EXTENSION OF A SPECIAL PROPERTY OF CUBIC POLYNOMIALS TO NTH DEGREE POLYNOMIALS Dvid Miller West Virgini University P.O. BOX 6310 30 Armstrong Hll Morgntown, WV 6506 millerd@mth.wvu.edu

More information

The DOACROSS statement

The DOACROSS statement The DOACROSS sttement Is prllel loop similr to DOALL, ut it llows prouer-onsumer type of synhroniztion. Synhroniztion is llowe from lower to higher itertions sine it is ssume tht lower itertions re selete

More information

A Primer on Continuous-time Economic Dynamics

A Primer on Continuous-time Economic Dynamics Eonomis 205A Fll 2008 K Kletzer A Primer on Continuous-time Eonomi Dnmis A Liner Differentil Eqution Sstems (i) Simplest se We egin with the simple liner first-orer ifferentil eqution The generl solution

More information

D. Harel, Statecharts: A visual formalism for complex systems, Science of Computer Programming 8, 1987, pp

D. Harel, Statecharts: A visual formalism for complex systems, Science of Computer Programming 8, 1987, pp Sttechrts y Kenr ooper ontents Introuction Stte igrms epth (hierrchy) Orthogonlity (concurrency) rocst ommuniction Exmple Prolems Introuction Sttechrts were introuce y vi Hrel in 1987. Hrel, Sttechrts:

More information

Chapter 4 State-Space Planning

Chapter 4 State-Space Planning Leture slides for Automted Plnning: Theory nd Prtie Chpter 4 Stte-Spe Plnning Dn S. Nu CMSC 722, AI Plnning University of Mrylnd, Spring 2008 1 Motivtion Nerly ll plnning proedures re serh proedures Different

More information

Digital Circuit Engineering

Digital Circuit Engineering Digitl Ciruit Engineering 5 INPUT MAPS (A) Loop squres with no friens, they n never shre. (B) Loop squres with no rothers, n simutneously loop their friens. Iterte: (A') Loop squres seperte from friens

More information

Chapter 3. Vector Spaces. 3.1 Images and Image Arithmetic

Chapter 3. Vector Spaces. 3.1 Images and Image Arithmetic Chpter 3 Vetor Spes In Chpter 2, we sw tht the set of imges possessed numer of onvenient properties. It turns out tht ny set tht possesses similr onvenient properties n e nlyzed in similr wy. In liner

More information

AP Calculus BC Chapter 8: Integration Techniques, L Hopital s Rule and Improper Integrals

AP Calculus BC Chapter 8: Integration Techniques, L Hopital s Rule and Improper Integrals AP Clulus BC Chpter 8: Integrtion Tehniques, L Hopitl s Rule nd Improper Integrls 8. Bsi Integrtion Rules In this setion we will review vrious integrtion strtegies. Strtegies: I. Seprte the integrnd into

More information

Lecture 8: Abstract Algebra

Lecture 8: Abstract Algebra Mth 94 Professor: Pri Brtlett Leture 8: Astrt Alger Week 8 UCSB 2015 This is the eighth week of the Mthemtis Sujet Test GRE prep ourse; here, we run very rough-n-tumle review of strt lger! As lwys, this

More information

Intermediate Math Circles Wednesday 17 October 2012 Geometry II: Side Lengths

Intermediate Math Circles Wednesday 17 October 2012 Geometry II: Side Lengths Intermedite Mth Cirles Wednesdy 17 Otoer 01 Geometry II: Side Lengths Lst week we disussed vrious ngle properties. As we progressed through the evening, we proved mny results. This week, we will look t

More information

Mechanisms A Brief Introduction October, 2014

Mechanisms A Brief Introduction October, 2014 Mehnisms A Brief Introution Otoer, 2014 A mehnism trnsfers motion n fore from soure to n output. Mehnisms inlue ger trins, liner to rotry onverters, lokworks n more. Mehnisms re everywhere you look from

More information

Common intervals of genomes. Mathieu Raffinot CNRS LIAFA

Common intervals of genomes. Mathieu Raffinot CNRS LIAFA Common intervls of genomes Mthieu Rffinot CNRS LIF Context: omprtive genomis. set of genomes prtilly/totlly nnotte Informtive group of genes or omins? Ex: COG tse Mny iffiulties! iology Wht re two similr

More information

Identifying and Classifying 2-D Shapes

Identifying and Classifying 2-D Shapes Ientifying n Clssifying -D Shpes Wht is your sign? The shpe n olour of trffi signs let motorists know importnt informtion suh s: when to stop onstrution res. Some si shpes use in trffi signs re illustrte

More information

C (6) DOORS TYPICAL, ALL SAME SIZE ENCLOSURE, CUSTOM 6 DOOR REVISION HISTORY ZONE REV DESCRIPTION DATE APPROVED 0.01 RELEASE FOR QUOTE 11/16/12 PH

C (6) DOORS TYPICAL, ALL SAME SIZE ENCLOSURE, CUSTOM 6 DOOR REVISION HISTORY ZONE REV DESCRIPTION DATE APPROVED 0.01 RELEASE FOR QUOTE 11/16/12 PH REVISION HISTORY ZONE REV ESRIPTION TE PPROVE 0.0 RELESE FOR QUOTE /6/2 PH 0.02 E ITONL ETL FOR PGO HOO, SE N OORS. RELESE FOR PROUTION 2/4/3 PH 0.03 INRESE OVERLL OF ENLOUSRE 2/8/3 PH 0.04 REVISE OOR

More information

Logarithms LOGARITHMS.

Logarithms LOGARITHMS. Logrithms LOGARITHMS www.mthletis.om.u Logrithms LOGARITHMS Logrithms re nother method to lulte nd work with eponents. Answer these questions, efore working through this unit. I used to think: In the

More information

CS103B Handout 18 Winter 2007 February 28, 2007 Finite Automata

CS103B Handout 18 Winter 2007 February 28, 2007 Finite Automata CS103B ndout 18 Winter 2007 Ferury 28, 2007 Finite Automt Initil text y Mggie Johnson. Introduction Severl childrens gmes fit the following description: Pieces re set up on plying ord; dice re thrown or

More information

5.3 The Fundamental Theorem of Calculus

5.3 The Fundamental Theorem of Calculus CHAPTER 5. THE DEFINITE INTEGRAL 35 5.3 The Funmentl Theorem of Clculus Emple. Let f(t) t +. () Fin the re of the region below f(t), bove the t-is, n between t n t. (You my wnt to look up the re formul

More information

Particle Physics. Michaelmas Term 2011 Prof Mark Thomson. Handout 3 : Interaction by Particle Exchange and QED. Recap

Particle Physics. Michaelmas Term 2011 Prof Mark Thomson. Handout 3 : Interaction by Particle Exchange and QED. Recap Prtile Physis Mihelms Term 2011 Prof Mrk Thomson g X g X g g Hnout 3 : Intertion y Prtile Exhnge n QED Prof. M.A. Thomson Mihelms 2011 101 Rep Working towrs proper lultion of ey n sttering proesses lnitilly

More information

I1 = I2 I1 = I2 + I3 I1 + I2 = I3 + I4 I 3

I1 = I2 I1 = I2 + I3 I1 + I2 = I3 + I4 I 3 2 The Prllel Circuit Electric Circuits: Figure 2- elow show ttery nd multiple resistors rrnged in prllel. Ech resistor receives portion of the current from the ttery sed on its resistnce. The split is

More information

Tutorial Worksheet. 1. Find all solutions to the linear system by following the given steps. x + 2y + 3z = 2 2x + 3y + z = 4.

Tutorial Worksheet. 1. Find all solutions to the linear system by following the given steps. x + 2y + 3z = 2 2x + 3y + z = 4. Mth 5 Tutoril Week 1 - Jnury 1 1 Nme Setion Tutoril Worksheet 1. Find ll solutions to the liner system by following the given steps x + y + z = x + y + z = 4. y + z = Step 1. Write down the rgumented mtrix

More information

Digital Circuit Engineering

Digital Circuit Engineering Digitl Ciruit Engineering 5 IN UT P MAPS (A) Loop squres with no friens, they n never shre. (B) Loop squres with no rothers, n simutneously loop their friens. Iterte: (A') Loop squres seperte from friens

More information

INTEGRATION. 1 Integrals of Complex Valued functions of a REAL variable

INTEGRATION. 1 Integrals of Complex Valued functions of a REAL variable INTEGRATION NOTE: These notes re supposed to supplement Chpter 4 of the online textbook. 1 Integrls of Complex Vlued funtions of REAL vrible If I is n intervl in R (for exmple I = [, b] or I = (, b)) nd

More information

Pythagoras Theorem. Pythagoras Theorem. Curriculum Ready ACMMG: 222, 245.

Pythagoras Theorem. Pythagoras Theorem. Curriculum Ready ACMMG: 222, 245. Pythgors Theorem Pythgors Theorem Curriulum Redy ACMMG:, 45 www.mthletis.om Fill in these spes with ny other interesting fts you n find out Pythgors. In the world of Mthemtis, Pythgors is legend. He lived

More information

Linear Algebra Introduction

Linear Algebra Introduction Introdution Wht is Liner Alger out? Liner Alger is rnh of mthemtis whih emerged yers k nd ws one of the pioneer rnhes of mthemtis Though, initilly it strted with solving of the simple liner eqution x +

More information

Proving the Pythagorean Theorem

Proving the Pythagorean Theorem Proving the Pythgoren Theorem W. Bline Dowler June 30, 2010 Astrt Most people re fmilir with the formul 2 + 2 = 2. However, in most ses, this ws presented in lssroom s n solute with no ttempt t proof or

More information

Necessary and sucient conditions for some two. Abstract. Further we show that the necessary conditions for the existence of an OD(44 s 1 s 2 )

Necessary and sucient conditions for some two. Abstract. Further we show that the necessary conditions for the existence of an OD(44 s 1 s 2 ) Neessry n suient onitions for some two vrile orthogonl esigns in orer 44 C. Koukouvinos, M. Mitrouli y, n Jennifer Seerry z Deite to Professor Anne Penfol Street Astrt We give new lgorithm whih llows us

More information

6. Suppose lim = constant> 0. Which of the following does not hold?

6. Suppose lim = constant> 0. Which of the following does not hold? CSE 0-00 Nme Test 00 points UTA Stuent ID # Multiple Choie Write your nswer to the LEFT of eh prolem 5 points eh The k lrgest numers in file of n numers n e foun using Θ(k) memory in Θ(n lg k) time using

More information

Typesetting Karnaugh Maps with L A TEX and TikZ

Typesetting Karnaugh Maps with L A TEX and TikZ Typesetting Krnugh Mps with L A TEX n TikZ Luis Pulo Lus emil: lus@utfpr.eu.r Version:., Version te: 89 Astrt Krnugh mps re use to simplify logi equtions leing to the most ompt expression of two levels

More information