
~YKc        
   @   s  d  d k  Z  d  d k Z d  d k Z d  d k Z d  d k Z d  d k Z d e f d     YZ d e f d     YZ h  Z	 h  Z
 e   Z e   Z d   Z d e  i i i f d     YZ d	 e f d
     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ h  Z d   Z e d d  Z d  e f d!     YZ  d" e f d#     YZ! d$ e f d%     YZ" d& e f d'     YZ# d( e$ f d)     YZ% d* d+ d, f d-  Z& d. d/ d0 f d* d+ d, f d1  Z' d2   Z( d3   Z) d4 e f d5     YZ* d6 e f d7     YZ+ e, d8  Z- d9   Z. d S(:   iNt
   CacheEntryc           B   s   e  Z d    Z RS(   c         C   s>   | |  _  | |  _ | i   \ } } | | |  _ d |  _ d  S(   Ni    (   t   whatt   surft   get_sizet   sizet   time(   t   selfR   R   t   wt   h(    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyt   __init__&   s
    		(   t   __name__t
   __module__R	   (    (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR    $   s   t   Cachec           B   st   e  Z d    Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z d
   Z d   Z RS(   c         C   s   d |  _  h  |  _ g  |  _ t |  _ d |  _ d |  _ t i   |  _	 t |  _
 h  |  _ t i d |  i d d  |  _ |  i i t  |  i i   d  S(   Ni    t   targett   namet	   preloader(   R   t   cachet   preloadst   Truet   first_preload_in_tickt   size_of_current_generationt   total_cache_sizet	   threadingt	   Conditiont   lockt   keep_preloadingt	   pin_cachet   Threadt   preload_thread_maint   preload_threadt	   setDaemont   start(   R   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR	   9   s    								c         C   sY   |  i  i   p d  Sn |  i i   t |  _ |  i i   |  i i   |  i  i   d  S(   N(	   R   t   isAliveR   t   acquiret   FalseR   t   notifyt   releaset   join(   R   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyt   quit]   s    	c         C   s   t  i i t  i i t  i i S(   N(   t   renpyt   configt   image_cache_sizet   screen_widtht   screen_height(   R   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyt   cache_limitk   s    c         C   sT   |  i  i   h  |  _ h  |  _ g  |  _ t |  _ d |  _ d |  _ |  i  i	   d  S(   Ni    (
   R   R!   R   R   R   R   R   R   R   R$   (   R   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyt   clearo   s    						c         C   s^   |  i  i   |  i d 7_ g  |  _ t |  _ d |  _ t i i	 o	 d GHn |  i  i
   d  S(   Ni   i    s   IC ----(   R   R!   R   R   R   R   R   R'   R(   t   debug_image_cacheR$   (   R   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyt   tick}   s    				c         C   s   g  |  _  d  S(   N(   R   (   R   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyt   end_tick   s    c         C   s`   t  i i o d G| GHn t | t  p" t  i i o d G| GHqL d  Sn |  i i |  d  S(   Ns   IC Request Preloads   IC Can't preload non image: (   R'   R(   R.   t
   isinstancet	   ImageBaseR   t   append(   R   t   image(    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyt   preload_image   s    c         C   s  t  | t  p t d t |  d   n | i p' | i   } t i i i	 |  | Sn d  } | |  i j o |  i | } n | d  j oD |  i i   |  i i | d   } | d  j	 o |  i i   q n | d  j oy1 | |  i j o |  i | } n | i   } Wn |  i i     n Xt | |  } |  i | i 7_ | |  i | <t i i i	 | i  t i i o' d | i d |  i |  i   f GHn t | i  t j o | i o t i i } | o t | i  } | t j o t | } n, t i i i | i  } | i d t  i!  t i i i	 |  | t | <t i i o d G| GHqkqon |  i i   n | i" |  i" j o" |  i" | _" |  i# | i 7_# n | i S(   Ns'   Expected an image of some sort, but gott   .s   IC Added %r (%.02f%%)g      Y@i   s   Added to rle cache:($   R1   R2   t	   Exceptiont   strR   t   loadR'   t   displayt   rendert   mutated_surfacet   NoneR   R!   t   getR$   R   R    R   R   R   R(   R.   R   R,   t   idt	   rle_cachet   gamet   less_memoryt   pin_rle_cachet   pgrendert   copy_surfacet	   set_alphat   pygamet   RLEACCELR   R   (   R   R4   R   t   cet   rlet   idsurft   rle_surf(    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR>      sZ    
' 
	c         C   s   | i  |  i  j o |  i | i 8_ n |  i | i 8_ |  i | i =t | i  t j o t t | i  =n t	 i
 i o d G| i GHn d  S(   Ns
   IC Removed(   R   R   R   R   R   R   R?   R   R@   R'   R(   R.   (   R   RI   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyt   kill   s    c         C   s   |  i    } |  i | j o d  Sn g  } |  i i   D] } | | i | f q8 ~ } | i   x\ | oT |  i | j oD | i d  \ } } | |  i j o g  |  _ Pn |  i |  qd Wt	 i
 i o* d G|  i i   GHd G|  i Gd G| GHn d  S(   Ni    s   IC is:s   IC size:t   /(   R,   R   R   t
   itervaluesR   t   sortt   popR   RM   R'   R(   R.   t   keys(   R   R,   t   _[1]RI   t   aceR   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyt   cleanout  s    3
	c         C   s   |  i  i   |  i ou t |  _ g  } x? |  i D]4 } | |  i j o |  i |  q0 | i |  q0 W| |  _ |  i   |  i  i	   n |  i  i
   d  S(   N(   R   R!   R   R"   R   R   R>   R3   RU   R#   R$   (   R   t   new_preloadst   i(    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyt   preload0  s    
	
 	
c      
   C   so  xh|  i  o]|  i i   |  i i   |  i i   x |  i o |  i  o |  i   } |  i | j o g  |  _ Pn |  i i   yO |  i i d  } | t	 j o, y |  i
 |  Wq t	 i |  q Xn Wn n X|  i   |  i i   q7 W|  i  oet i i oWt t i i  } x |  i i   D]s } | | j o | i |  q1t i i o d G| GHn t |  i |  } | t j o t | =n |  i | =q1Wx | D] } | t	 j o qn |  i o Pn t i i o d G| GHn yU | i   } | |  i | <t i i i |  } | i d t i   | t t |  <Wqt	 i |  qXqWq q Wd  S(   Ni    s   IC Pin Clears   IC Pin Preloadi   (!   R   R   R!   t   waitR$   R   R,   R   RQ   t   preload_blacklistR>   t   addRU   R'   RA   RB   t   sett   storet   _cache_pin_setR   RR   t   removeR(   R.   R?   RC   R9   R:   RD   RE   RF   RG   RH   (   R   R,   R4   t   worksetRW   RK   R   RL   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR   L  sb    	
  
(   R
   R   R	   R&   R,   R-   R/   R0   R5   R>   RM   RU   RX   R   (    (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR   7   s   	$							[		#	c           C   s"   t  i   t i   t i   d S(   s   
    Frees some memory.
    N(   R   R-   R@   RC   (    (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyt   free_memory  s    

R2   c           B   se   e  Z d  Z d Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z d
   Z RS(   sf   
    This is the base class for all of the various kinds of images that
    we can possibly have.
    i   c         C   s   | d j  o t  |  _ n d  S(   Ni   (   R   R   (   R   t   version(    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyt   after_upgrade  s    c         O   sm   | i  d d   |  _ | i  d t  |  _ | i d d  t t |   i |   t	 |   i
 f | |  _ d  S(   NRJ   R   t   styleR4   (   RQ   R=   RJ   R   R   t
   setdefaultt   superR2   R	   t   typeR
   t   identity(   R   t   argst
   properties(    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR	     s
    c         C   s   t  |  i  S(   N(   t   hashRh   (   R   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyt   __hash__  s    c         C   s(   t  | t  p t Sn |  i | i j S(   N(   R1   R2   R"   Rh   (   R   t   other(    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyt   __eq__  s    c         C   s9   d d i  g  } |  i D] } | t |  q ~  d S(   Nt   <t    t   >(   R%   Rh   t   repr(   R   RS   RW   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyt   __repr__  s    c         C   s   d S(   s   
        This function is called by the image cache code to cause this
        image to be loaded. It's expected that children of this class
        would override this.
        N(    (   R   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR9     s    c         C   sM   t  i |   } | i   \ } } t i i i | |  } | i | d  | S(   Ni    (   i    i    (   R   R>   R   R'   R:   R;   t   Rendert   blit(   R   R   R   t   stt   att   imt   rv(    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR;     s
    c         C   s   | |   d  S(   N(    (   R   t   callback(    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyt   predict_one  s    c         C   s   g  S(   so   
        Returns a list of files that will be accessed when this image
        operation is performed.
        (    (   R   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyt   predict_files  s    (   R
   R   t   __doc__t   __version__Rc   R	   Rl   Rn   Rs   R9   R;   R{   R|   (    (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR2     s   									t   Imagec           B   s,   e  Z d  Z d   Z e d  Z d   Z RS(   s<   
    This image manipulator loads an image from a file.
    c         K   s&   t  t |   i | |  | |  _ d S(   sS   
        @param filename: The filename that the image will be loaded from.
        N(   Rf   R   R	   t   filename(   R   R   Rj   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR	     s    c         C   s   yg | o. t  i i i t  i i |  i  |  i  } n+ t  i i i t  i i |  i  |  i  } | SWn_ t j
 oS } t  i	 i
 o: t  i	 i
 |  i  } | d  j o
 |  n | i   Sn   n Xd  S(   N(   R'   R:   RD   t   load_image_unscaledt   loaderR9   R   t
   load_imageR7   R(   t   missing_image_callbackR=   (   R   t   unscaledR   t   eRx   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR9     s    .*
c         C   ss   t  i i |  i  o |  i g SnL t  i i o4 t  i i |  i  } | d  j	 o | i   Sqe n |  i g Sd  S(   N(   R'   R   t   loadableR   R(   R   R=   R|   (   R   Rx   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR|   !  s    (   R
   R   R}   R	   R"   R9   R|   (    (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR     s   	t   ZipFileImagec           B   s&   e  Z d  d  Z d   Z d   Z RS(   i    c         K   s5   t  t |   i | | | |  | |  _ | |  _ d  S(   N(   Rf   R   R	   t   zipfilenameR   (   R   R   R   t   mtimeRj   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR	   /  s    	c         C   sY   t  i |  i d  } t i | i |  i   } t i i	 i
 | |  i  } | i   | S(   Nt   r(   t   zipfilet   ZipFileR   t	   cStringIOt   StringIOt   readR   R'   R:   RD   R   t   close(   R   t   zft   sioRy   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR9   5  s
    
c         C   s   g  S(   N(    (   R   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR|   =  s    (   R
   R   R	   R9   R|   (    (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR   -  s   	t	   Compositec           B   s)   e  Z d  Z d   Z d   Z d   Z RS(   sH   
    This image manipulator composites one or more images together.
    c         O   s   t  t |   i | | |  t |  d d j o t d   n | |  _ | d d d  |  _ g  } | d d d  D] } | t |  qz ~ |  _ d S(   sG  
        This takes a variable number of arguments. The first argument
        is size, which is either the desired size of the image (in
        pixels), or None to indicate that the size should be the size of
        the first image.

        It then takes an even number of further arguments. (For an odd
        number of total arguments.) The second and other even numbered
        arguments contain position tuples, while the third and further
        odd-numbered arguments give images (or image
        manipulators). A position argument gives the position of the
        image immediately following it, with the position expressed as
        a tuple giving an offset from the upper-left corner of the
        image.  The images are composited in bottom-to-top order, with
        the last image being closest to the user.
        i   i    s.   Composite requires an odd number of arguments.Ni   (	   Rf   R   R	   t   lenR7   R   t	   positionsR4   t   images(   R   R   Ri   Rj   RS   RW   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR	   G  s    	c         C   s   |  i  o |  i  } n t i |  i d  i   } t i i i | t	  } x< t
 |  i |  i  D]% \ } } | i t i |  |  qa W| S(   Ni    (   R   R   R>   R   R   R'   R:   RD   t   surfaceR   t   zipR   Ru   (   R   R   Ry   t   posRx   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR9   b  s    
 c         C   s1   g  } x$ |  i  D] } | i | i    q W| S(   N(   R   t   extendR|   (   R   Ry   RW   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR|   p  s
    
 (   R
   R   R}   R	   R9   R|   (    (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR   B  s   		t
   FrameImagec           B   s    e  Z d  Z d   Z d   Z RS(   s   
    This is an image that implements a frame with a given size. Instances
    of this are used by the frame object to return a new frame when
    such a new frame is needed.
    c         C   s   t  |  } t t |   i | | | | | | |  | |  _  | |  _ | |  _ t |  |  _ t |  |  _ | |  _	 | |  _
 |  i |  i d j  o |  i d |  _ n |  i |  i d j  o |  i d |  _ n d S(   s  
        @param image: The image that will be used as the base of this
        frame.

        @param xborder: The number of pixels in the x direction to use as
        a border.

        @param yborder: The number of pixels in the y direction to use as
        a border.

        @param width: The width we are being rendered at.

        @param height: The height we are being rendered at.

        @param tile: Should we tile? If False, we scale.
        i   N(   R4   Rf   R   R	   t   xbordert   ybordert   intt   widtht   heightt   tilet   bilinear(   R   Rx   R   R   R   R   R   R   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR	     s    (					c            s   i    i   t i i i    f t    } t i  i	   t i i
 i    t i i
 i    t i i
 i
  i  } t i i
 i
  i  }  i   \    i   \    | d  j o  d d } n | d  j o  d d } n         f d   } | d | d |  | | | d |  | | d d |  | d | | |  | | | | |  | | d | |  | d | | d  | | | | d  | | d | d  | S(   Ni   i   c            s@  |  d j o |  } |  } n   |  }  |  } | d j o | } | } n   | }  | } | d j o | } | }	 n  | }  | }	 | d j o | }
 | } n  | }
  | } | | j p |	 | j o d  Sn | | | |	 f } t  | |  t  |
 |  f }  i | |	 | d | d f  } | | j o  i o | \ } } | \ } } t i i i | |  } xM t d | |  D]9 } x0 t d | |  D] } | i | | | f  qWqW| } q& i	 o t i i
 i | |  } n t i i
 i | |  } | } n  i | | | f  d  S(   Ni    i   (   R   t
   subsurfaceR   R'   R:   RD   t   surface_unscaledt   rangeRu   R   t   scalet   real_smoothscalet   real_transform_scale(   t   x0t   x1t   y0t   y1t   dx0t   sx0t   dx1t   sx1t   dy0t   sy0t   dy1t   sy1t   srcsizet   dstsizeR   t   tilewt   tileht   dstwt   dstht   surf2t   yt   x(   t   dwR   t   sourcet   dht   destt   swt   sh(    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyt   draw  sR    











 #
  


i    (   R   R   R'   R:   RD   R   R   R   R>   R4   R   t   realR   R   R   (   R   Ry   t   xbt   ybR   (    (   R   R   R   R   R   R   R   s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR9     s4    		!L(   R
   R   R}   R	   R9   (    (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR   y  s   	't
   SolidImagec           B   s    e  Z d  Z d   Z d   Z RS(   si   
    This is an image that is a solid rectangle with a given size. It's
    used to implement Solid.
    c         C   sG   t  t |   i | | |  | |  _ t |  |  _ t |  |  _ d  S(   N(   Rf   R   R	   t   colorR   R   R   (   R   R   R   R   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR	   #  s    	c         C   s8   t  i i i |  i |  i f t  } | i |  i  | S(   N(	   R'   R:   RD   R   R   R   R   t   fillR   (   R   Ry   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR9   )  s    $(   R
   R   R}   R	   R9   (    (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR     s   	t   Scalec           B   s,   e  Z d  Z e d  Z d   Z d   Z RS(   ss   
    This is an image manipulator that scales another image manipulator
    to the specified width and height.
    c         K   sb   t  |  } t t |   i | | | | |  | |  _  t |  |  _ t |  |  _ | |  _ d  S(   N(   R4   Rf   R   R	   R   R   R   R   (   R   Rx   R   R   R   Rj   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR	   6  s    "	c         C   s   t  i |  i  } |  i oV z; t i i i i   t i i	 i
 | |  i |  i f  } Wd  t i i i i   XnS z; t i i i i   t i i i | |  i |  i f  } Wd  t i i i i   X| S(   N(   R   R>   R4   R   R'   R:   R;   t	   blit_lockR!   R   t   smoothscaleR   R   R$   RD   t   transform_scale(   R   t   childRy   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR9   @  s    
((c         C   s   |  i  i   S(   N(   R4   R|   (   R   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR|   S  s    (   R
   R   R}   R   R	   R9   R|   (    (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR   0  s   
	t   FactorScalec           B   s/   e  Z d  Z d e d  Z d   Z d   Z RS(   sY   
    This is the same, but it takes a factor rather than an absolute scale
    size.
    c         K   sm   | d  j o
 | } n t |  } t t |   i | | | | |  | |  _ | |  _ | |  _ | |  _ d  S(   N(   R=   R4   Rf   R   R	   R   R   R   (   R   Rx   R   R   R   Rj   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR	   \  s    
"			c         C   s   t  i |  i  } | i   \ } } t | |  i  } t | |  i  } |  i oP z5 t i	 i
 i i   t i	 i i | | | f  } Wd  t i	 i
 i i   XnM z5 t i	 i
 i i   t i	 i i | | | f  } Wd  t i	 i
 i i   X| S(   N(   R   R>   R4   R   R   R   R   R   R'   R:   R;   R   R!   R   R   R$   RD   R   (   R   R   R   R   Ry   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR9   i  s    
""c         C   s   |  i  i   S(   N(   R4   R|   (   R   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR|     s    N(   R
   R   R}   R=   R   R	   R9   R|   (    (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR   V  s   	t   Flipc           B   s/   e  Z d  Z e e d  Z d   Z d   Z RS(   sZ   
    This is an image manipulator that can flip the image horizontally or vertically.
    c         K   sh   | p | p t  d   n t |  } t t |   i | | | |  | |  _ | |  _ | |  _ d S(   s   
        @param im: The image to be rotozoomed.

        @param horizontal: True to flip the image horizontally.

        @param vertical: True to flip the image vertically.
        sD   im.Flip must be called with a true value for horizontal or vertical.N(   R7   R4   Rf   R   R	   t
   horizontalt   vertical(   R   Rx   R   R   Rj   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR	     s    			c         C   se   t  i |  i  } z8 t i i i i   t i i i	 | |  i
 |  i  } Wd  t i i i i   X| S(   N(   R   R>   R4   R'   R:   R;   R   R!   RD   t   flipR   R   R$   (   R   R   Ry   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR9     s    %c         C   s   |  i  i   S(   N(   R4   R|   (   R   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR|     s    (   R
   R   R}   R"   R	   R9   R|   (    (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR     s   	t   Rotozoomc           B   s)   e  Z d  Z d   Z d   Z d   Z RS(   sg   
    This is an image manipulator that is a smooth rotation and zoom of another image manipulator.
    c         K   sJ   t  |  } t t |   i | | | |  | |  _  | |  _ | |  _ d S(   s  
        @param im: The image to be rotozoomed.

        @param angle: The number of degrees counterclockwise the image is
        to be rotated.

        @param zoom: The zoom factor. Numbers that are greater than 1.0
        lead to the image becoming larger.
        N(   R4   Rf   R   R	   t   anglet   zoom(   R   Rx   R   R   Rj   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR	     s
    		c         C   se   t  i |  i  } z8 t i i i i   t i i i	 | |  i
 |  i  } Wd  t i i i i   X| S(   N(   R   R>   R4   R'   R:   R;   R   R!   RD   t   rotozoomR   R   R$   (   R   R   Ry   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR9     s    %c         C   s   |  i  i   S(   N(   R4   R|   (   R   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR|     s    (   R
   R   R}   R	   R9   R|   (    (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR     s   		t   Cropc           B   s)   e  Z d  Z d   Z d   Z d   Z RS(   s1   
    This crops the image that is its child.
    c         K   sb   t  |  } t t |   i | | | | | |  | |  _  | |  _ | |  _ | |  _ | |  _ d  S(   N(   R4   Rf   R   R	   R   R   R   R   (   R   Rx   R   R   R   R   Rj   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR	     s    %				c         C   s1   t  i |  i  i |  i |  i |  i |  i f  S(   N(   R   R>   R4   R   R   R   R   R   (   R   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR9     s    c         C   s   |  i  i   S(   N(   R4   R|   (   R   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR|     s    (   R
   R   R}   R	   R9   R|   (    (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR     s   		c         C   s   t  i |  | f d  } | d j ov g  } xJ t d d  D]9 } | d } | i t t | | |  d |    q; Wd i |  } | t  |  | f <n | S(   s   
    Returns a 256 character linear ramp, where the first character has
    the value start and the last character has the value end. Such a
    ramp can be used as a map argument of im.Map.
    i    i   g     o@g      ?t    N(   t
   ramp_cacheR>   R=   R   R3   t   chrR   R%   (   R   t   endRy   t   charsRW   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyt   ramp  s     
-i    i   t   Mapc           B   s8   e  Z d  Z e e e e e d  Z d   Z d   Z RS(   s   
    This adjusts the colors of the image that is its child. It takes
    as arguments 4 256 character strings. If a pixel channel has a
    value of 192, then the value of the 192nd character in the string
    is used for the mapped pixel component.
    c         K   sn   t  |  } t t |   i | | | | | | |  | |  _  | |  _ | |  _ | |  _ | |  _ | |  _ d  S(   N(	   R4   Rf   R   R	   t   rmapt   gmapt   bmapt   amapt   force_alpha(   R   Rx   R   R   R   R   R   Rj   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR	     s    (					c         C   sb   t  i |  i  } t i i i | i   t  } t i i	 i
 | | |  i |  i |  i |  i  | S(   N(   R   R>   R4   R'   R:   RD   R   R   R   t   modulet   mapR   R   R   R   (   R   R   Ry   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR9   "  s
    c         C   s   |  i  i   S(   N(   R4   R|   (   R   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR|   -  s    (   R
   R   R}   Rh   R"   R	   R9   R|   (    (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR     s
   		t   Twocolorc           B   s,   e  Z d  Z e d  Z d   Z d   Z RS(   sp  
    This takes as arguments two colors, white and black. The image is
    mapped such that pixels in white have the white color, pixels in
    black have the black color, and shades of gray are linearly
    interpolated inbetween.  The alpha channel is mapped linearly
    between 0 and the alpha found in the white color, the black
    color's alpha is ignored.
    c         K   sz   t  i i |  } t  i i |  } t |  } t t |   i | | | | |  | |  _ | |  _ | |  _ | |  _	 d  S(   N(
   R'   t   easyR   R4   Rf   R   R	   t   whitet   blackR   (   R   Rx   R   R   R   Rj   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR	   :  s    "			c         C   sV   t  i |  i  } t i i i | i   t  } t i i	 i
 | | |  i |  i  | S(   N(   R   R>   R4   R'   R:   RD   R   R   R   R   t   twomapR   R   (   R   R   Ry   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR9   I  s
    c         C   s   |  i  i   S(   N(   R4   R|   (   R   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR|   T  s    (   R
   R   R}   R"   R	   R9   R|   (    (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR   0  s   	t   Recolorc           B   s8   e  Z d  Z d d d d e d  Z d   Z d   Z RS(   s   
    This adjusts the colors of the image that is its child. It takes as an
    argument 4 numbers between 0 and 255, and maps each channel of the image
    linearly between 0 and the supplied color.
    i   c         K   s~   t  |  } t t |   i | | | | | | |  | |  _  | d |  _ | d |  _ | d |  _ | d |  _ | |  _ d  S(   Ni   (	   R4   Rf   R   R	   t   rmult   gmult   bmult   amulR   (   R   Rx   R   R   R   R   R   Rj   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR	   _  s    (	c         C   sb   t  i |  i  } t i i i | i   t  } t i i	 i
 | | |  i |  i |  i |  i  | S(   N(   R   R>   R4   R'   R:   RD   R   R   R   R   t   linmapR   R   R   R   (   R   R   Ry   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR9   n  s
    c         C   s   |  i  i   S(   N(   R4   R|   (   R   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR|   y  s    (   R
   R   R}   R"   R	   R9   R|   (    (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR   X  s
   		t   MatrixColorc           B   s)   e  Z d  Z d   Z d   Z d   Z RS(   ss   
    This applies a 20 element matrix, that turns the color vector:
    [ r, g, b, a, 1 ] into [ r, g, b, a ].
    c         K   s   t  |  } t |  d j o- t |  d j o t d t |    n t |  } t t |   i | | |  | |  _  | |  _ d  S(   Ni   i   s?   ColorMatrix expects a 20 or 25 element matrix, got %d elements.(   R4   R   R7   t   tupleRf   R   R	   t   matrix(   R   Rx   R   Rj   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR	     s    &	c         C   sP   t  i |  i  } t i i i | i   t  } t i i	 i
 | | |  i  | S(   N(   R   R>   R4   R'   R:   RD   R   R   R   R   t   colormatrixR   (   R   R   Ry   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR9     s    c         C   s   |  i  i   S(   N(   R4   R|   (   R   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR|     s    (   R
   R   R}   R	   R9   R|   (    (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR   |  s   		
R   c           B   s.  e  Z d  Z d   Z d   Z d   Z d   Z d   Z e Z d   Z	 d   Z
 d   Z d	   Z d
   Z d   Z e e  Z d d  Z e e  Z d   Z e e  Z d   Z e e  Z d   Z e e  Z d   Z e e  Z d   Z e e  Z d   Z e e  Z d   Z e e  Z RS(   s:   
    This class represents a 5x5 mathematical matrix.
    c         G   s   t  |  d j o t | d  } n t  |  d j o | d } n t  |  d j o t d t  |    n t i |  |  S(   Ni   i    i   i   s4   Matrix expects to be given 20 or 25 entries, not %d.(   i    i    i    i    i   (   R   R   R7   t   __new__(   t   clsRi   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR     s    c         C   s   t  | t  p t |  } n t  | t  p t |  } n d g d } x t d d  D]n } xe t d d  D]T } xK t d d  D]: } | | | d c | | | d | | | d 7<q Wqs Wq] Wt |  S(   Ni    i   i   (   R1   R   R   (   R   t   at   bt   resultR   R   RW   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyt   mul  s       @c         C   s5   t  |  } t g  } |  D] } | | | q ~  S(   N(   t   floatR   (   R   Rm   RS   RW   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyt
   scalar_mul  s    c         C   s#  | d |  d | d |  d | d |  d | d |  d |  d | d |  d | d |  d | d |  d | d |  d	 |  d
 | d |  d | d |  d | d |  d | d |  d |  d | d |  d | d |  d | d |  d | d |  d |  d d f S(   Ni    i   i   i   i   i   i   i   i   i	   i
   i   i   i   i   i   i   i   i   i   (    (   R   t   o(    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyt
   vector_mul  s
    GGGGc         C   s   t  | t t f  o9 t |  } t g  } |  D] } | | | q0 ~  Sn t |  } t g  } t |  |  D] \ } } | | | qr ~  S(   N(   R1   R   R   R   R   (   R   Rm   RS   RW   t   _[2]t   j(    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyt   __add__  s
    -c         C   s   |  | d S(   Ni(    (   R   Rm   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyt   __sub__  s    c         C   s   |  d | S(   Ni(    (   R   Rm   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyt   __rsub__  s    c         C   s7   t  | t t f  o |  i |  Sn |  i |  |  S(   N(   R1   R   R   R   R   (   R   Rm   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyt   __mul__  s    c         C   s7   t  | t t f  o |  i |  Sn |  i | |   S(   N(   R1   R   R   R   R   (   R   Rm   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyt   __rmul__  s    c         C   s   d |  S(   Ns   im.matrix(%f, %f, %f, %f, %f.
          %f, %f, %f, %f, %f,
          %f, %f, %f, %f, %f,
          %f, %f, %f, %f, %f,
          %f, %f, %f, %f, %f)(    (   R   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyRs     s    c           C   sC   t  d d d d d d d d d d d d d d d d d d d d  S(   Ni   i    (   R   (    (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyRh     s    gz6?g,C?g]m{?c            s   | \ } } }   f d   } t  | | d  | | d  | | d  d d | | d  | | d  | | d  d d | | d  | | d  | | d  d d d d d d d  S(   Nc            s   |  | |    S(   N(    (   R   R   (   t   level(    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyt   I  s    i   i    (   R   (   R	  t   desatR   t   gR   R
  (    (   R	  s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyt
   saturation  s    -**c           C   s   t  i d  S(   Ng        (   R   R  (    (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyt
   desaturate  s    c         C   sC   t  |  d d d d d | d d d d d | d d d d d d d  S(   Ni    i   (   R   (   R   R  R   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyt   tint  s    c           C   sC   t  d d d d d d d d d d d d d d d d d d d d  S(   Nii    i   (   R   (    (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyt   invert  s    c         C   sC   t  d d d d |  d d d d |  d d d d |  d d d d d  S(   Ni   i    (   R   (   R   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyt
   brightness  s    c         C   sC   t  d d d d d d d d d d d d d d d d d d |  d  S(   Ni   i    (   R   (   R   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyt   opacity$  s    c         C   s-   t  i d  t  i |  |  |   t  i d  S(   Ng      g      ?(   R   R  R  (   t   c(    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyt   contrast,  s    c         C   s@  |  t  i d }  t  i |   } t  i |   } d } d } d } t | | d | | | | | | | | | | | | d | d d | | | | d | | d | | d | | | | d	 d d | | | | d | | | | | | | | d | | | d d d d d d d d d d d d  S(
   Ni   g$C?gzG?g;On?i   i    gM?gQ?g&1ҿ(   t   matht   pit   cost   sinR   (   R   t   cosValt   sinValt   lumRt   lumGt   lumB(    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyt   hue3  s    KEJ(   gz6?g,C?g]m{?(   R
   R   R}   R   R   R   R  R  t   __radd__R  R  R  R  Rs   Rh   t   staticmethodR  R  R  R  R  R  R  R  (    (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR     s<   																				gz6?g,C?g]m{?c         K   s   t  |  t i d |  |  S(   Ng        (   R   R   R  (   Rx   R  Rj   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyt	   GrayscaleE  s    g      ?gGz?gRQ?c         K   s;   t  |  t i d |  t i | d | d | d  |  S(   Ng        i    i   i   (   R   R   R  R  (   Rx   R  R  Rj   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyt   SepiaI  s    c         C   s4   t  i i |  \ } } } } t |  | | | |  S(   sx   
    This recolors the supplied image, mapping colors such that black is
    black and white is the supplied color.
    (   R'   R   R   R   (   Rx   R   R   R  R   R   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyt   ColorM  s    c      	   K   s)   t  |  d d d t d |  d t | S(   s  
    Returns an alpha-mapped version of the image. Alpha is the maximum
    alpha that this image can have, a number between 0.0 (fully
    transparent) and 1.0 (opaque).

    If an image already has an alpha channel, values in that alpha
    channel are reduced as appropriate.
    i   R   (   R   R   R   (   R4   t   alphaRj   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyt   AlphaX  s    
t   Tilec           B   s,   e  Z d  Z d d  Z d   Z d   Z RS(   s   
    This tiles the image, repeating it vertically and horizontally
    until it is as large as the specified size. If no size is given,
    then the size defaults to the size of the screen.
    c         K   s>   t  |  } t t |   i | | |  | |  _  | |  _ d  S(   N(   R4   Rf   R&  R	   R   (   R   Rx   R   Rj   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR	   k  s    	c   
      C   s   |  i  } | d  j o t i i t i i f } n t i |  i  } t i	 i
 i | t  } | \ } } | i   \ } } xM t d | |  D]9 } x0 t d | |  D] }	 | i | |	 | f  q Wq W| S(   Ni    (   R   R=   R'   R(   R*   R+   R   R>   R4   R:   RD   R   R   R   R   Ru   (
   R   R   R   Ry   R   R   R   R   R   R   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR9   s  s    	  c         C   s   |  i  i   S(   N(   R4   R|   (   R   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR|     s    N(   R
   R   R}   R=   R	   R9   R|   (    (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR&  d  s   	t	   AlphaMaskc           B   s#   e  Z d    Z d   Z d   Z RS(   c         K   s>   t  t |   i | | |  t |  |  _ t |  |  _ d  S(   N(   Rf   R'  R	   R4   t   baset   mask(   R   R(  R)  Rj   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR	     s    c         C   s   t  i |  i  } t  i |  i  } | i   | i   j o t d   n t i i i	 |  } t i i
 i | | t  | S(   Ns)   AlphaMask surfaces must be the same size.(   R   R>   R(  R)  R   R7   R'   R:   RD   RE   R   t   alpha_mungeRh   (   R   t   basesurft   masksurfRy   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR9     s    c         C   s   |  i  i   |  i i   S(   N(   R(  R|   R)  (   R   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR|     s    (   R
   R   R	   R9   R|   (    (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR'    s   		c         K   s  t  |  t  o |  Sn t  |  t i i i  o$ |  i   t |  i d | | Snt t  |  t  o t	 |  |  SnS t  |  t
  oB g  } x( |  D]  } | i d  | i |  q Wt d |  Sn | o |  Sn t  |  t i i i  o t d   n t d   d S(   s,  
    This takes as input one of a number of ways of specifying an
    image, and returns the Displayable image object that has been so
    specified. Specifically, this can take as input:

    <ul>
    <li> An image object. In that case, it's returned unchanged.</li>
    <li> A string. If a string is given, then the string is interpreted
    as a filename, and what is returned is an im.Image object, which
    loads the image from disk.</li>
    <li> A tuple. If this is the case, then what is returned is an
    im.Composite object, which aligns the upper-left corner of all
    of the images supplied as arguments. </li>
    </ul>

    If the loose argument is False, then this will report an error if an
    arbitrary argument is given. If it's True, then the argument is passed
    through unchanged.
    t   loosei    s1   Expected an image, but got a general displayable.s(   Could not construct image from argument.N(   i    i    (   R1   R2   R'   R:   R4   t   ImageReferencet   find_targetR   t
   basestringR   R   R3   R   R=   t   coret   DisplayableR7   (   t   argR-  Rj   t   paramsRW   (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR4     s&    
 c         C   s   t  i t |    S(   sG   
    This loads an image from the given filename, using the cache.
    (   R   R>   R4   (   t   fn(    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pyR     s    (/   R'   R  R   R   R   RG   t   objectR    R   R@   RC   R\   RZ   R   Ra   R:   R1  R2  R2   R   R   R   R   R   R   R   R   R   R   R   R   Rh   R   R   R   R   R   R   R!  R"  R#  R%  R&  R'  R"   R4   R   (    (    (    s8   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\display\im.pys   <module>   sP    t			
@.7&/+(	%($ !		&1