ó
2…6ic           @   s2   d  d l  Z d  d l Z d e f d „  ƒ  YZ d S(   iÿÿÿÿNt   Colorc           B   sm  e  Z d  Z d  Z d  Z d  Z d  Z d  d  d  d  d d „ Z e	 d „  ƒ Z
 d „  Z d „  Z e	 d „  ƒ Z e	 d „  ƒ Z e	 d „  ƒ Z e	 d	 „  ƒ Z d
 „  Z d „  Z e Z d „  Z d „  Z d „  Z 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# d „  Z$ d „  Z% d „  Z& d „  Z' d „  Z( RS(!   sñ  
    :doc: color class
    :args: (color=None, hls=None, hsv=None, rgb=None, alpha=1.0)
    :name: Color

    The Color class is used to represent and manipulate colors and convert
    between various color spaces. It also represents opacity in the form
    of an alpha.

    When creating a Color, at one of the `color`, `hls`, `hsv`, or `rgb`
    arguments should be supplied. (If all are None, None is returned.)

    `color`
        The color, in one of the standard formats Ren'Py understands. These
        are:

        * A Color object.
        * An (r, g, b) or (r, g, b, a) tuple, in which all the numbers are
          between 0 and 255.
        * A string giving a hexadecimal color, in the form "#rgb", "#rgba",
          "#rrggbb", or "#rrggbbaa".

    `hls`
        A color in the hue-lightness-saturation color space. This should
        be supplied a three-component tuple, where each component is between
        0.0 and 1.0.

    `hsv`
        A color in the hue-saturation-value color space. This should
        be supplied a three-component tuple, where each component is between
        0.0 and 1.0.

    `rgb`
        A color in the red-green-blue color space. This should
        be supplied a three-component tuple, where each component is between
        0.0 and 1.0.

    If the supplied color does not contain an alpha value, `alpha` is used.
    `alpha` must be between 0.0 and 1.0.

    Color objects can be used as 4-component tuples, where the components
    are (red, green, blue, and alpha). When used as a tuple, the value
    of each component is between 0 and 255.

    Color objects support the +, -, and * operators, representing
    component-wise addition, subtraction, and multiplication. Some uses
    of these operators can cause the creation of colors with components
    that are not in the supported range. Such colors should not be passed
    to other parts of Ren'Py. (The normalize method can be called to return
    a new color with the components limited to the proper range.)

    A Color object has the following properties:

    .. attribute:: hls

        Returns the color as a tuple of three floating point numbers giving
        hue, lightness, and saturation. Each component ranges between 0.0 and 1.0.

    .. attribute:: hsv

        Returns the color as a tuple of three floating point numbers giving
        hue, saturation, and value. Each component ranges between 0.0 and 1.0.

    .. attribute:: rgb

        Returns the color as a tuple of three floating point numbers giving
        the red, green, and blue components. Each component ranges between 0.0
        and 1.0.

    .. attribute:: alpha

        Returns the alpha (opacity) of this Color as a number between 0.0 and
        1.0, where 0.0 is transparent and 1.0 is opaque.

    .. attribute:: hexcode

        Returns a string containing a hex color code of the form #rrggbbaa
        or #rrggbb.

    Color objects have the following methods. Since Colors are immutable,
    these methods always return a new Color object.
    g      ð?c         C   s¼  | d  k	 rµ| } t | t ƒ rŒ t | t ƒ r4 | St | ƒ d k rV t j |  | ƒ St | ƒ d k rŒ t j |  | t d | ƒ f ƒ Sn  t | t ƒ rµ| d d k r¸ | d } n  t | ƒ d k r.t | d | d d ƒ } t | d	 | d d ƒ } t | d | d
 d ƒ }	 t | d ƒ }
 nht | ƒ d k r¯t | d | d d ƒ } t | d	 | d d ƒ } t | d | d
 d ƒ }	 t | d | d d ƒ }
 nç t | ƒ d k rt | d d ƒ d } t | d d ƒ d } t | d	 d ƒ d }	 t | d ƒ }
 n} t | ƒ d k rŠt | d d ƒ d } t | d d ƒ d } t | d	 d ƒ d }	 t | d d ƒ d }
 n t d ƒ ‚ t j |  | | |	 |
 f ƒ Sn  | d  k	 rÓt	 j
 | Œ  } n  | d  k	 r÷d  } t	 j | Œ  } n  | d  k	 r•t | d d ƒ } t | d d ƒ } t | d	 d ƒ }	 t | d ƒ }
 t j |  | | |	 |
 f ƒ } | | _ | | _ | | _ | | _ | S| d  k r¥d  St d | f ƒ ‚ d  S(   Ni   i   iÿ   i    t   #i   i   i   i   i   i   i   i   s3   Color string must be 3, 4, 6, or 8 hex digits long.s   Not a color: %r(   t   Nonet
   isinstancet   tupleR    t   lent   __new__t   intt
   basestringt	   Exceptiont   colorsyst
   hsv_to_rgbt
   hls_to_rgbt   _rgbt   _hlst   _hsvt   _alpha(   t   clst   colort   hlst   hsvt   rgbt   alphat   ct   rt   gt   bt   at   rv(    (    sZ   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\color.pyR   t   sj    $				c         C   s3   |  j  d k r d j d |  ƒ Sd j d |  ƒ Sd  S(   Ng      ð?s5   #{self[0]:02x}{self[1]:02x}{self[2]:02x}{self[3]:02x}t   selfs(   #{self[0]:02x}{self[1]:02x}{self[2]:02x}(   R   t   format(   R   (    (    sZ   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\color.pyt   hexcodeº   s    c         C   s   d j  |  j ƒ S(   Ns
   <Color {}>(   R   R   (   R   (    (    sZ   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\color.pyt   __repr__Á   s    c         C   s   t  |  ƒ f S(   N(   R   (   R   (    (    sZ   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\color.pyt   __getnewargs__Ä   s    c         C   sC   |  j  d  k r< |  d d |  d d |  d d f |  _  n  |  j  S(   Ni    g     ào@i   i   (   R   R   (   R   (    (    sZ   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\color.pyR   Ç   s
    c         C   s.   |  j  d  k r' t j |  j Œ  |  _  n  |  j  S(   N(   R   R   R
   t
   rgb_to_hlsR   (   R   (    (    sZ   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\color.pyR   Ò   s    c         C   s.   |  j  d  k r' t j |  j Œ  |  _  n  |  j  S(   N(   R   R   R
   t
   rgb_to_hsvR   (   R   (    (    sZ   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\color.pyR   Ù   s    c         C   s*   |  j  d  k r# |  d d |  _  n  |  j  S(   Ni   g     ào@(   R   R   (   R   (    (    sZ   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\color.pyR   à   s    c         C   s†   t  t |  d d ƒ d ƒ } t  t |  d d ƒ d ƒ } t  t |  d d ƒ d ƒ } t  t |  d d ƒ d ƒ } t | | | | f ƒ S(   s   
        :doc: color method

        Returns a normalized version of this Color where all components fall
        between 0 and 255.
        i    iÿ   i   i   i   (   t   maxt   minR    (   R   R   R   R   R   (    (    sZ   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\color.pyt	   normalizeç   s
    c         C   sR   t  | ƒ } t  |  d | d |  d | d |  d | d |  d | d f ƒ S(   Ni    i   i   i   (   R    (   R   t   other(    (    sZ   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\color.pyt   __add__ö   s    c         C   sR   t  | ƒ } t  |  d | d |  d | d |  d | d |  d | d f ƒ S(   Ni    i   i   i   (   R    (   R   R'   (    (    sZ   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\color.pyt   __sub__  s    c         C   s   t  | ƒ } | |  S(   N(   R    (   R   R'   (    (    sZ   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\color.pyt   __rsub__
  s    c         C   s‘   t  | t j j j ƒ r? t t d „  | j |  ƒ d  Dƒ ƒ ƒ St | ƒ } t |  d | d |  d | d |  d | d |  d | d f ƒ S(   Nc         s   s   |  ] } t  | ƒ Vq d  S(   N(   R   (   t   .0t   i(    (    sZ   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\color.pys	   <genexpr>  s    i   i    i   i   i   (   R   t   renpyt   displayt   imt   matrixR    R   t
   vector_mul(   R   R'   (    (    sZ   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\color.pyt   __mul__  s    'c            s\   t  | t ƒ r: t ‡  ‡ f d †  t | | ƒ Dƒ ƒ } n | | | ˆ  } t | ƒ | ƒ S(   Nc         3   s*   |  ]  \ } } ˆ j  | | ˆ  ƒ Vq d  S(   N(   t   interpolate_core(   R+   t   act   bc(   t   fractionR   (    sZ   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\color.pys	   <genexpr>   s    (   R   R   t   zipt   type(   R   R   R   R6   R   (    (   R6   R   sZ   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\color.pyR3     s    +c         C   s   t  | ƒ } |  j |  | | ƒ S(   s  
        :doc: color method

        Interpolates between this Color and `other` in the RGB color
        space, returning a new Color as the result. If `fraction` is 0.0, the
        result is the same as this color, if 1.0, it is the same as `other`.
        (   R    R3   (   R   R'   R6   (    (    sZ   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\color.pyt   interpolate&  s    	c         C   sš   t  | t ƒ r' t | d |  j ƒ} n* t  | t ƒ sQ t d | d |  j ƒ } n  |  j |  j | j | ƒ } |  j |  j | j | ƒ } t d | d | ƒ S(   s>  
        :doc: color method

        Interpolates between this Color and `other` in the HSV color
        space, returning a new Color as the result. If `fraction` is 0.0, the
        result is the same as this color, if 1.0, it is the same as `other`.

        `other` may be a string, Color or an HSV tuple.
        R   R   (   R   R   R    R   R3   R   (   R   R'   R6   R   R   (    (    sZ   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\color.pyt   interpolate_hsv3  s    c         C   sš   t  | t ƒ r' t | d |  j ƒ} n* t  | t ƒ sQ t d | d |  j ƒ } n  |  j |  j | j | ƒ } |  j |  j | j | ƒ } t d | d | ƒ S(   s>  
        :doc: color method

        Interpolates between this Color and `other` in the HLS color
        space, returning a new Color as the result. If `fraction` is 0.0, the
        result is the same as this color, if 1.0, it is the same as `other`.

        `other` may be a string, Color or an HLS tuple.
        R   R   (   R   R   R    R   R3   R   (   R   R'   R6   R   R   (    (    sZ   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\color.pyt   interpolate_hlsH  s    c         C   s'   |  j  |  d d d |  d f d | ƒ S(   s(  
        :doc: color method

        Creates a tint of this color by mixing it with white. `fraction` is
        the fraction of this color that is in the new color. If `fraction` is
        1.0, the color is unchanged, if 0.0, white is returned.

        The alpha channel is unchanged.
        iÿ   i   g      ð?(   R3   (   R   R6   (    (    sZ   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\color.pyt   tint]  s    c         C   s'   |  j  |  d d d |  d f d | ƒ S(   s)  
        :doc: color method

        Creates a shade of this color by mixing it with black. `fraction` is
        the fraction of this color that is in the new color. If `fraction` is
        1.0, the color is unchanged, if 0.0, black is returned.

        The alpha channel is unchanged.
        i    i   g      ð?(   R3   (   R   R6   (    (    sZ   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\color.pyt   shadej  s    c         C   s0   t  |  d |  d |  d t |  d | ƒ f ƒ S(   s‰   
        :doc: color method

        Multiplies the alpha channel of this color by `opacity`, and returns
        the new color.
        i    i   i   i   (   R    R   (   R   t   opacity(    (    sZ   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\color.pyR>   w  s
    c         C   s?   |  j  \ } } } | | d } t d | | | f d |  j ƒ S(   sÉ   
        :doc: color method

        Rotates this color's hue by `rotation`, and returns the new Color. `rotation`
        is a fraction of a full rotation, to convert degrees divide by 360.0.
        g      ð?R   R   (   R   R    R   (   R   t   rotationt   ht   lt   s(    (    sZ   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\color.pyt
   rotate_hue…  s    c         C   s7   |  j  \ } } } | } t d | | | f d |  j ƒ S(   s—   
        :doc: color method

        Replaces this color's hue with `hue`, which should be between 0.0 and
        1.0. Returns the new Color.
        R   R   (   R   R    R   (   R   t   huet   _RA   RB   R@   (    (    sZ   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\color.pyt   replace_hue‘  s    c         C   sD   |  j  \ } } } t | | d ƒ } t d | | | f d |  j ƒ S(   sº   
        :doc: color method

        Multiplies this color's saturation by `saturation`, and returns
        the result as a new Color. This is performed in the HLS color space.
        g      ð?R   R   (   R   R%   R    R   (   R   t
   saturationR@   RA   RB   (    (    sZ   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\color.pyt   multiply_hls_saturation  s    c         C   sD   |  j  \ } } } t | | d ƒ } t d | | | f d |  j ƒ S(   sº   
        :doc: color method

        Multiplies this color's saturation by `saturation`, and returns
        the result as a new Color. This is performed in the HSV color space.
        g      ð?R   R   (   R   R%   R    R   (   R   RG   R@   RB   t   v(    (    sZ   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\color.pyt   multiply_hsv_saturation©  s    c         C   sD   |  j  \ } } } t | | d ƒ } t d | | | f d |  j ƒ S(   s®   
        :doc: color method

        Multiples this color's value by `value` and returns the result as a
        new Color. This is performed in the HSV color space.
        g      ð?R   R   (   R   R%   R    R   (   R   t   valueR@   RB   RI   (    (    sZ   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\color.pyt   multiply_valueµ  s    c         C   s7   |  j  \ } } } | } t d | | | f d |  j ƒ S(   sº   
        :doc: color method

        Replaces this color's saturation with `saturation`, and returns
        the result as a new Color. This is performed in the HLS color space.
        R   R   (   R   R    R   (   R   RG   R@   RA   RE   RB   (    (    sZ   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\color.pyt   replace_hls_saturationÁ  s    c         C   s7   |  j  \ } } } | } t d | | | f d |  j ƒ S(   s¹   
        :doc: color method

        Replace this color's saturation with `saturation`, and returns
        the result as a new Color. This is performed in the HSV color space.
        R   R   (   R   R    R   (   R   RG   R@   RE   RI   RB   (    (    sZ   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\color.pyt   replace_hsv_saturationÍ  s    c         C   s7   |  j  \ } } } | } t d | | | f d |  j ƒ S(   s¯   
        :doc: color method

        Replaces this color's value with `value` and returns the result as a
        new Color. This is performed in the HSV color space.
        R   R   (   R   R    R   (   R   RK   R@   RB   RE   RI   (    (    sZ   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\color.pyt   replace_valueÙ  s    c         C   s7   |  j  \ } } } | } t d | | | f d |  j ƒ S(   s¸   
        :doc: color method

        Replaces this color's lightness with `lightness`, and returns
        the result as a new Color. This is performed in the HLS color space.
        R   R   (   R   R    R   (   R   t	   lightnessR@   RE   RB   RA   (    (    sZ   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\color.pyt   replace_lightnesså  s    c         C   s=   t  t | d ƒ d ƒ } t |  d |  d |  d f d | ƒS(   s   
        :doc: color method

        Replaces this color's alpha channel with `opacity`, and
        returns the result as a new Color.
        g        g      ð?i    i   i   R   (   R%   R$   R    (   R   R>   R   (    (    sZ   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\color.pyt   replace_opacityñ  s    N()   t   __name__t
   __module__t   __doc__R   R   R   R   R   R   t   propertyR   R    R!   R   R   R   R   R&   R(   t   __radd__R)   R*   R2   t   __rmul__R3   R9   R:   R;   R<   R=   R>   RC   RF   RH   RJ   RL   RM   RN   RO   RQ   RR   (    (    (    sZ   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\color.pyR       sJ   RF																										(   t   renpy.displayR-   R
   R   R    (    (    (    sZ   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\color.pyt   <module>   s   