%!PS % PostScript-as-Language runtime speedup guidelines #16 % ===================================================== % by Don Lancaster % Copyright c 2003 by Don Lancaster & Synergetics, Box 809, Thatcher, AZ, 85552 % (928) 428-4073 Email: don@tinaja.com Website: http://www.tinaja.com % Consulting services available http://www.tinaja.com/info01.html % Linking welcome. Reposting expressly forbidden. % All commercial rights and all electronic media rights ~fully~ reserved. % Linking usually welcome. Reposting expressly forbidden. Version 1.1 % Gathers together some non-obvious utilities and routines for % PostScript Disk access % IMPORTANT NOTE: Don Lancaster's file gonzo.ps is required for this program. % After obvious location mods, uncomment ONE of the following two lines: (C:\\windows\\desktop\\gonzo\\gonzo.ps) run % use internal gonzo % (A:\\gonzo.ps) run % use external gonzo % NOTE THAT ALL PS FILENAME STRINGS !!!DEMAND!!! DOUBLE REVERSE SLASHES. % GONZO20A Guru Gonzo PostScript power tools (Interim release) % Includes gonzo justification and layout utilities. % Copyright c 1990, 1996, 2001 by Don Lancaster and Synergetics, Box 809, % Thatcher Arizona, 5552 (928) 428-4073 don@tinaja.com support % via http://www.tinaja.com All commercial rights and all electronic % media rights **FULLY** reserved. Reposting is expressly forbidden. %%%%%%%%%%% links menu directory %%%%%%%%%%%% % This code locks pdfmark commands out of a PostScript printer. /pdfmark where {pop}{userdict /pdfmark /cleartomark load put} ifelse % /surl "start url" marks the beginning of a text sequence to be urled. % It also paints the text blue... /surl {mark /blue cvx 0.33 /setgray cvx % change text to blue /currentpoint cvx % remember box start /urly /exch cvx /store cvx /urlx /exch cvx /store cvx ] cvx % complete deferred command printlist exch 3 index exch put % stuff into gonzo printlist exch 1 add exch % increment gonzo list count } def % /eurl "end url" unmarks the end of a text sequence and sets up % the pdfmark needed to define the Acrobat web link. /eurl {mark % start deferred proc exch % position url string % /black cvx 0 /setgray cvx % turn blue marker off % maintextcolor /setrgbcolor cvx % reset to main text color??? /aqua cvx /black cvx /makeurl cvx % defer call of url builder ] cvx % complete deferred proc printlist exch 3 index exch % stuff into gonzo printlist put exch 1 add exch % increment gonzo list count } def % /makeurl generates the pdfmark, receiving a {(urlstring) makeurl}. % Note that it is not called until formatted printlist time... /urlover 0.2 def % fraction of hot area over bounds /makeurl { /cururlname exch store % save the url string mark % start pdfmark currentfont /ScaleMatrix get 3 get /fsize exch store % guess height /Rect [ urlx fsize urlover mul sub % set box left x urly fsize urlover mul sub % set box left y currentpoint exch fsize urlover mul add exch fsize add ] /Border [ 0 0 0] % [0 0 0 ] = none; [0 0 2] = debug /Color [ .7 0 0 ] /Action <> /Subtype /Link /ANN % annotation type pdfmark % call pdf operators } def % /makeurlx generates the box specific pdfmark, receiving % a {(urlstring) makeurl}. % Note that it is not called until formatted printlist time... /makeurlx { /cururlnamex exch store % save the url string mark % start pdfmark /Rect [ xpos % set box left x ypos 0.9 sub % set box left y xpos 2.8 add % box right x ypos 0.9 sub 2.8 add % box right y ] /Border [ 0 0 0] % [0 0 0 ] = none; [0 0 2] = debug /Color [ .7 0 0 ] /Action <> /Subtype /Link /ANN % annotation type pdfmark % call pdf operators } def /maintextcolor {0 0 0 } def % text link specific data -- use dictionary instead below { /cubic01 {(http://www.tinaja.com/cubic01.asp) eurl} def /hack62 {(http://www.tinaja.com/glib/hack62.pdf) eurl} def /increment {(http://www.tinaja.com/text/bezgen3.html) eurl} def /interpolate {(http://members.bellatlantic.net/~vze2vrva/design.html) eurl } def /bezmath {(http://www.tinaja.com/text/bezmath.html) eurl } def /table {(http://www.tinaja.com/psutils/imtable.psl) eurl } def } pop % dictionary method << %zzzzz %%%% unused links have been commented for gg9a simplicity /flut01 (http://www.tinaja.com/flut01.asp) /swingt01 (http://www.tinaja.com/psutils/swingt01.psl) /before01 (http://www.tinaja.com/images/bargs/marcon01.jpg) /during01 (http://www.tinaja.com/images/bargs/marcon01.bmp) /after01 (http://www.tinaja.com/images/bargs/marconz1.jpg) /repobmp (http://www.tinaja.com/glib/repobmp.pdf) /basis01 (http://www.tinaja.com/glib/basis.pdf) /arcata (http://www.arcatapet.net/imgv32.cfm) /comparebmp (http://www.designer-info.com/Writing/bmp_tiff_jpeg_gif.htm) /imagimag (http://www.tinaja.com/glib/imagimag.pdf) /myebays (http://www.tinaja.com/glib/myebays.pdf) /stepprep (http://www.tinaja.com/glib/stepprep.pdf) /aafont01 (http://www.tinaja.com/aafont01.asp) /here1 (http://village.infoweb.ne.jp/~fwhw1257/study/bmpform.htm) /here2 (http://www.daubnet.com/formats/BMP.html) /bittype (http://www.tinaja.com/psutils/pdf2bmp.psl) /photocombine (http://www.tinaja.com/psutils/blender.psl) /psl (http://www.tinaja.com/psutils/) % dummy temp /psl1 (http://www.tinaja.com/psutils/pdf2bmp.psl) /psl2 (http://www.tinaja.com/psutils/acatdata.psl) /psl3 (http://www.tinaja.com/psutils/catwords.psl) /psl4 (http://www.tinaja.com/psutils/graburls.psl) /psl5 (http://www.tinaja.com/psutils/blender.psl) /psl6 (http://www.tinaja.com/psutils/catools1.psl) /psl7 (http://www.tinaja.com/psutils/strconv.html) /psl8 (http://www.tinaja.com/psutils/bodcat.psl) /psl9 (http://www.tinaja.com/psutils/flatvue1.psl) /psl10 (http://www.tinaja.com/psutils/fern2img.psl) /psl11 (http://www.tinaja.com/psutils/flutools.psl) /psl12 (http://www.tinaja.com/psutils/mscal156q.psl) /psl13 (http://www.tinaja.com/psutils/weblogu2.psl) /psl14 (http://www.tinaja.com/psutils/pfa2pfb.psl) /psl15 (http://www.tinaja.com/psutils/pfb2pfa.psl) /psl16 (http://www.tinaja.com/glib/psdisk03.psl) /psl17 (http://www.tinaja.com/psutils/disktool.psl) /psl18 (http://www.tinaja.com/glib/psinscrt.psl) /psl19 (http://www.tinaja.com/glib/pssearch.psl) /psl20 (http://www.tinaja.com/text/refsum1.html) /psl21 (http://www.tinaja.com/text/reflog1.html) /psl22 (http://www.tinaja.com/psutils/reflog1.psl) /psl23 (http://www.tinaja.com/psutils/refsum1.psl) /psl24 (http://www.tinaja.com/psutils/searepl.psl) /psl25 (http://www.tinaja.com/psutils/weberru2.psl) /psl26 (http://www.tinaja.com/psutils/grabsrch.psl) /psl27 (http://www.tinaja.com/psutils/grabrefs.psl) /magsn01 (http://www.tinaja.com/magsn01.asp) /gonzoutils (http://www.tinaja.com/post01.asp#gonzo) /disktool (http://www.tinaja.com/psutils/disktool.ps) /elesimp (http://www.tinaja.com/glib/elesimp.pdf) /tn5603 (http://partners.adobe.com/asn/developer/pdfs/tn/TN5603.Filters.pdf) /fern2img (http://www.tinaja.com/psutils/fern2img.psl) /fern (http://www.tinaja.com/psutils/fern2img.pdf) /oldfern (http://www.tinaja.com/psutils/fernx1.pdf) /acrosdk (http://partners.adobe.com/asn/developer/acrosdk/main.html) /refman2 (http://partners.adobe.com/asn/developer/pdfs/tn/psrefman.pdf) /refman3 (http://partners.adobe.com/asn/developer/pdfs/tn/PLRM.pdf) /s3011 (http://partners.adobe.com/asn/developer/pdfs/tn/PS3010and3011.Supplement.pdf) /s2011 (http://ftp.ktug.or.kr/obsolete/info/adobe/devtechnotes/pdffiles/ps2011.supplement.pdf) /s2012 (http://ftp.ktug.or.kr/obsolete/info/adobe/devtechnotes/pdffiles/ps2012.supplement.pdf) /s2013 (http://ftp.ktug.or.kr/obsolete/info/adobe/devtechnotes/pdffiles/ps2013.supplement.pdf) /s2014 (http://ftp.ktug.or.kr/obsolete/info/adobe/devtechnotes/pdffiles/ps2014.supplement.pdf) /s2015 (http://ftp.ktug.or.kr/obsolete/info/adobe/devtechnotes/pdffiles/ps2015.supplement.pdf) /s2016 (http://ftp.ktug.or.kr/obsolete/info/adobe/devtechnotes/pdffiles/ps2016.supplement.pdf) /ghost (http://www.cs.wisc.edu/~ghost/) /distlang (http://www.tinaja.com/psutils/distlang.html) /adobepst (http://partners.adobe.com/asn/developer/technotes/) /maildon (mailto:don@tinaja.com) /tinaja (http://www.tinaja.com) /adobe (http://www.adobe.com) /adobesdk (http://partners.adobe.com/asn/developer/acrosdk/main.html) /pstrans (http://www.tinaja.com/glib/pstrans.pdf) /borland (http://www.borland.com/products/downloads/download_cbuilder.html) /ebay (http://cgi6.ebay.com/ws/eBayISAPI.dll?ViewSellersOtherItems&userid=abeja&completed=0&sort=2&since=-1&include=0&page=1&rows=100) /searepl (http://www.tinaja.com/psutils/searepl.psl) /aasdk (http://www.tinaja.com/plugins/AboutAcrobatSDK.api) /uncomp (http://www.tinaja.com/plugins/UncompressPDF.api) /addimage (http://www.tinaja.com/plugins/AddImage.api) /samplejpg (http://www.tinaja.com/plugins/sample.jpg) /transparency (http://www.tinaja.com/plugins/Transparency.api) /threerects (http://www.tinaja.com/plugins/threerects.pdf) /watermark (http://www.tinaja.com/plugins/Watermark.api) /verifyurls (http://www.tinaja.com/plugins/VerifyURLS.api) /flate (http://www.tinaja.com/glib/flatvue.pdf) /pstrans (http://www.tinaja.com/glib/pstrans.pdf) /advt01 (http://www.tinaja.com/advt01.asp) /amlink01 (http://www.tinaja.com/amlink01.asp) /ng1 (news:///comp.text.pdf) /ng2 (news:///comp.lang.postscript) /msc++ (http://msdn.microsoft.com/visualc/productinfo/default.asp) /degub (http://www.tinaja.com/glib/degub.pdf) /ghostscript (http://www.artifex.com/pressreleases/GS70.htm) /demox.psl (http://www.tinaja.com/glib/g9demox.psl) /demox.pdf (http://www.tinaja.com/glib/g9demox.pdf) /demo.pdf (http://www.tinaja.com/glib/g9demo.pdf) /flatvue (http://www.tinaja.com/glib/flatvue.psl) /pdfrefman (http://partners.adobe.com/asn/developer/acrosdk/docs.html) /psrefman (http://partners.adobe.com/asn/developer/technotes/postscript.html) /pdfmrm (http://partners.adobe.com/asn/developer/acrosdk/docs.html) /tipdf (http://partners.adobe.com/asn/developer/acrosdk/docs.html) /asdk (http://partners.adobe.com/asn/developer/acrosdk) /mtcr (http://support.adobe.com/devsup/devsup.nsf/docs/51864.htm) /flatvue1 (http://www.tinaja.com/psutils/flatvue1.psl) /acrob01 (http://www.tinaja.com/acrob01.asp) /post01 (http://www.tinaja.com/post01.asp) /info01 (http://www.tinaja.com/info01.asp) /gurgrm01 (http://www.tinaja.com/gurgrm01.asp) { /tilley (http://www.tilleyfoundation.com) /mnglobal (http://www.mnglobal.com/energy/pg2.htm) /keely (http://www.keelynet.com) /evolve (http://www.evolvedtechnology.com) /hack64 (http://www.tinaja.com/glib/hack64.pdf) /hackar3 (http://www.tinaja.com/glib/hackar3.pdf) /resbn58 (http://www.tinaja.com/glib/resbn58.pdf) /bppt (http://www.batterypoweronline.com) /muse112 (http://www.tinaja.com/glib/muse112.pdf) /muse113 (http://www.tinaja.com/glib/muse113.pdf) /energfun (http://www.tinaja.com/glib/energfun.pdf) /bashpseu (http://www.tinaja.com/glib/bashpseu.pdf) /adobe (http://www.adobe.com) /netscape (http://www.netscape.com) /gallypsl (http://www.tinaja.com/galley1.psl) /gallypdf (http://www.tinaja.com/galley1.pdf) /atn5150 (http://partners.adobe.com/asn/developer/acrosdk/docs/createpdfapi/pdfmarkReference.pdf) /nutour (http://www.tinaja.com/bargains/nutour02.pdf) /nutoursource (http://www.tinaja.com/bargains/nutour02.psl) /bwhistle (http://www.tinaja.com/glib/bwhistle.pdf) /gonzo1 (http://www.tinaja.com/post01.asp#gonzo) /barg01 (http://www.tinaja.com/barg01.asp) /weblib01 (http://www.tinaja.com/weblib01.asp) /gurgrm01 (http://www.tinaja.com/gurgrm01.asp) /z1 (http://www.tinaja.com/bargains/thumb/albradz2.jpg) /z2 (http://www.tinaja.com/bargains/sbtesteq.asp) /z3 (http://www.tinaja.com/images/bargs/albrad02.jpg) /z4 (http://www.tinaja.com/bargains/thumb/tutenaz2.jpg) /z5 (http://www.tinaja.com/bargains/sbphone.asp) /z6 (http://www.tinaja.com/images/bargs/tutena02.jpg) /sourceme (http://www.tinaja.com/glib/gallery.psl) /sourceme2 (http://www.tinaja.com/glib/autourl.psl) } pop >> {mark exch /eurl cvx ] cvx def} forall %%%%%%%%%%%%%%%% New colorizer patches %%%%%%%%%%%%%%%%%% /boxgrays 0.899 def /grayshade boxgrays def /mastergray boxgrays def /staytint {0.33 setgray} def /staytint1 {0.25 setgray} def /showadgrays true def /red {0 settint} def /Zmacro {staytint /ypos ypos 2 add def 72 300 div setlinewidth xpos ypos moveto txtwide 0 rlineto stroke /ypos ypos -2 add def tintoff} def % hair rule /amacro {(zy0) stringmacro /ypos ypos ypara add def 0.33 setgray } def % start drop cap /bmacro {(iFy1) stringmacro /ypos ypos ypara add def black} def % finish drop cap % Gonzo character colorizer /blueon {mark /blue cvx 0.33 /setgray cvx] cvx printlist exch 3 index exch put exch 1 add exch} def /blueoff {mark /beige cvx 0 /setgray cvx] cvx printlist exch 3 index exch put exch 1 add exch} def /tinton {mark 0.33 /setgray cvx] cvx printlist exch 3 index exch put exch 1 add exch} def /tinton1 {mark 0.25 /setgray cvx] cvx printlist exch 3 index exch put exch 1 add exch} def /tinton1b {mark beige cvx % try for aqua after url??? 0.25 /setgray cvx] cvx printlist exch 3 index exch put exch 1 add exch} def /tinton1a {mark /aqua cvx % try for aqua after url??? 0.25 /setgray cvx] cvx printlist exch 3 index exch put exch 1 add exch} def /tinton1p {mark /burple cvx % try for aqua after url??? 0.25 /setgray cvx] cvx printlist exch 3 index exch put exch 1 add exch} def /tinton1r {mark /red cvx % try for aqua after url??? 0.25 /setgray cvx] cvx printlist exch 3 index exch put exch 1 add exch} def /tinton1a {mark /aqua cvx % try for aqua after url??? 0.25 /setgray cvx] cvx printlist exch 3 index exch put exch 1 add exch} def /tinton1b {mark /beige cvx % try for beige after url??? 0.25 /setgray cvx] cvx printlist exch 3 index exch put exch 1 add exch} def /tintoff {mark 0 /setgray cvx] cvx printlist exch 3 index exch put exch 1 add exch} def %%%%%%%%%%%%%% COMPACT VERSION OF COLORIZER II %%%%%%%%%%%%%%%%%%%%%% /settint {dup /currenttint exch store 5.999 mul dup floor cvi /&cbar exch store dup floor sub /&cwt exch store [ {/setgray [ /dup cvx 0.3 &cwt 0.59 mul add /ge cvx [1 /exch cvx &cwt 0.59 mul 0.30 add /sub cvx 1 &cwt sub 0.59 mul 0.11 add /div cvx /dup cvx 1 &cwt sub /mul cvx &cwt /add cvx /exch cvx ] cvx [ &cwt 0.59 mul 0.3 add /div cvx /dup cvx &cwt /mul cvx 0] cvx /ifelse cvx /setrgbcolor cvx] cvx /def cvx} {/setgray [/dup cvx 0.59 1 &cwt sub 0.3 mul add /ge cvx [1 &cwt sub 0.3 mul 0.59 add /sub cvx &cwt 0.3 mul 0.11 add /div cvx /dup cvx &cwt /mul cvx 1 &cwt sub /add cvx /exch cvx 1 /exch cvx] cvx [1 &cwt sub 0.3 mul 0.59 add /div cvx /dup cvx 1 &cwt sub /mul cvx /exch cvx 0] cvx /ifelse cvx /setrgbcolor cvx] cvx /def cvx} {/setgray [/dup cvx 0.59 &cwt 0.11 mul add /ge cvx [&cwt 0.11 mul 0.59 add /sub cvx 1 &cwt sub 0.11 mul 0.30 add /div cvx /dup cvx 1 &cwt sub /mul cvx &cwt /add cvx 1 /exch cvx] cvx [0 /exch cvx &cwt 0.11 mul 0.59 add /div cvx /dup cvx &cwt /mul cvx] cvx /ifelse cvx /setrgbcolor cvx] cvx /def cvx} {/setgray [/dup cvx 0.59 1 &cwt sub mul 0.11 add /ge cvx [1 &cwt sub 0.59 mul 0.11 add /sub cvx &cwt 0.59 mul 0.30 add /div cvx /dup cvx &cwt /mul cvx 1 &cwt sub /add cvx 1] cvx [0 /exch cvx 1 &cwt sub 0.59 mul 0.11 add /div cvx /dup cvx 1 &cwt sub /mul cvx /exch cvx] cvx /ifelse cvx /setrgbcolor cvx] cvx /def cvx} {/setgray [/dup cvx 0.11 &cwt 0.30 mul add /ge cvx[&cwt 0.30 mul 0.11 add /sub cvx 1 &cwt sub 0.30 mul 0.59 add /div cvx /dup cvx 1 &cwt sub /mul cvx &cwt /add cvx /exch cvx 1] cvx [ &cwt 0.30 mul 0.11 add /div cvx /dup cvx &cwt /mul cvx /exch cvx 0 /exch cvx ] cvx /ifelse cvx /setrgbcolor cvx ] cvx /def cvx} {/setgray [ /dup cvx 0.30 1 &cwt sub 0.11 mul add /ge cvx[ 1 /exch cvx 1 &cwt sub 0.11 mul 0.30 add /sub cvx &cwt 0.11 mul 0.59 add /div cvx /dup cvx &cwt /mul cvx 1 &cwt sub /add cvx ] cvx [ 1 &cwt sub 0.11 mul 0.30 add /div cvx /dup cvx 1 &cwt sub /mul cvx 0 /exch cvx] cvx /ifelse cvx /setrgbcolor cvx ] cvx /def cvx} ] &cbar get exec exec} bind def /beige {0.10 settint} def % examples of convenience operators /aqua {0.52 settint} def /blue {0.67 settint} def /lime {0.44 settint} def /burple {0.75 settint} def %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /guru { gonzo begin ps.util.1 begin printerror nuisance begin} def % guru % activate gonzo utilities 50 50 10 setgrid % create grid % 56 61 showgrid /setpagefonts { /cstretch 0.015 def /sstretch 0.015 def /font0 /StoneSans-Bold 1.6 gonzofont /font1 /StoneSans 0.95 gonzofont /font2 /StoneSans [0.95 0 0.25 0.95 0 0 ] gonzofont /font4 /StoneSans 0.85 gonzofont /font3 /StoneSans-Bold 0.85 gonzofont /font6 /StoneSans-Bold 0.85 gonzofont /font7 /StoneSans-Bold 1.05 gonzofont % subheaders /font8 /StoneSans-Bold [0.65 0 0 0.65 0 0.4] gonzofont /txtwide 36 store /yinc 1.2 store /kern 0.1 store /pm 1.5 store aqua 0.33 setgray font1 black /amacro { mark /aqua cvx 0.33 /setgray cvx ] cvx printlist exch 3 index exch % stuff into gonzo printlist put exch 1 add exch } def /bmacro { mark /black cvx ] cvx printlist exch 3 index exch % stuff into gonzo printlist put exch 1 add exch } def /shiftin {xpos /xposhold exch store /xpos xpos 3 add store} def /shiftout {/xpos xposhold store} def /texttop 51 store /textleft 3 store /cmacro {aqua 0.25 setgray (znhL7) stringmacro /xpos xpos 1.7 sub store /ypos ypos .1 sub def } def % left title /dmacro {black (pL1hz) stringmacro /xpos xpos 1.7 add store /ypos ypos .1 add def} def % normal text after centered title /fmacro % try and fake | {mark /gsave cvx /currentpoint cvx /moveto cvx 0.1 /setlinewidth cvx 0 0.65 /rlineto cvx /stroke cvx /grestore cvx ] cvx printlist exch 3 index exch put % stuff into gonzo printlist exch 1 add exch % increment gonzo list count } def } def setpagefonts % -2 50.5 (optional header here \274) cl %% Set document opening conventions. Note DOCVIEW limited. [/CropBox [0 0 520 620] % set the wierd size /PAGES pdfmark [ {Catalog} << /ViewerPreferences << /FitWindow true /CenterWindow true >> /PageLayout /OneColumn % continous /Pagemode /UseNone % no thumbs /View [/XYZ null null 1 ] % force 100% >> /PUT pdfmark %%%%%%%%%%%%%%%%% START DEMO ART (not in use) %%%%%%%%%%%%%%%% %%% Hand patching Info: % next available variable is /GS3 % transparency gstate is object 2 % contents stream is object 18 gets q /GS3 gs (xstuff) Q % be sure to q Q bracket to localize % resources stream is object 19 gets /GS3 2 0 R /transoverlay { % make a new graphics state [ /_objdef {newgsstate} /type /dict /OBJ pdfmark % fill the new overlay graphics state - See PDF manual for details [ {newgsstate} << /Type /ExtGState /ca 0.5 % fill transparency is 0.5 /CA 0.5 % stroke transparency is 0.5 /BM /Normal /AIS false /OP false /OPM 1 /op true >> /PUT pdfmark % start a Begin Picture graphics overlay subroutine... [ /BBox [0 0 1000 1000 ] /_objdef {overlaypix} /BP pdfmark % fill the Begin Picture graphics overlay Xobject subroutine... 0 0.5 1 setrgbcolor % on the aqua side of blue 4 4 6 6 rectfill % complete the Begin Picture graphics overlay Xobject... [ /EP pdfmark } def % Write a two squares program... /twosquares { gsave translate 1 0.5 0 setrgbcolor % red side of orange 2 2 6 6 rectfill % do background opaque box [ {overlaypix} /SP pdfmark % show foreground transparent box grestore} def % Distill the two squares program. Initially use a BARE Distiller Job % Options that has no compression, no embedded fonts, and little else save /snap1 exch store %%% transoverlay % create new objects %%% 14 17.5 twosquares snap1 restore %%%%%%%%%%%% END DEMO %%%%%%% %%%%%%%%%%%% PHOTO INSERTS %%%%%%%%%% % When photos are needed, they are inserted here. Comment out otherwise. /pixfilename1 (C:\\windows\\desktop\\aaraw_pix\\marcon01.jpg) def /pixfilename2 (C:\\windows\\desktop\\aaraw_pix\\marconz1.jpg) def /figure1 {2.5 0 712 568 pixfilename1 jpegimageproc} def % image link /figure2 {21.5 0 712 568 pixfilename2 jpegimageproc} def % image link /hotspot1 { 2.5 0 20.5 14.3 (http://www.tinaja.com/images/bargs/marcon01.jpg) setareaurl} def /hotspot2 { 21.5 0 39.5 14.3 (http://www.tinaja.com/images/bargs/marconz1.jpg) setareaurl} def /photoscale 0.025 store /jpegimageproc { % hoffset voffset hres vres save /snap2 exch def /infilename exch store % grab passed pix file /vpixels exch store /hpixels exch store translate % adjust position for final figure ??? electronics begin /DeviceRGB setcolorspace % pick color model 0 0 translate % set page position hpixels vpixels scale % magnify unit square photoscale dup scale /infile infilename (r) file def % establish input read file /Data {infile /DCTDecode filter} def % define a data source << % start image dicationary /ImageType 1 % always one /Width hpixels % JPEG width in pixels /Height vpixels % JPEG height in pixels /ImageMatrix [hpixels 0 0 vpixels neg 0 vpixels ] /DataSource Data % proc to get filtered JPEG /BitsPerComponent 8 % color resolution /Decode [0 1 0 1 0 1] % per red book 4.10 >> image % call the image operator end ypos snap2 restore /ypos exch def } def %%%%%%%%%%%%%%%%%%%%%% HOTSPOTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % manually positioned area url click.. /setareaurl { /cururlname exch store % save the url string /ury exch store /urx exch store /lly exch store /llx exch store mark % start pdfmark /Rect [ llx lly urx ury] /Border [ 0 0 0] % [0 0 0 ] = none; [0 0 2] = debug /Color [ .7 0 0 ] /Action <> /Subtype /Link /ANN % annotation type pdfmark % call pdf operators } def %%%%%%%%%%%%% /burpwide 29.5 store /burplebox3 {save /burp1 exch store xpos ypos translate -1 .2 mt 3.5 yinc mul .4 add pd burpwide pr 3.5 yinc mul .4 add pu closepath 0.9 setgray fill burp1 restore } def /burplebox2 {save /burp1 exch store xpos ypos translate -1 .2 mt 2.5 yinc mul .4 add pd burpwide pr 2.5 yinc mul .4 add pu closepath 0.9 setgray fill burp1 restore } def /burplebox2.5 {save /burp1 exch store xpos ypos translate -1 .2 mt 3 yinc mul .4 add pd burpwide pr 3 yinc mul .4 add pu closepath 0.9 setgray fill burp1 restore } def /burplebox4 {save /burp1 exch store xpos ypos translate -1 .2 mt 4.5 yinc mul .4 add pd burpwide pr 4.5 yinc mul .4 add pu closepath 0.9 setgray fill burp1 restore } def /burplebox5 {save /burp1 exch store xpos ypos translate -1 .2 mt 5.5 yinc mul .4 add pd burpwide pr 5.5 yinc mul .4 add pu closepath 0.9 setgray fill burp1 restore } def /burplebox6 {save /burp1 exch store xpos ypos translate -1 .2 mt 6.5 yinc mul .4 add pd burpwide pr 6.5 yinc mul .4 add pu closepath 0.9 setgray fill burp1 restore } def /burplebox6.5 {save /burp1 exch store xpos ypos translate -1 .2 mt 7 yinc mul .4 add pd burpwide pr 7 yinc mul .4 add pu closepath 0.9 setgray fill burp1 restore } def /burplebox7.5 {save /burp1 exch store xpos ypos translate -1 .2 mt 8 yinc mul .4 add pd burpwide pr 8 yinc mul .4 add pu closepath 0.9 setgray fill burp1 restore } def /burplebox8 {save /burp1 exch store xpos ypos translate -1 .2 mt 8.5 yinc mul .4 add pd burpwide pr 8.5 yinc mul .4 add pu closepath 0.9 setgray fill burp1 restore } def /burplebox8.5 {save /burp1 exch store xpos ypos translate -1 .2 mt 9 yinc mul .4 add pd burpwide pr 9 yinc mul .4 add pu closepath 0.9 setgray fill burp1 restore } def /burplebox9 {save /burp1 exch store xpos ypos translate -1 .2 mt 9.5 yinc mul .4 add pd burpwide pr 9.5 yinc mul .4 add pu closepath 0.9 setgray fill burp1 restore } def /burplebox20 {save /burp1 exch store xpos ypos translate -1 .2 mt 20.5 yinc mul .4 add pd burpwide pr 20.5 yinc mul .4 add pu closepath 0.9 setgray fill burp1 restore } def /burplebox36 {save /burp1 exch store xpos ypos translate -1 .2 mt 36.5 yinc mul .4 add pd burpwide pr 36.5 yinc mul .4 add pu closepath 0.9 setgray fill burp1 restore } def /pagenum 1 store /startnewpage { black beige 0.35 setgray 21 -2.5 (|3\320|j) pagenum 10 string cvs mergestr (|j\320) mergestr cc aqua showpage %% start next page /pagenum pagenum 1 add store 50 50 10 setgrid % create grid setpagefonts font1 textleft texttop } def /su {surl font6} store /to {tinton1 font6} store /tx {tintoff font1} store /tabs [11 15] store aqua 0.33 setgray font0 20 47.3 0.7 add % 1 sub (PostScript|j|j-|j|jas|j|j-|j|jLanguage) cc 20 45.3 0.7 add (Runtime Speedup Tricks) cc black font2 textleft 43 0.3 add % this one only need |h below (|/aqua |/staytint1 |3Don Lancaster Synergetics, Box 809, Thatcher, AZ 85552 copyright c2003 as |/surl |6GuruGram|1|/gurgrm01 |/tinton1 |6#16 |/surl http://www.tinaja.com|/tinaja |/surl don@tinaja.com|/maildon (928) 428-4073 |/aqua |/black |a|0T|b|1|khe first few cuts of our |/su Swings & Tilts|1|/swingt01 utility in |/su GuruGram #15|1|/gurgrm01 ran kinda slow, and it did take me several more passes to get it up to reasonable speed. What I thought I'd do here is review some of the methods you can use to optimize your |/su PostScript-as-Language|1|/post01 runtime speeds. |h We'll first note that too much speed optimization may lead to code that is longer, more obtuse, harder to maintain, and less tutorial. So a balance between speed and usability is often best. PostScript has gotten amazingly fast over the years. Consistent with what is possible within the limits of a batch-oriented interpreted higher level language. Here are some items to consider when optimizing your code for fastest runtime speed\274 |h |/to Write your own code \320 |/tx Most commercial packages that generate PostScript code write sequences that are ridiculously long and execute way too slowly. Your own "bare metal" hand coding can eliminate anything unnecessary and should run ten to a hundred times faster. My |/su Gonzo Utilities|1|/gonzoutils are one route towards fast and efficient high performance routines. |h |/to Get your code working first \320 |/tx The first cut of any program can |/to always|1|/tx have its speed improved, so don't worry too much about optimizing speed early in the game, Use a two-step process where you first get your code to do exactly what you ask of it. Then go back through and clean up any speed issues. |h |/to Use a fast machine and the latest version Distiller \320 |/tx PostScript-as-Language code will obviously execute faster on a new 4 GigaHertz computer than on an older 50 MegaHertz one. Especially if the latter does not include a decent math coprocessor. The latest |/su Acrobat Distiller|1|/adobe versions have gotten stunningly fast. |h |/to Use print to disk \320 |/tx The standard way of capturing and evaluating slow PostScript code is to do a print to disk and then inspect your results |/to as an ordinary ASCII |/to textfile|/tx . The code can then be analyzed for any excesses, redundancies, or speed limitations. But note that certain newer |/su Acrobat|1|/acrob01 features such as |/su transparency|1|/pstrans have no direct |/su PostScript|1|/post01 equivalent and thus lead to large and slow code. )cl % figure1 % hotspot1 startnewpage /tabs [9] store (|/to Don't Sweat mul or div \320 |/tx At one time, more complex math functions were quite slow, but these days with a modern math coprocessor, the PS |/to mul|/tx multiply or |/to div|/tx divide operations usually run just as fast as ordinary addition or subtraction. Even trig functions such as a |/to cos|/tx cosine calculation will only take four or so times longer. Allow a microsecond or two per trig function. |h |/to Bound and Determined \320 |/tx Your first and foremost speedup trick is to use the PostScript |/to bind|/tx operator. Simply place a |/to bind|/tx before each major |/to def|/tx . This tightly links variables to their values and eliminates a lookup step. Binding typically speeds you up by fifteen to twenty percent. But may not always be appropriate. |h |/to Measure program speed \320 |/tx The PostScript |/to usertime|/tx operator measures and records one millisecond ticks. Longer times may be evaluated by repeated use. Here are some handy procs from my |/su gonzo utilities|1|/gonzoutils \274 |6|/shiftin |/burple |/staytint1 |/burplebox8.5 /starttimer {usertime /mytimenow exch def} def /stoptimer {usertime mytimenow sub /mytime exch mytime add def} def /resettimer {/mytime 0 def} def /reporttimer {mytime 1000 div (\\\\rElapsed time: ) print 20 string cvs print ( seconds.\\\\r) print flush} def |h /stopwatchon {resettimer starttimer} def /stopwatchoff {stoptimer reporttimer} def |1|/shiftout |/aqua |/black Normally, you just put a |/to stopwatchon|/tx at the beginning of what you want to time and a self-reporting |/to stopwatchoff|/tx at the end. |h |/to Big lumps first \320 |/tx Your first speedup goal is to measure how much time you are spending in each activity. Normally, the innermost code loops will dominate since they tend to execute much more often. Obviously, your first efforts at speedup are best spent in those areas that are using up the most time. |h |/to Try null differencing \320 |/tx Sometimes it is tricky to measure a complex inner loop of major code. A sneaky way around this is to measure your total program time, then comment out the inner loop and measure again. The |/to difference|/tx between the two should be your inner loop time. Repeated differencing can then get your total time budget for typical program operation. |h |/to Measure proc speeds \320 |/tx Individual PostScript commands or small procs will execute much faster than a millisecond and thus give you a |/to usertime|/tx value of zero. Instead, measure the time of one million procs at once\274 |6|/shiftin |/burple |/staytint1 |/burplebox3 stopwatchon 1000000 { your_proc_here } repeat stopwatchoff |1|/shiftout |/aqua |/black ) cl startnewpage (|/to Select store instead of def \320 |/tx The PostScript |/to def|/tx command always assigns new vm resources, where |/to store|/tx writes over previously assigned values. Stores thus can be far more compact and efficient. |h |/to Stuff the stack \320 |/tx PostScript stack operations are self-addressing and the fastest available. Creative use of |/to dup|/tx , |/to copy|/tx , |/to index|/tx , |/to exch|/tx , and |/to roll|/tx are often the secret to tight code. The more you can do with the stack, and the deeper you can load it, the faster your results will often be. |h |/to But watch for excessive exch \320 |/tx The |/to exch|/tx command is certainly among the most versatile and fastest in PostScript. But too many of them in the innermost tight portions of your code strongly suggest that you need to rearrange things or earlier preload other items on your stack. Ferinstance, a |/to /cx exch def|/tx can sometimes get its |/to exch|/tx eliminated by a previous |/to /cx |/tx stack entry. |h |/to Reuse strings \320 |/tx Predefine a workstring or two and reuse them over and over again, rather than creating a new string for each and every use instance. But be sure to apply the new string content |/to immediately|/tx , or it might change rather unexpectedly later in your routine. Note that strings are |/to not|/tx protected by the usual saves and restores. |h |/to Use table lookups \320 |/tx A key rule is to |/to never calculate anything you already know |/to the answer to|/tx . Table lookups are one of the greatest and least appreciated routes towards fast code. With a table lookup, you simply go get the answer, rather than spending a lot of time calculating it. Here is an |/su Elegantly Simple|1|/elesimp example where a PostScript lookup table fakes the |/to case|/tx command of other languages\274 |6|/shiftin |/burple |/staytint1 |/burplebox2 |h {|j{proc0} {proc1} {proc2} {defaultexit}|j} exch get exec |h |1|/shiftout |/aqua |/black Entering with a number 0, 1, 2, or 3 does |/to proc0|/tx , |/to proc1|/tx , |/to proc2|/tx , or |/to defaultexit|/tx without having to test for each selected value. As a fancier example, very complex bicubic |/su basis functions|1|/basis01 are needed for pixel interpolation. Instead of calculating them over and over again, you simply look up the results\274 |6|/shiftin |/burple |/staytint1 |/burplebox3 /b1 [|j1.000 0.999 0.998 0.992 0.979 0.954 0.916 0.863 0.795 0.715 0.625 0.529 0.432 0.338 0.252 0.176 0.113 0.064 0.028 0.007 0.000 ] store |1|/shiftout |/aqua |/black You can inspect |/su SWINGT01.PSL|1|/swingt01 as a detailed use example. This code is discussed in depth at |/su GuruGram #15|1|/gurgrm01 . |h Table lookups can either be downloaded or calculated early in the program. On-the-fly table building makes sense so long as the build time is much less than the use time saved. While table sizes of a few hundred bytes are the norm, very large lookup tables can sometimes be used to advantage. Tables are often best as one-dimensional arrays. ) cl startnewpage (|/to Minimize disk reads and writes \320 |/tx The PostScript disk access operators quite useful but rather slow. If you are going to need thousands or millions of disk reads or writes, consider using the |/to writestring|/tx and |/to readstring|/tx operators to create long |/to buffer strings|1|/tx . Use of |/to put|/tx and |/to get|/tx on those buffers can be much faster. Especially when processing, say, an entire scan line of pixels. |h |/to Watch those "==" and flush instructions \320 |/tx It is certainly a good idea to report lots of results often to your log files. But the |/to flush|1|/tx operator can be exceptionally slow, and it is needed by |/to ==|/tx or anytime you want an immediate text output. Here's an outer loop "still busy" status reporter that adds little overhead time\274 |6|/shiftin |/burple |/staytint1 |/burplebox2 |h dup 24 mod 0 eq {(.) print flush|j} if % for count on stack |h |1|/shiftout |/aqua |/black |h |/to Use Conditionals with care \320 The PostScript |/to if|/tx and |/to ifelse|/tx statements execute rather slowly, so you often will want to |/to avoid any and all unnecessary testing|/tx . Sometimes |/to and|/tx or |/to or|/tx Booleans can be successfully used to reduce multiple tests to a single one. Other times, rethinking of an algorithm can let one test do the work of two. Or place one inside the other. |h |/to Calculate changes only \320 |/tx If you are making very complex calculations and only a small part of the calculation changes each time, consider |/to saving old results and |/to recalculating only the changes|/tx . This dramatically sped up my |/su Magic Sinewave|1|/magsn01 research. Sometimes |/to derivatives or differentials|/tx can also be used to quickly find a neighboring value. This is an advanced concept I'd be glad to help you with per our |/su Consulting Services|1|/info01 . |h |/to Be aware of Garbage Collection \320 |/tx Earlier |/su PostScipt|1|/post01 code had a disconcerting habit of stopping every now and then to do |/to vm|/tx cleanup housekeeping. Which could add mysterious and erratic long delays to your processing time. One obvious precaution is to |/to shut down other host programs when running Distiller|/tx . A second defense is to avoid excess buildup of abandoned strings, defs, variables, saves/restores, and whatever in your code development. And a third is to be aware of the |/to vmreclaim|/tx command and its use. As detailed in the |/su PostScript Level|/refman2 |/su II Reference Manual|1|/refman2 and the |/su PostScript Level III Reference Manual|1|/refman3 . |h |/to Some random tips \320 |/tx Minimize the total number of variables. Do as much as you can directly on the stack. Don't sweat exact name lengths or definition sequences as these do not seem to consistently save you a lot of speed. It's usually better to keep names informative rather than ultra short. Use "linear" coding instead of nesting "subroutine" proc after proc after proc. But it is probably a good idea to keep your main code loop clean, calling |/to only|/tx a few key detail procs as needed. Consider |/to glyph|/tx , |/to font|/tx , or |/to Xobject|/tx tricks where you need to reuse a complex but small image. Debugging is often enormously helped by purposely introducing a |/to zorch|/tx "stop here" error. |/to Test and measure continuously|/tx . For "obvious" speedup tricks may in fact end up |/to slower|/tx than you'd first expect. ) cl startnewpage (|/to Think outside the box \320 |/tx If things are still too slow, perhaps a radical new algorithm would be better. Maybe parallel processing on several machines at once (this works like a champ on my |/su Magic Sinewaves|1|/magsn01 .) Or, in the case of those |/to Uh-compared to what?|/tx situations, running overnight, or on a secondary machine, or during lunch can be effective. |h In several instances, I've successfully used easy, powerful, and convenient interpreted PostScript-as-Language for all of my early development work and later switched to another language for the final out-the-door product. I've even |/su used |/magsn01 |/su PostScript|/magsn01 |/su to automatically write JavaScript programs!|1|/magsn01 Or even to create a |/su Custom Robotic Languages|1|/flut01 . |c For Further Help |d Additional background along with related utilities and tutorials appears on our |/su GuruGram|1|/gurgrm01 , |/su PostScript|1|/post01 , |/su Acrobat|1|/acrob01 , and |/su Fonts & Bitmaps|1|/aafont01 library pages. |h Consulting assistance on any and all of these and related topics can be found at |/surl |6http://www.tinaja.com/info01.asp|1|/info01 . As can our speed analysis services. |h Additional |/surl |6GuruGrams|1|/gurgrm01 await your ongoing support as a |/surl |6Synergetics Partner|1|/advt01 . ) cl startnewpage %%%%%%%%%%%%%%%%%%%% % EOF % big lookup is triple get to avoid multiply. % not really effective.