%!PS-Adobe-2.0
%%Title: Blue Book Program 15, on page 191
%%Creator: Adobe Systems Incorporated 
%%CreationDate: Fri Dec 29 12:29:23 PST 1989
%%EndComments

/setuserscreendict 22 dict def
setuserscreendict begin
  /tempctm matrix def
  /temprot matrix def
  /tempscale matrix def
  
  /concatprocs
    { /proc2 exch cvlit def
      /proc1 exch cvlit def
      /newproc proc1 length proc2 length add
        array def
      newproc 0 proc1 putinterval
      newproc proc1 length proc2 putinterval
      newproc cvx
    } def
  
  /resmatrix matrix def
  /findresolution
    { 72 0 resmatrix defaultmatrix dtransform
      /yres exch def /xres exch def
      xres dup mul yres dup mul add sqrt
    } def
  end

/setuserscreen
  { setuserscreendict begin
      /spotfunction exch def
      /screenangle exch def
      /cellsize exch def
      
      /m tempctm currentmatrix def
      /rm screenangle temprot rotate def
      /sm cellsize dup tempscale scale def
      
      sm rm m m concatmatrix m concatmatrix pop
      
      1 0 m dtransform /y1 exch def /x1 exch def
      
      /veclength x1 dup mul y1 dup mul add sqrt def
      /frequency findresolution veclength div def
      
      /newscreenangle y1 x1 atan def
      
      m 2 get m 1 get mul m 0 get m 3 get mul sub
        0 gt
        { {neg} /spotfunction load concatprocs
            /spotfunction exch def
        } if
        
      frequency newscreenangle /spotfunction load
        setscreen
    end
  } def
  
/setpatterndict 18 dict def
setpatterndict begin
  /bitison
    { /ybit exch def /xbit exch def
      /bytevalue bstring ybit bwidth mul xbit 8 idiv
        add get def
      
      /mask 1 7 xbit 8 mod sub bitshift def
      bytevalue mask and 0 ne
    } def
  end
  
/bitpatternspotfunction
  { setpatterndict begin
    /y exch def /x exch def
    
    /xindex x 1 add 2 div bpside mul cvi def
    /yindex y 1 add 2 div bpside mul cvi def
    
    xindex yindex bitison
      { /onbits onbits 1 add def 1 }
      { /offbits offbits 1 add def 0 }
      ifelse
    end
  } def

/setpattern
  { setpatterndict begin
    /cellsz exch def
    /angle exch def
    /bwidth exch def
    /bpside exch def
    /bstring exch def
    
    /onbits 0 def /offbits 0 def
    cellsz angle /bitpatternspotfunction load
      setuserscreen
    { } settransfer
    offbits offbits onbits add div setgray
  end
} def

/enlargebits
  { /bwidth exch def
    /bpside exch def
    /bstring exch def
    
    0.08 setlinewidth
    0 1 bpside 1 sub
      { /y exch def
        0 1 bpside 1 sub
          { /x exch def
            x y setpatterndict /bitison get cvx exec
              { gsave
                x y translate
                newpath
                  0 0 moveto 0 1 lineto
                  1 1 lineto 1 0 lineto
                closepath
                gsave 0 setgray fill grestore
                1 setgray stroke
              grestore
            } if
          } for
        } for
      newpath
        0 0 moveto 0 bpside lineto
        bpside dup lineto bpside 0 lineto
      closepath 0 setgray stroke
    } def
    
/inch { 72 mul } def

/showpattern
  { /ang exch def
    /pat exch def
    gsave
      0 3.5 inch translate
      3 8 div inch dup scale
      pat 8 1 enlargebits
    grestore
    pat 8 1 ang 72 300 32 div div setpattern
    
    newpath
      0 0 moveto 3 inch 0 lineto
      3 inch dup lineto 0 3 inch lineto
    closepath fill
  } def

/pat1 <d1e3c5885c3e1d88> def
/pat2 <3e418080e3140808> def

/Helvetica findfont 12 scalefont setfont

gsave
  1 inch 1.25 inch translate
  pat1 0 showpattern
grestore
1 inch 1 inch moveto
(Basketweave, no rotation in user space) show

gsave
  4.5 inch 1.25 inch translate
  pat2 90 showpattern
grestore
4.5 inch 1 inch moveto
(Fish scale, 90 degree rotation) show
( in user space) show
showpage
                  
        
       
% But what does it do?