ó
5…6ic        
   @   sM  d  d l  Z  e  d  d l Z d  d l Z d  d l Z d „  Z d „  Z d „  Z e j d k rŠ i d d 6d d	 6d
 d 6d d 6d d 6Z	 n) i d d 6d
 d	 6d d 6d d 6d d 6Z	 d a d „  Z d „  Z d „  Z e j Z d „  Z d „  Z d „  Z d d d d d d d d d d „	 Z e j Z e j Z d „  Z d „  Z d „  Z d S(   iÿÿÿÿNc         G   sO   | j  ƒ  d d k | j  ƒ  d d k k r; t d ƒ ‚ n  |  | | | Œ d S(   sú   
    This calls the function with the source and destination
    surface. The surfaces must have the same alpha.

    If the surfaces are not 24 or 32 bits per pixel, or don't have the
    same format, they are converted and then converted back.
    i   i    s   Surface alphas do not match.N(   t	   get_maskst	   Exception(   t   functiont   srct   dstt   args(    (    sc   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\display\module.pyt   convert_and_call    s    ,c         C   s#   t  t j |  | | | | | ƒ d S(   s;  
    This pixellates the source surface. First, every pixel in the
    source surface is projected onto a virtual surface, such that
    the average value of every avgwidth x avgheight pixels becomes
    one virtual pixel. It then gets projected back onto the
    destination surface at a ratio of one virtual pixel to every
    outwidth x outheight destination pixels.

    If either src or dst is not a 24 or 32 bit surface, they are
    converted... but that may be a significant performance hit.

    The two surfaces must either have the same alpha or no alpha.
    N(   R   t   _renpyt	   pixellate(   R   R   t   avgwidtht	   avgheightt   outwidtht	   outheight(    (    sc   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\display\module.pyR   2   s    	c         C   s)   t  j j j | t ƒ } t |  | ƒ | S(   sƒ   
    Scales down the supplied pygame surface by the given X and Y
    factors.

    Always works, but may not be high quality.
    (   t   renpyt   displayt   pgrendert   surfacet   Truet   bilinear_scale(   t   st   sizet   d(    (    sc   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\display\module.pyt   scaleG   s    t   bigi   iÿ   i   i ÿ  i   i  ÿ i    l      ~ i   ÿc         C   s6   t  d k r2 g  |  j ƒ  D] } t | ^ q a  n  t  S(   sÏ   
    Given the surface src, returns a 4-tuple giving the byte offsets
    for the red, green, blue, and alpha components of the pixels in
    the surface. If a component doesn't exist, None is returned.
    N(   t   bo_cachet   NoneR    t   bo32(   R   t   i(    (    sc   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\display\module.pyt   byte_offsetb   s    	&c         C   se   t  d  k r t |  ƒ n  | | | | g } x3 t | | | | f t  ƒ D] \ } } | | | <qG W| S(   N(   R   R   R   t   zip(   R   t   rt   gt   bt   at   rvR   t   index_i(    (    sc   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\display\module.pyt   endian_orderq   s    (c      
   C   s,   t  t j |  | t | | | | | ƒ Œ d S(   s„   
    This maps the colors between two surfaces. The various map
    parameters should be fixed-point integers, with 1.0 == 256.
    N(   R   R   t   linmapR$   (   R   R   t   rmapt   gmapt   bmapt   amap(    (    sc   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\display\module.pyR%   ~   s    	c      
   C   s,   t  t j |  | t | | | | | ƒ Œ d S(   së   
    This maps the colors between two surfaces. The various map
    parameters must be 256 character long strings, with the value
    of a character at a given offset being what a particular pixel
    component value is mapped to.
    N(   R   R   t   mapR$   (   R   R   R&   R'   R(   R)   (    (    sc   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\display\module.pyR*   Œ   s    	c      	   C   sæ   | d } | d } | d } | d } | d } | d }	 | d }
 t  j j j } | d k r¥ |	 d k r¥ |
 d k r¥ t |  | | d | d | d | d ƒ n= t |  | | | | ƒ | |	 | ƒ | |
 | ƒ | d | ƒ ƒ d S(   sx   
    Given colors for white and black, linearly maps things
    appropriately, taking the alpha channel from white.
    i    i   i   i   N(   R   R   t   imt   rampR%   R*   (   R   R   t   whitet   blackt   wrt   wgt   wbt   wat   brt   bgt   bbR,   (    (    sc   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\display\module.pyt   twomap™   s&    






$		c         C   st   |  j  ƒ  | j  ƒ  k r d St |  ƒ d } t | ƒ d } | d k	 rp | d k	 rp t j |  | | | | ƒ n  d S(   sw   
    This samples the red channel from src, maps it through amap, and
    place it into the alpha channel of amap.
    Ni    i   (   t   get_sizeR   R   R   t   alpha_munge(   R   R   R)   t   redt   alpha(    (    sc   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\display\module.pyR8   ¸   s    c         C   s3  | d  k r! |  j ƒ  \ } } n  | d  k rB | j ƒ  \ } }	 n  x¼ t r | | d k ro | |	 d k ro Pn  t | d | ƒ } t | d |	 ƒ } t j j j | | f |  j ƒ  d ƒ } t	 j
 |  | | | | | d |
 ƒd } d } | } | } | }  qE Wt	 j
 |  | | | | | | | | |	 d |
 ƒ
d  S(   Ni   i   t   precisei    (   R   R7   R   t   maxR   R   R   R   R    R   t   bilinear(   R   R   t   sxt   syt   swt   sht   dxt   dyt   dwt   dhR;   t   nswt   nsht   nsrc(    (    sc   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\display\module.pyR   È   s"    	 ("
c         C   s0   t  | ƒ d } t j |  | | | | | ƒ d  S(   Ni   (   R   R   t
   imageblend(   R!   R    R   t   imgR)   R:   (    (    sc   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\display\module.pyRI   ê   s    c         C   sï  | d d !| d d !| d d !| d d !g } t  |  ƒ } d  g d } x% t d d ƒ D] } | | | | <qW Wt j |  | | | 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	 | d	 | | d	 d ƒ d  S(
   Ni    i   i
   i   i   i   i   i   i   (   R   R   t   rangeR   t   colormatrix(   R   R   t   matrixt   ct   offst   oR   (    (    sc   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\display\module.pyRL   ï   s    .[[[c         C   s-   |  j  ƒ  d } t j |  | | | | ƒ d  S(   Ni   (   t
   get_shiftsR   t   subpixel(   R   R   t   xt   yt   shift(    (    sc   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\display\module.pyRR   þ   s    (   t   pygame_sdl2t   renpy.displayR   R   t   sysR   R   R   t	   byteorderR   R   R   R   R$   R%   t   save_pngR*   R6   R8   R   t	   transformt   blendRI   RL   RR   (    (    (    sc   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\display\module.pyt   <module>   s0    			,)							$				