%! % brillig: by robin%brillig@sun.com (Robin Schaufler) % Cannonical PostScript shadowing added by Don Hopkins % Display with psview: "psview brillig.ps" systemdict /pause known not { /pause {} def } if /min { % x y => min(x,y) 2 copy gt { exch } if pop } def /points2rect { % x y x' y' => x y w h 3 index 2 index min % x y x' y' X 3 index 2 index min % x y x' y' X Y 5 index 4 index sub abs % x y x' y' X Y W 5 index 4 index sub abs % x y x' y' X Y W H 8 -4 roll pop pop pop pop % X Y W H } def /bril { 0 -10 moveto 80 70 50 70 15 arcto pop pop pop pop 10 70 10 20 15 arcto pop pop pop pop 10 0 lineto stroke 35 0 25 -180 90 arc 10 10 rmoveto 25 30 cos mul 35 add 25 30 sin mul lineto currentpoint pop stroke % y was 12.5 25 30 cos mul 2 copy add 0 25 30 150 arc stroke % stack now contains x of old current point and 25cos30 dup add add matrix currentmatrix exch 0 translate 0 -70 moveto -20 20 10 -20 -10 0 rcurveto stroke 3.125 -12.5 moveto 25 -50 0 75 25 25 rcurveto currentpoint stroke pop 0 translate 0 70 moveto 20 -20 -10 20 10 0 rcurveto stroke 2 2 scale 3.125 -12.5 moveto 25 -50 0 75 25 25 rcurveto setmatrix currentpoint stroke } def /lig { bril pop dup add 0 translate 180 rotate bril pop pop } def /brillig_dimensions { 0 -70 368.6541 140 } def /scale_to_fit { % _ => _; scale to fit brillig in bbox of current path pathbbox points2rect 4 2 roll translate 2 copy div % w h w/h /brillig_dimensions load aload pop % w h w/h bx by bw bh div 3 1 roll pop pop % w h w/h bw/bh le { % this is wrong, but I don't understand why 0 exch 2 div translate % w h w/h /brillig_dimensions load 2 get div % w h w/h/bw dup scale % w h w/h/bw } { 1 index 2 div 1 index 2 div translate % w h bw/bh /brillig_dimensions load 3 get div % w h bw/bh/bh dup scale pop % w h /brillig_dimensions load 2 get 2 div neg 0 translate % w h } ifelse } def gsave systemdict /setlinequality known {1 setlinequality} if clippath pathbbox points2rect /h exch def /w exch def exch neg exch neg h add translate -90 rotate newpath h .1 mul w .1 mul moveto h .8 mul w .1 mul lineto h .8 mul w .9 mul lineto h .1 mul w .9 mul lineto closepath scale_to_fit newpath 1 setlinecap % rounded 10 setlinewidth 0 .05 1 { 5 {pause} repeat dup setgray 1.5 -1 translate gsave lig grestore } for 4 setlinewidth 0 setgray gsave lig grestore 1 setlinewidth 1 setgray gsave lig grestore grestore showpage