ó
î Xc           @  sI   d  d l  m Z d  d l m Z d d	 d „  ƒ  YZ d Z d Z d Z d S(
   iÿÿÿÿ(   t   print_function(   t   EpsImagePlugint   PSDrawc           B  sh   e  Z d  Z d
 d „ Z d
 d „ Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d
 d	 „ Z RS(   sk   
    Sets up printing to the given file. If **file** is omitted,
    :py:attr:`sys.stdout` is assumed.
    c         C  s+   | s d d  l  } | j } n  | |  _ d  S(   Niÿÿÿÿ(   t   syst   stdoutt   fp(   t   selfR   R   (    (    s.   /usr/lib/python2.7/dist-packages/PIL/PSDraw.pyt   __init__    s    c         C  sM   |  j  j d ƒ |  j  j t ƒ |  j  j t ƒ |  j  j d ƒ i  |  _ d S(   s=   Set up printing of a document. (Write Postscript DSC header.)sD   %!PS-Adobe-3.0
save
/showpage { } def
%%EndComments
%%BeginDocument
s   %%EndProlog
N(   R   t   writet	   EDROFF_PSt   VDI_PSt   isofont(   R   t   id(    (    s.   /usr/lib/python2.7/dist-packages/PIL/PSDraw.pyt   begin_document&   s
    c         C  s6   |  j  j d ƒ t |  j  d ƒ r2 |  j  j ƒ  n  d S(   s-   Ends printing. (Write Postscript DSC footer.)s%   %%EndDocument
restore showpage
%%End
t   flushN(   R   R   t   hasattrR   (   R   (    (    s.   /usr/lib/python2.7/dist-packages/PIL/PSDraw.pyt   end_document4   s    c         C  sW   | |  j  k r9 |  j j d | | f ƒ d |  j  | <n  |  j j d | | f ƒ d S(   s~   
        Selects which font to use.

        :param font: A Postscript font name
        :param size: Size in points.
        s#   /PSDraw-%s ISOLatin1Encoding /%s E
i   s   /F0 %d /PSDraw-%s F
N(   R   R   R   (   R   t   fontt   size(    (    s.   /usr/lib/python2.7/dist-packages/PIL/PSDraw.pyt   setfont<   s
    c         C  s   t  d ƒ d S(   s`   
        .. warning:: This has been in the PIL API for ages but was never implemented.

        s   *** NOT YET IMPLEMENTED ***N(   t   print(   R   t   ink(    (    s.   /usr/lib/python2.7/dist-packages/PIL/PSDraw.pyt   setinkK   s    c         C  s"   | | } |  j  j d | ƒ d S(   s¿   
        Draws a line between the two points. Coordinates are given in
        Postscript point coordinates (72 points per inch, (0, 0) is the lower
        left corner of the page).
        s   %d %d %d %d Vl
N(   R   R   (   R   t   xy0t   xy1t   xy(    (    s.   /usr/lib/python2.7/dist-packages/PIL/PSDraw.pyt   lineR   s    
c         C  s   |  j  j d | ƒ d S(   s8  
        Draws a rectangle.

        :param box: A 4-tuple of integers whose order and function is currently
                    undocumented.

                    Hint: the tuple is passed into this format string:

                    .. code-block:: python

                        %d %d M %d %d 0 Vr

        s   %d %d M %d %d 0 Vr
N(   R   R   (   R   t   box(    (    s.   /usr/lib/python2.7/dist-packages/PIL/PSDraw.pyt	   rectangle[   s    c         C  sU   d j  | j d ƒ ƒ } d j  | j d ƒ ƒ } | | f } |  j j d | ƒ d S(   sŠ   
        Draws text at the given position. You must use
        :py:meth:`~PIL.PSDraw.PSDraw.setfont` before calling this method.
        s   \(t   (s   \)t   )s   %d %d M (%s) S
N(   t   joint   splitR   R   (   R   R   t   text(    (    s.   /usr/lib/python2.7/dist-packages/PIL/PSDraw.pyR!   j   s    c         C  sš  | s' | j  d k r d } q' d } n  t | j d d ƒ | } t | j d d ƒ | } t | d | d ƒ } t | d | d ƒ } | | k r° | | | } | } n  | | k rÓ | | | } | } n  | | d | d } | | d | d }	 |  j j d	 | |	 f ƒ | | f | j k rm| | j d }
 | | j d } |  j j d
 |
 | f ƒ n  t j | |  j d d ƒ |  j j d ƒ d S(   s,   Draw a PIL image, centered in the given box.t   1iÈ   id   i    iH   i   i   i   s   gsave
%f %f translate
s   %f %f scale
s
   
grestore
N(   t   modet   floatR   R   R   R   t   _savet   None(   R   R   t   imt   dpit   xt   yt   xmaxt   ymaxt   dxt   dyt   sxt   sy(    (    s.   /usr/lib/python2.7/dist-packages/PIL/PSDraw.pyt   imaget   s.    				N(   t   __name__t
   __module__t   __doc__R&   R   R   R   R   R   R   R   R!   R1   (    (    (    s.   /usr/lib/python2.7/dist-packages/PIL/PSDraw.pyR      s   							
s×  /S { show } bind def
/P { moveto show } bind def
/M { moveto } bind def
/X { 0 rmoveto } bind def
/Y { 0 exch rmoveto } bind def
/E {    findfont
        dup maxlength dict begin
        {
                1 index /FID ne { def } { pop pop } ifelse
        } forall
        /Encoding exch def
        dup /FontName exch def
        currentdict end definefont pop
} bind def
/F {    findfont exch scalefont dup setfont
        [ exch /setfont cvx ] cvx bind def
} bind def
sñ  /Vm { moveto } bind def
/Va { newpath arcn stroke } bind def
/Vl { moveto lineto stroke } bind def
/Vc { newpath 0 360 arc closepath } bind def
/Vr {   exch dup 0 rlineto
        exch dup neg 0 exch rlineto
        exch neg 0 rlineto
        0 exch rlineto
        100 div setgray fill 0 setgray } bind def
/Tm matrix def
/Ve {   Tm currentmatrix pop
        translate scale newpath 0 0 .5 0 360 arc closepath
        Tm setmatrix
} bind def
/Vf { currentgray exch setgray fill setgray } bind def
sã  /landscape false def
/errorBUF 200 string def
/errorNL { currentpoint 10 sub exch pop 72 exch moveto } def
errordict begin /handleerror {
    initmatrix /Courier findfont 10 scalefont setfont
    newpath 72 720 moveto $error begin /newerror false def
    (PostScript Error) show errorNL errorNL
    (Error: ) show
        /errorname load errorBUF cvs show errorNL errorNL
    (Command: ) show
        /command load dup type /stringtype ne { errorBUF cvs } if show
        errorNL errorNL
    (VMstatus: ) show
        vmstatus errorBUF cvs show ( bytes available, ) show
        errorBUF cvs show ( bytes used at level ) show
        errorBUF cvs show errorNL errorNL
    (Operand stargck: ) show errorNL /ostargck load {
        dup type /stringtype ne { errorBUF cvs } if 72 0 rmoveto show errorNL
    } forall errorNL
    (Execution stargck: ) show errorNL /estargck load {
        dup type /stringtype ne { errorBUF cvs } if 72 0 rmoveto show errorNL
    } forall
    end showpage
} def end
N(    (   t
   __future__R    t   PILR   R   R	   R
   t   ERROR_PS(    (    (    s.   /usr/lib/python2.7/dist-packages/PIL/PSDraw.pyt   <module>   s
   —"