ó
È4ec           @   sX   d  d l  Z  d d l m Z d d l m Z d e f d „  ƒ  YZ d Z d Z d	 Z	 d S(
   iÿÿÿÿNi   (   t   EpsImagePlugin(   t   py3t   PSDrawc           B   sh   e  Z d  Z d
 d „ Z d „  Z d
 d „ Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d
 d	 „ Z RS(   si   
    Sets up printing to the given file. If **fp** is omitted,
    :py:attr:`sys.stdout` is assumed.
    c         C   s   | s t  j } n  | |  _ d  S(   N(   t   syst   stdoutt   fp(   t   selfR   (    (    s4   /usr/local/lib/python2.7/dist-packages/PIL/PSDraw.pyt   __init__!   s    c         C   sI   t  s |  j t j k r, |  j j | ƒ n |  j j t | d ƒ ƒ d  S(   Ns   UTF-8(   R   R   R   R   t   writet   bytes(   R   t   to_write(    (    s4   /usr/local/lib/python2.7/dist-packages/PIL/PSDraw.pyt	   _fp_write&   s    c         C   sA   |  j  d ƒ |  j  t ƒ |  j  t ƒ |  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	   EDROFF_PSt   VDI_PSt   isofont(   R   t   id(    (    s4   /usr/local/lib/python2.7/dist-packages/PIL/PSDraw.pyt   begin_document,   s    c         C   s3   |  j  d ƒ t |  j d ƒ r/ |  j j ƒ  n  d S(   s-   Ends printing. (Write Postscript DSC footer.)s%   %%EndDocument
restore showpage
%%End
t   flushN(   R   t   hasattrR   R   (   R   (    (    s4   /usr/local/lib/python2.7/dist-packages/PIL/PSDraw.pyt   end_document<   s    c         C   sQ   | |  j  k r6 |  j d | | f ƒ d |  j  | <n  |  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   t   fontt   size(    (    s4   /usr/local/lib/python2.7/dist-packages/PIL/PSDraw.pyt   setfontB   s    c         C   s   | | } |  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   t   xy0t   xy1t   xy(    (    s4   /usr/local/lib/python2.7/dist-packages/PIL/PSDraw.pyt   lineP   s    
c         C   s   |  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   t   box(    (    s4   /usr/local/lib/python2.7/dist-packages/PIL/PSDraw.pyt	   rectangleY   s    c         C   sR   d j  | j d ƒ ƒ } d j  | j d ƒ ƒ } | | f } |  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   t   text(    (    s4   /usr/local/lib/python2.7/dist-packages/PIL/PSDraw.pyR!   h   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 d	 | |	 f ƒ | | f | j k rg| | j d }
 | | j d } |  j d
 |
 | f ƒ n  t j | |  j d d ƒ |  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    t   _saveR   t   None(   R   R   t   imt   dpit   xt   yt   xmaxt   ymaxt   dxt   dyt   sxt   sy(    (    s4   /usr/local/lib/python2.7/dist-packages/PIL/PSDraw.pyt   imager   s.    				N(   t   __name__t
   __module__t   __doc__R&   R   R   R   R   R   R   R   R!   R1   (    (    (    s4   /usr/local/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
(
   R   t    R    t   _utilR   t   objectR   R   R   t   ERROR_PS(    (    (    s4   /usr/local/lib/python2.7/dist-packages/PIL/PSDraw.pyt   <module>   s   –"