ó
 m[c           @` s>  d  Z  d d l m Z m Z m Z m Z d d l Z d d l m Z d d l	 m
 Z d d l	 m Z d d l	 m 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 e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d S(   u¯   
Defines classes for path effects. The path effects are supported in
:class:`~matplotlib.text.Text`, :class:`~matplotlib.lines.Line2D`
and :class:`~matplotlib.patches.Patch`.
i    (   t   absolute_importt   divisiont   print_functiont   unicode_literalsN(   t   RendererBase(   t   colors(   t   patches(   t
   transformst   AbstractPathEffectc           B` s8   e  Z d  Z d d „ Z d „  Z d „  Z d d „ Z RS(   uƒ   
    A base class for path effects.

    Subclasses should override the ``draw_path`` method to add effect
    functionality.

    g        c         C` s   | |  _  t j ƒ  |  _ d S(   u   
        Parameters
        ----------
        offset : pair of floats
            The offset to apply to the path, measured in points.
        N(   t   _offsett   mtransformst   Affine2Dt   _offset_trans(   t   selft   offset(    (    s5   lib/python2.7/site-packages/matplotlib/patheffects.pyt   __init__   s    	c         C` sI   | j  |  j d ƒ } | j  |  j d ƒ } | |  j j ƒ  j | | ƒ S(   u(   Apply the offset to the given transform.i    i   (   t   points_to_pixelsR	   R   t   cleart	   translate(   R   t   renderert	   transformt   offset_xt   offset_y(    (    s5   lib/python2.7/site-packages/matplotlib/patheffects.pyt   _offset_transform$   s    c         C` sœ   | j  ƒ  } | j d d ƒ } | r4 | j |   n  xa t j | ƒ D]P \ } } t | d | d ƒ } t | ƒ sŠ t d j	 | ƒ ƒ ‚ n  | | ƒ qD W| S(   uÆ   
        Update the given GraphicsCollection with the given
        dictionary of properties. The keys in the dictionary are used to
        identify the appropriate set_ method on the gc.

        u   dashesu   set_u   Unknown property {0}N(
   t   copyt   popt   Nonet
   set_dashest   sixt	   iteritemst   getattrt   callablet   AttributeErrort   format(   R   t   gct   new_gc_dictt   dashest   kt   vt
   set_method(    (    s5   lib/python2.7/site-packages/matplotlib/patheffects.pyt
   _update_gc+   s    c         C` s1   t  | t ƒ r | j } n  | j | | | | ƒ S(   uÆ   
        Derived should override this method. The arguments are the same
        as :meth:`matplotlib.backend_bases.RendererBase.draw_path`
        except the first argument is a renderer.

        (   t
   isinstancet   PathEffectRenderert	   _renderert	   draw_path(   R   R   R"   t   tpatht   affinet   rgbFace(    (    s5   lib/python2.7/site-packages/matplotlib/patheffects.pyR,   ?   s    (   g        g        N(   t   __name__t
   __module__t   __doc__R   R   R(   R   R,   (    (    (    s5   lib/python2.7/site-packages/matplotlib/patheffects.pyR      s
   
		R*   c           B` sb   e  Z d  Z d „  Z d „  Z d „  Z d
 d „ Z d „  Z d „  Z	 d „  Z
 d „  Z d	 „  Z RS(   ux  
    Implements a Renderer which contains another renderer.

    This proxy then intercepts draw calls, calling the appropriate
    :class:`AbstractPathEffect` draw method.

    .. note::
        Not all methods have been overridden on this RendererBase subclass.
        It may be necessary to add further methods to extend the PathEffects
        capabilities further.

    c         C` s   | |  _  | |  _ d S(   u÷   
        Parameters
        ----------
        path_effects : iterable of :class:`AbstractPathEffect`
            The path effects which this renderer represents.
        renderer : :class:`matplotlib.backend_bases.RendererBase` instance

        N(   t   _path_effectsR+   (   R   t   path_effectsR   (    (    s5   lib/python2.7/site-packages/matplotlib/patheffects.pyR   Y   s    		c         C` s   |  j  j ƒ  S(   N(   R+   t   new_gc(   R   (    (    s5   lib/python2.7/site-packages/matplotlib/patheffects.pyR5   e   s    c         C` s   |  j  | |  j ƒ S(   N(   t	   __class__R+   (   R   R4   (    (    s5   lib/python2.7/site-packages/matplotlib/patheffects.pyt   copy_with_path_effecth   s    c         C` s4   x- |  j  D]" } | j |  j | | | | ƒ q
 Wd  S(   N(   R3   R,   R+   (   R   R"   R-   R.   R/   t   path_effect(    (    s5   lib/python2.7/site-packages/matplotlib/patheffects.pyR,   k   s    c   	      O` sz   t  |  j ƒ d k r4 t j |  | | | | | | Ž Sx? |  j D]4 } |  j | g ƒ } | j | | | | | | Ž q> Wd  S(   Ni   (   t   lenR3   R   t   draw_markersR7   (	   R   R"   t   marker_patht   marker_transt   patht   argst   kwargsR8   R   (    (    s5   lib/python2.7/site-packages/matplotlib/patheffects.pyR:   p   s    	c         O` st   t  |  j ƒ d k r1 t j |  | | | | | Ž Sx< |  j D]1 } |  j | g ƒ } | j | | | | | Ž q; Wd  S(   Ni   (   R9   R3   R   t   draw_path_collectionR7   (   R   R"   t   master_transformt   pathsR>   R?   R8   R   (    (    s5   lib/python2.7/site-packages/matplotlib/patheffects.pyR@   ƒ   s    
c         C` s   |  j  j | ƒ S(   N(   R+   R   (   R   t   points(    (    s5   lib/python2.7/site-packages/matplotlib/patheffects.pyR   –   s    c         C` sZ   |  j  | | | | | | ƒ \ } }	 | j ƒ  }
 | j d ƒ |  j | | |	 d |
 ƒd  S(   Ng        R/   (   t   _get_text_path_transformt   get_rgbt   set_linewidthR,   (   R   R"   t   xt   yt   st   propt   anglet   ismathR=   R   t   color(    (    s5   lib/python2.7/site-packages/matplotlib/patheffects.pyt   _draw_text_as_path™   s
    c         C` s0   | d k r t  |  j | ƒ St j |  | ƒ Sd  S(   Nu
   _text2pathu   flipyu   heightu   width(   u
   _text2pathu   flipyu   heightu   width(   R   R+   t   objectt   __getattribute__(   R   t   name(    (    s5   lib/python2.7/site-packages/matplotlib/patheffects.pyRP   ¡   s    N(   R0   R1   R2   R   R5   R7   R   R,   R:   R@   R   RN   RP   (    (    (    s5   lib/python2.7/site-packages/matplotlib/patheffects.pyR*   L   s   							t   Normalc           B` s   e  Z d  Z RS(   uŽ   
    The "identity" PathEffect.

    The Normal PathEffect's sole purpose is to draw the original artist with
    no special path effect.
    (   R0   R1   R2   (    (    (    s5   lib/python2.7/site-packages/matplotlib/patheffects.pyRR   ¨   s   t   Strokec           B` s#   e  Z d  Z d d „ Z d „  Z RS(   u0   A line based PathEffect which re-draws a stroke.i    c         K` s#   t  t |  ƒ j | ƒ | |  _ d S(   u±   
        The path will be stroked with its gc updated with the given
        keyword arguments, i.e., the keyword arguments should be valid
        gc parameter values.
        N(   t   superRS   R   t   _gc(   R   R   R?   (    (    s5   lib/python2.7/site-packages/matplotlib/patheffects.pyR   ´   s    c         C` sd   | j  ƒ  } | j | ƒ |  j | |  j ƒ } |  j | | ƒ } | j | | | | ƒ | j ƒ  d S(   u0   
        draw the path with updated gc.
        N(   R5   t   copy_propertiesR(   RU   R   R,   t   restore(   R   R   R"   R-   R.   R/   t   gc0t   trans(    (    s5   lib/python2.7/site-packages/matplotlib/patheffects.pyR,   ½   s    (   i    i    (   R0   R1   R2   R   R,   (    (    (    s5   lib/python2.7/site-packages/matplotlib/patheffects.pyRS   ²   s   	t
   withStrokec           B` s   e  Z d  Z d „  Z RS(   uy   
    Adds a simple :class:`Stroke` and then draws the
    original Artist to avoid needing to call :class:`Normal`.

    c         C` s6   t  j |  | | | | | ƒ | j | | | | ƒ d  S(   N(   RS   R,   (   R   R   R"   R-   R.   R/   (    (    s5   lib/python2.7/site-packages/matplotlib/patheffects.pyR,   Ò   s    (   R0   R1   R2   R,   (    (    (    s5   lib/python2.7/site-packages/matplotlib/patheffects.pyRZ   Ì   s   t   SimplePatchShadowc           B` s,   e  Z d  Z d d d d d „ Z d „  Z RS(   u#   A simple shadow via a filled patch.i   iþÿÿÿg333333Ó?c         K` sƒ   t  t |  ƒ j | ƒ | d k r. | |  _ n t j | ƒ |  _ | d k rU d } n  | |  _ | |  _ | |  _	 t
 j ƒ  |  _ d S(   u•  
        Parameters
        ----------
        offset : pair of floats
            The offset of the shadow in points.
        shadow_rgbFace : color
            The shadow color.
        alpha : float
            The alpha transparency of the created shadow patch.
            Default is 0.3.
            http://matplotlib.1069221.n5.nabble.com/path-effects-question-td27630.html
        rho : float
            A scale factor to apply to the rgbFace color if `shadow_rgbFace`
            is not specified. Default is 0.3.
        **kwargs
            Extra keywords are stored and passed through to
            :meth:`AbstractPathEffect._update_gc`.

        g333333Ó?N(   RT   R[   R   R   t   _shadow_rgbFacet   mcolorst   to_rgbat   _alphat   _rhoRU   R
   R   t   _offset_tran(   R   R   t   shadow_rgbFacet   alphat   rhoR?   (    (    s5   lib/python2.7/site-packages/matplotlib/patheffects.pyR   Ù   s    				c         C` sæ   |  j  | | ƒ } | j ƒ  } | j | ƒ |  j d k rz | pC d d  \ } }	 }
 | |  j |	 |  j |
 |  j f } n	 |  j } | j d ƒ | j |  j ƒ | j	 d ƒ |  j
 | |  j ƒ } | j | | | | ƒ | j ƒ  d S(   u€   
        Overrides the standard draw_path to add the shadow offset and
        necessary color changes for the shadow.

        g      ð?i   u   nonei    N(   g      ð?g      ð?g      ð?(   R   R5   RV   R\   R   R`   t   set_foregroundt	   set_alphaR_   RF   R(   RU   R,   RW   (   R   R   R"   R-   R.   R/   t   affine0RX   t   rt   gt   bRb   (    (    s5   lib/python2.7/site-packages/matplotlib/patheffects.pyR,     s    '	(   i   iþÿÿÿN(   R0   R1   R2   R   R   R,   (    (    (    s5   lib/python2.7/site-packages/matplotlib/patheffects.pyR[   ×   s
   (t   withSimplePatchShadowc           B` s   e  Z d  Z d „  Z RS(   u„   
    Adds a simple :class:`SimplePatchShadow` and then draws the
    original Artist to avoid needing to call :class:`Normal`.

    c         C` s6   t  j |  | | | | | ƒ | j | | | | ƒ d  S(   N(   R[   R,   (   R   R   R"   R-   R.   R/   (    (    s5   lib/python2.7/site-packages/matplotlib/patheffects.pyR,   $  s    (   R0   R1   R2   R,   (    (    (    s5   lib/python2.7/site-packages/matplotlib/patheffects.pyRk     s   t   SimpleLineShadowc           B` s,   e  Z d  Z d d d d d „ Z d „  Z RS(   u   A simple shadow via a line.i   iþÿÿÿu   kg333333Ó?c         K` sn   t  t |  ƒ j | ƒ | d k r. | |  _ n t j | ƒ |  _ | |  _ | |  _ | |  _	 t
 j ƒ  |  _ d S(   u½  
        Parameters
        ----------
        offset : pair of floats
            The offset to apply to the path, in points.
        shadow_color : color
            The shadow color. Default is black.
            A value of ``None`` takes the original artist's color
            with a scale factor of `rho`.
        alpha : float
            The alpha transparency of the created shadow patch.
            Default is 0.3.
        rho : float
            A scale factor to apply to the rgbFace color if `shadow_rgbFace`
            is ``None``. Default is 0.3.
        **kwargs
            Extra keywords are stored and passed through to
            :meth:`AbstractPathEffect._update_gc`.

        N(   RT   Rl   R   R   t   _shadow_colorR]   R^   R_   R`   RU   R
   R   Ra   (   R   R   t   shadow_colorRc   Rd   R?   (    (    s5   lib/python2.7/site-packages/matplotlib/patheffects.pyR   +  s    			c         C` så   |  j  | | ƒ } | j ƒ  } | j | ƒ |  j d k r€ | j ƒ  pI d d  \ } }	 }
 | |  j |	 |  j |
 |  j f } n	 |  j } d } | j | ƒ | j |  j	 ƒ |  j
 | |  j ƒ } | j | | | | ƒ | j ƒ  d S(   u€   
        Overrides the standard draw_path to add the shadow offset and
        necessary color changes for the shadow.

        g      ð?i   N(   g      ð?g      ð?g      ð?(   R   R5   RV   Rm   R   t   get_foregroundR`   Re   Rf   R_   R(   RU   R,   RW   (   R   R   R"   R-   R.   R/   Rg   RX   Rh   Ri   Rj   Rb   t
   fill_color(    (    s5   lib/python2.7/site-packages/matplotlib/patheffects.pyR,   P  s    '	(   i   iþÿÿÿ(   R0   R1   R2   R   R,   (    (    (    s5   lib/python2.7/site-packages/matplotlib/patheffects.pyRl   )  s   $t   PathPatchEffectc           B` s#   e  Z d  Z d d „ Z d „  Z RS(   u|   
    Draws a :class:`~matplotlib.patches.PathPatch` instance whose Path
    comes from the original PathEffect artist.

    i    c         K` s2   t  t |  ƒ j d | ƒ t j g  |  |  _ d S(   uŒ  
        Parameters
        ----------
        offset : pair of floats
            The offset to apply to the path, in points.
        **kwargs :
            All keyword arguments are passed through to the
            :class:`~matplotlib.patches.PathPatch` constructor. The
            properties which cannot be overridden are "path", "clip_box"
            "transform" and "clip_path".
        R   N(   RT   Rq   R   t   mpatchest	   PathPatcht   patch(   R   R   R?   (    (    s5   lib/python2.7/site-packages/matplotlib/patheffects.pyR   r  s    c         C` s}   |  j  | | ƒ } | |  j _ |  j j | ƒ |  j j | j ƒ  ƒ | j ƒ  } | ri |  j j | Œ  n  |  j j | ƒ d  S(   N(	   R   Rt   t   _patht   set_transformt   set_clip_boxt   get_clip_rectanglet   get_clip_patht   set_clip_patht   draw(   R   R   R"   R-   R.   R/   t	   clip_path(    (    s5   lib/python2.7/site-packages/matplotlib/patheffects.pyR,     s    (   i    i    (   R0   R1   R2   R   R,   (    (    (    s5   lib/python2.7/site-packages/matplotlib/patheffects.pyRq   l  s   (   R2   t
   __future__R    R   R   R   R   t   matplotlib.backend_basesR   t
   matplotlibR   R]   R   Rr   R   R
   RO   R   R*   RR   RS   RZ   R[   Rk   Rl   Rq   (    (    (    s5   lib/python2.7/site-packages/matplotlib/patheffects.pyt   <module>   s   ":\
GC