From steve Mon Oct 10 12:05:16 1994 Received: by ip2 (5.57/1.34) id AA07882; Mon, 10 Oct 94 12:05:16 +1000 Date: Mon, 10 Oct 94 12:05:16 +1000 From: steve (stephen welsh) Message-Id: <9410100205.AA07882@ip2> To: lloyd Status: RO %!PS-Adobe-1.0 %================================================================= % This is a postscript file that prints the words: % % Nervous? % Tense? % Tired? % % in a way, that if you look at them for a few seconds, you will % become nervous, tense and tired! % % The idea is that each letter sonsists of a black interior, % surrounded by a light grey shadow. If you look it from a certain % distance, your brain thinks that your eyes are out of focus. % % The effect is achieved by taking each character and moving it % upwards by an amount specified by the global variable 'Text_dy' % The union of the areas covered by the original and the moved % character is painted gray (global variable 'LightGray' % specifies how light or dark this shadow is). % Then we take the intersection of these two areas and paint it % black. % % Fell free to play with the program, and even if you know nothing % about Postscript, you can still experiment by changing the values % of the global variables defined below (especially 'Text_dy' and % 'LightGray' - these two specify how "fuzzy" the letters will look % like). With a little effort, you can even change the strings % printed. % % % Spyros Potamianos % potamian@hpl.hp.com %================================================================= %--------------------------------------------------------------- % GLOBAL VARIABLES *** EXPERIMENT WITH OTHER VALUES IF YOU LIKE %--------------------------------------------------------------- % FontSize: how big the letters will be % Text_vs: "vertical spacing" between the lines % Text_dy: how "fuzzy" the letters will look like, i.e % how big the "shadow" around the letters will % be (see procedure 'textPrint') % LightGray: shade of grey for the "fuzzy shadow" for the % letters (0.0 -> black, 1.0 -> white) %-------------------------------------------------------------- /FontSize 140 def /Text_dy 7 def /Text_vs 150 def /LightGray 0.8 def %--------------------------------------------------------------- % textCentered % % Stack: textCentered - % Global Vars used: FontSize % SideEffect: move the currentpoint % % Center a string around the current point. % % NOTE1: we center around both the X and Y axis % NOTE2: no other action is taken (i.e. you have to explicitly % call 'show' or 'charpath' etc.) %--------------------------------------------------------------- /textCentered { % save graphics state gsave % start a new path, but remember curr.point currentpoint newpath moveto % % find the bounding box of the string % true charpath pathbbox % Stack: llx lly urx ury exch % Stack: llx lly ury urx 4 1 roll % Stack: urx llx lly ury sub % Stack: urx llx -height 3 1 roll % Stack: -height urx llx sub neg % Stack: -height -width 2 div exch 2 div % Stack: -width/2 -height/2 % restore graphics state % NOTE: *first* restore the state, and *then* move the % current point.... % grestore rmoveto } def %--------------------------------------------------------------- % textPrint % % Stack: textPrint - % % print the given string in a "fuzzy" way... % Global Vars used: Text_dy, LightGray % % How it works: it takes the string, moves it upwards by 'Text_dy' % takes the union of the areas covered by the original and the % slightly moved string and fills them with a light shade of grey. % Then it takes their intersection and fills them with black shade % The result (when watching it from a certain distance) is eh.... % bad for your eyes! % % Implementation Note: I process the string one character at a time, % because some printers find the 'charpath' of a whole string % too complicated to 'fill', and complain about a 'limitcheck' error... % % Local variables: % str: the string % chr: one character from the string (we iterrate over all % string characters) % indx: index of 'chr' in 'string' % x0,y0: coordinates of the current point %--------------------------------------------------------------- /textPrint { % % remember the string and the current point coordinates % /str exch def currentpoint /y0 exch def /x0 exch def % % itterate over all characters % 'indx' is the char number (from 0 to length-1) % 'chr' is the corresponding character % 0 1 str length 1 sub { /indx exch def /chr str indx 1 getinterval def % % using 'charpath' find the outline of the area covered % by the character. Then move it upwards by 'Text_dy' % and find the new outline. Take their union and % fill it with a light gray color % gsave x0 y0 moveto chr true charpath x0 y0 Text_dy add moveto chr true charpath clip LightGray setgray fill grestore % % same as above, but take the intersection of the area % gsave x0 y0 moveto chr true charpath clip newpath x0 y0 Text_dy add moveto chr true charpath clip 0.0 setgray fill grestore % % we have printed one character, move to the right % /x0 chr stringwidth pop x0 add def } for } def %=============================================================== % MAIN PROGRAM BEGINS HERE %=============================================================== % % select a font % /Helvetica-Bold findfont FontSize scalefont setfont %--------------------------------------------------------------- % find the size of the page %--------------------------------------------------------------- newpath clippath pathbbox /ury exch def % upper right Y coord /urx exch def % upper right X coord /lly exch def % lower left Y coord /llx exch def % lower left X coord %--------------------------------------------------------------- % move to the center of the page %--------------------------------------------------------------- llx urx add 2 div lly ury add 2 div translate %--------------------------------------------------------------- % if width