Ñò
t,2Jc        
   @   s»   d  Z  d d k Z d d k l Z d d k Z d d k l Z d d k l Z l	 Z	 l
 Z
 l Z l Z l Z l Z d d k l Z d d k l Z d e f d	 „  ƒ  YZ e Z d
 „  Z d S(   s2   
Contains a class for managing paths (polylines).
iÿÿÿÿN(   t   WeakValueDictionary(   t   ma(   t   point_in_patht   get_path_extentst   point_in_path_collectiont   get_path_collection_extentst   path_in_patht   path_intersects_patht   convert_path_to_polygons(   t   simple_linear_interpolation(   t   rcParamst   Pathc           B   s¯  e  Z d  Z d Z d Z d Z d Z d Z d Z d d d d d d g Z	 e
 i Z d d „ Z d „  Z e e ƒ Z d	 „  Z d
 „  Z d d „ Z d „  Z d d „ Z d d „ Z d d „ Z e d „ Z e d „ Z d „  Z d d d d „ Z d Z d „  Z e e ƒ Z e  ƒ  Z! d „  Z" e e" ƒ Z" e  ƒ  Z# d d „ Z$ e e$ ƒ Z$ d „  Z% e e% ƒ Z% d Z& d „  Z' e e' ƒ Z' d e( d „ Z) e e) ƒ Z) d d „ Z* e e* ƒ Z* RS(   s~  
    :class:`Path` represents a series of possibly disconnected,
    possibly closed, line and curve segments.

    The underlying storage is made up of two parallel numpy arrays:
      - *vertices*: an Nx2 float array of vertices
      - *codes*: an N-length uint8 array of vertex types

    These two arrays always have the same length in the first
    dimension.  For example, to represent a cubic curve, you must
    provide three vertices as well as three codes ``CURVE3``.

    The code types are:

       - ``STOP``   :  1 vertex (ignored)
           A marker for the end of the entire path (currently not
           required and ignored)

       - ``MOVETO`` :  1 vertex
            Pick up the pen and move to the given vertex.

       - ``LINETO`` :  1 vertex
            Draw a line from the current position to the given vertex.

       - ``CURVE3`` :  1 control point, 1 endpoint
          Draw a quadratic Bezier curve from the current position,
          with the given control point, to the given end point.

       - ``CURVE4`` :  2 control points, 1 endpoint
          Draw a cubic Bezier curve from the current position, with
          the given control points, to the given end point.

       - ``CLOSEPOLY`` : 1 vertex (ignored)
          Draw a line segment to the start point of the current
          polyline.

    Users of Path objects should not access the vertices and codes
    arrays directly.  Instead, they should use :meth:`iter_segments`
    to get the vertex/code pairs.  This is important, since many
    :class:`Path` objects, as an optimization, do not store a *codes*
    at all, but have a default one provided for them by
    :meth:`iter_segments`.

    Note also that the vertices and codes arrays should be treated as
    immutable -- there are a number of optimizations and assumptions
    made up front in the constructor that will not change when the
    data changes.
    i    i   i   i   i   i   c         C   sK  t  i | ƒ o" | i t i ƒ i t i ƒ } n t i | t i ƒ } | d j	 oP t i | |  i	 ƒ } | i
 d j p t ‚ t | ƒ t | ƒ j p t ‚ n | i
 d j p t ‚ | i d d j p t ‚ t d o6 t | ƒ d j o# | d j p t i | t i j ƒ |  _ t i | ƒ i ƒ  |  _ | |  _ | |  _ d S(   s©  
        Create a new path with the given vertices and codes.

        *vertices* is an Nx2 numpy float array, masked array or Python
        sequence.

        *codes* is an N-length numpy array or Python sequence of type
        :attr:`matplotlib.path.Path.code_type`.

        These two arrays must have the same length in the first
        dimension.

        If *codes* is None, *vertices* will be treated as a series of
        line segments.

        If *vertices* contains masked values, they will be converted
        to NaNs which are then handled correctly by the Agg
        PathIterator and other consumers of path data, such as
        :meth:`iter_segments`.
        i   i   s   path.simplifyi€   N(   R   t   isMaskedArrayt   astypet   npt   float_t   filledt   nant   asarrayt   Nonet	   code_typet   ndimt   AssertionErrort   lent   shapeR
   t   allR   t   LINETOt   should_simplifyt   isfinitet   has_nonfinitet   codest   vertices(   t   selfR   R   (    (    s?   P:\graphics\Tools\Python26\lib\site-packages\matplotlib\path.pyt   __init__O   s    "$(	c          G   sì   x% |  D] } | i  d j p t ‚ q Wg  } |  D] } | t | ƒ q3 ~ } t | ƒ } t i g  } |  D] } | | i ql ~ ƒ } | i | d f ƒ t	 i
 t i | ƒ } d }	 x% | D] }
 t	 i | |	 <|	 |
 7}	 q¾ Wt	 | | ƒ S(   s…   
        (staticmethod) Make a compound path from a list of Path
        objects.  Only polygons (not curves) are supported.
        i   i    N(   R   R   R   R   t   sumR   t   vstackR   t   reshapeR   R   t   onest   MOVETO(   t   argst   pt   _[1]t   xt   lengthst   total_lengtht   _[2]R   R   t   it   length(    (    s?   P:\graphics\Tools\Python26\lib\site-packages\matplotlib\path.pyt   make_compound_pathy   s     '- c         C   s   d |  i  |  i f S(   Ns   Path(%s, %s)(   R   R   (   R    (    (    s?   P:\graphics\Tools\Python26\lib\site-packages\matplotlib\path.pyt   __repr__   s    c         C   s   t  |  i ƒ S(   N(   R   R   (   R    (    (    s?   P:\graphics\Tools\Python26\lib\site-packages\matplotlib\path.pyt   __len__“   s    c         c   sT  |  i  } t | ƒ p d S|  i } t | ƒ } t i } |  i } |  i } |  i } |  i }	 |  i	 }
 | d j	 o` |  i oV |  i d | Œ } x¾| D]5 } | d | f Vx | d D] } | | f Vq¶ Wq– Wn~| d j o‰ |  i oL | } xr | D]7 } t i | ƒ i ƒ  o | | f V| } q÷ | } q÷ WqP| d | f Vx| d D] } | | f VqPWnè d } t } xØ | | j  oÊ | | } | |	 j o g  | f V| d 7} qx| |
 j o d S| t | ƒ } | | | | !i ƒ  } | | ƒ i ƒ  p
 t } n7 | o$ | d  | f V| | f Vt } n | | f V| | 7} qxWd S(   s  
        Iterates over all of the curve segments in the path.  Each
        iteration returns a 2-tuple (*vertices*, *code*), where
        *vertices* is a sequence of 1 - 3 coordinate pairs, and *code* is
        one of the :class:`Path` codes.

        If *simplify* is provided, it must be a tuple (*width*,
        *height*) defining the size of the figure, in native units
        (e.g. pixels or points).  Simplification implies both removing
        adjacent line segments that are very close to parallel, and
        removing line segments outside of the figure.  The path will
        be simplified *only* if :attr:`should_simplify` is True, which
        is determined in the constructor by this criteria:

           - No curves
           - More than 128 vertices
        Ni    i   i   (   R   R   R   R   R   t   NUM_VERTICESR&   R   t	   CLOSEPOLYt   STOPR   R   t   to_polygonsR   R   t   Falset   intt   flattent   True(   R    t   simplifyR   R   t   len_verticesR   R3   R&   R   R4   R5   t   polygonst   vt	   next_codeR.   t   was_nant   codet   num_verticest   curr_vertices(    (    s?   P:\graphics\Tools\Python26\lib\site-packages\matplotlib\path.pyt   iter_segments–   sh    								  
 
  


c         C   s   t  | i |  i ƒ |  i ƒ S(   s/  
        Return a transformed copy of the path.

        .. seealso::
            :class:`matplotlib.transforms.TransformedPath`:
                A specialized path class that will cache the
                transformed result and automatically update when the
                transform changes.
        (   R   t	   transformR   R   (   R    RE   (    (    s?   P:\graphics\Tools\Python26\lib\site-packages\matplotlib\path.pyt   transformedà   s    
c         C   s8   | d j	 o | i ƒ  } n t | d | d |  | ƒ S(   s®   
        Returns *True* if the path contains the given point.

        If *transform* is not *None*, the path will be transformed
        before performing the test.
        i    i   N(   R   t   frozenR   (   R    t   pointRE   (    (    s?   P:\graphics\Tools\Python26\lib\site-packages\matplotlib\path.pyt   contains_pointì   s    c         C   s0   | d j	 o | i ƒ  } n t |  d | | ƒ S(   s¹   
        Returns *True* if this path completely contains the given path.

        If *transform* is not *None*, the path will be transformed
        before performing the test.
        N(   R   RG   R   (   R    t   pathRE   (    (    s?   P:\graphics\Tools\Python26\lib\site-packages\matplotlib\path.pyt   contains_path÷   s    c         C   s@   d d k  l } | d j	 o | i ƒ  } n | t |  | ƒ ƒ S(   s  
        Returns the extents (*xmin*, *ymin*, *xmax*, *ymax*) of the
        path.

        Unlike computing the extents on the *vertices* alone, this
        algorithm will take into account the curves and deal with
        control points appropriately.
        iÿÿÿÿ(   t   BboxN(   t
   transformsRL   R   RG   R   (   R    RE   RL   (    (    s?   P:\graphics\Tools\Python26\lib\site-packages\matplotlib\path.pyt   get_extents  s    	c         C   s   t  |  | | ƒ S(   s  
        Returns *True* if this path intersects another given path.

        *filled*, when True, treats the paths as if they were filled.
        That is, if one path completely encloses the other,
        :meth:`intersects_path` will return True.
        (   R   (   R    t   otherR   (    (    s?   P:\graphics\Tools\Python26\lib\site-packages\matplotlib\path.pyt   intersects_path  s    c         C   sA   d d k  l } |  i ƒ  i | | ƒ ƒ } |  i | | ƒ } | S(   s  
        Returns *True* if this path intersects a given
        :class:`~matplotlib.transforms.Bbox`.

        *filled*, when True, treats the path as if it was filled.
        That is, if one path completely encloses the other,
        :meth:`intersects_path` will return True.
        iÿÿÿÿ(   t   BboxTransformTo(   RM   RQ   t   unit_rectangleRF   RP   (   R    t   bboxR   RQ   t	   rectanglet   result(    (    s?   P:\graphics\Tools\Python26\lib\site-packages\matplotlib\path.pyt   intersects_bbox  s
    	c         C   s}   t  |  i | ƒ } |  i } | d j	 oB t i t i t | ƒ d | d f ƒ } | | d d | … <n d } t | | ƒ S(   s|   
        Returns a new path resampled to length N x steps.  Does not
        currently handle interpolating curves.
        i   i    N(	   R	   R   R   R   R   R   R   R%   R   (   R    t   stepsR   R   t	   new_codes(    (    s?   P:\graphics\Tools\Python26\lib\site-packages\matplotlib\path.pyt   interpolated)  s    	+c         C   s¤   t  |  i ƒ d j o g  S| d j	 o | i ƒ  } n |  i d j oI | d j p | d j o/ | d j o |  i g S| i |  i ƒ g Sn t |  | | | ƒ S(   sä  
        Convert this path to a list of polygons.  Each polygon is an
        Nx2 array of vertices.  In other words, each polygon has no
        ``MOVETO`` instructions or curves.  This is useful for
        displaying in backends that do not support compound paths or
        Bezier curves, such as GDK.

        If *width* and *height* are both non-zero then the lines will
        be simplified so that vertices outside of (0, 0), (width,
        height) will be clipped.
        i    N(   R   R   R   RG   R   RE   R   (   R    RE   t   widtht   height(    (    s?   P:\graphics\Tools\Python26\lib\site-packages\matplotlib\path.pyR6   7  s    *c         C   sW   |  i  d j o@ t d d g d d g d d g d d g d d g g ƒ |  _  n |  i  S(   sm   
        (staticmethod) Returns a :class:`Path` of the unit rectangle
        from (0, 0) to (1, 1).
        g        g      ð?N(   t   _unit_rectangleR   R   (   t   cls(    (    s?   P:\graphics\Tools\Python26\lib\site-packages\matplotlib\path.pyRR   U  s    @c         C   sÇ   | d j o |  i  i | ƒ } n d } | d j o d t i | t i | d ƒ i | d d f ƒ } | t i d 7} t i t i | ƒ t i	 | ƒ f d ƒ } t
 | ƒ } | |  i  | <n | S(   s§   
        (staticmethod) Returns a :class:`Path` for a unit regular
        polygon with the given *numVertices* and radius of 1.0,
        centered at (0, 0).
        i   i   i   g       @N(   t   _unit_regular_polygonst   getR   R   t   pit   arangeR$   t   concatenatet   cost   sinR   (   R]   t   numVerticesRJ   t   thetat   verts(    (    s?   P:\graphics\Tools\Python26\lib\site-packages\matplotlib\path.pyt   unit_regular_polygonb  s    '*g      à?c         C   sû   | d j o |  i  i | | f ƒ } n d } | d j o» | d } d t i | t i | d ƒ } | t i d 7} t i | d ƒ } | | d d d … <t i | t i | ƒ | t i	 | ƒ f ƒ i
 ƒ  } t | ƒ } | |  i | | f <n | S(   s¢   
        (staticmethod) Returns a :class:`Path` for a unit regular star
        with the given numVertices and radius of 1.0, centered at (0,
        0).
        i   i   i   g       @N(   t   _unit_regular_starsR_   R   R   R`   Ra   R%   R#   Rc   Rd   t	   transposeR   R^   (   R]   Re   t   innerCircleRJ   t   ns2Rf   t   rRg   (    (    s?   P:\graphics\Tools\Python26\lib\site-packages\matplotlib\path.pyt   unit_regular_starz  s    
"5c         C   s   |  i  | d ƒ S(   s¦   
        (staticmethod) Returns a :class:`Path` for a unit regular
        asterisk with the given numVertices and radius of 1.0,
        centered at (0, 0).
        g        (   Rn   (   R]   Re   (    (    s?   P:\graphics\Tools\Python26\lib\site-packages\matplotlib\path.pyt   unit_regular_asterisk“  s    c         C   sØ  |  i  d
 j oÁd } t i d ƒ } t i | | d ƒ } t i d d g | d g | | | | g | | g | | | | g d | g d d g d | g | | | | g | | g | | | | g | d g d d g | d g | | | | g | | g | | | | g d | g d d g d | g | | | | g | | g | | | | g | d g d d g d d g g t i ƒ } |  i t i d ƒ } |  i | d <|  i	 | d	 <t
 | | ƒ |  _  n |  i  S(   s}  
        (staticmethod) Returns a :class:`Path` of the unit circle.
        The circle is approximated using cubic Bezier curves.  This
        uses 8 splines around the circle using the approach presented
        here:

          Lancaster, Don.  `Approximating a Circle or an Ellipse Using Four
          Bezier Cubic Splines <http://www.tinaja.com/glib/ellipse4.pdf>`_.
        grSlùÐ?g      à?g       @g        g      ð¿g      ð?i   i    iÿÿÿÿN(   t   _unit_circleR   R   t   sqrtt   arrayR   t   CURVE4R%   R&   R4   R   (   R]   t   MAGICt   SQRTHALFt   MAGIC45R   R   (    (    s?   P:\graphics\Tools\Python26\lib\site-packages\matplotlib\path.pyt   unit_circlež  sJ    
		

					

		

	c      	   C   së  | t  i d 9} | t  i d 9} t  i d } t  i d } t  i t  i | ƒ t  i | ƒ ƒ } t  i t  i | ƒ t  i | ƒ ƒ } | | t  i | | | ƒ 8} | | t  i j o" | | t  i j  o | | 7} n | d j o% t d t  i | | | ƒ ƒ } n | d j  o t	 d ƒ ‚ n | | | }	 t  i
 d |	 ƒ }
 t  i |	 ƒ t  i d d |
 |
 ƒ d d } t  i | | | d t ƒ } t  i | ƒ } t  i | ƒ } | d	  } | d	  } | } | } | d } | d } | } | } | o£ | d
 d } t  i | d f t  i ƒ } t i t  i | f t i ƒ } | d | d g | d <t i t i g | d d +t i t i g | d )d } | d } nz | d
 d } t  i | d f t  i ƒ } t i t  i | f t i ƒ } | d | d g | d <t i | d <d } | } | | | | | | d
 … d f <| | | | | | d
 … d f <| | | | | d | d
 … d f <| | | | | d | d
 … d f <| | | d | d
 … d f <| | | d | d
 … d f <t | | ƒ S(   s  
        (staticmethod) Returns an arc on the unit circle from angle
        *theta1* to angle *theta2* (in degrees).

        If *n* is provided, it is the number of spline segments to make.
        If *n* is not provided, the number of spline segments is
        determined based on the delta between *theta1* and *theta2*.

           Masionobe, L.  2003.  `Drawing an elliptical arc using
           polylines, quadratic or cubic Bezier curves
           <http://www.spaceroots.org/documents/ellipse/index.html>`_.
        g     €f@g       @g      à?i   i   s   n must be >= 1 or Noneg      @g      @iÿÿÿÿi   i   i    iþÿÿÿN(   R   R`   t   arctan2Rd   Rc   t   floorR   R8   t   ceilt
   ValueErrort   tanRq   t   linspaceR:   t   zerosR   R   Rs   R%   R   R&   R   R4   (   R]   t   theta1t   theta2t   nt   is_wedget   twopit   halfpit   eta1t   eta2t   detat   tt   alphaRW   t   cos_etat   sin_etat   xAt   yAt   xA_dott   yA_dott   xBt   yBt   xB_dott   yB_dotR/   R   R   t   vertex_offsett   end(    (    s?   P:\graphics\Tools\Python26\lib\site-packages\matplotlib\path.pyt   arcÜ  sd    $$(%0



!!%%c         C   s   |  i  | | | t ƒ S(   sO  
        (staticmethod) Returns a wedge of the unit circle from angle
        *theta1* to angle *theta2* (in degrees).

        If *n* is provided, it is the number of spline segments to make.
        If *n* is not provided, the number of spline segments is
        determined based on the delta between *theta1* and *theta2*.
        (   R–   R:   (   R]   R   R€   R   (    (    s?   P:\graphics\Tools\Python26\lib\site-packages\matplotlib\path.pyt   wedge+  s    	N(+   t   __name__t
   __module__t   __doc__R5   R&   R   t   CURVE3Rs   R4   R3   R   t   uint8R   R   R!   R0   t   staticmethodR1   R2   RD   RF   RI   RK   RN   R:   RP   RV   RY   R6   R\   RR   t   classmethodR    R^   Rh   Ri   Rn   Ro   Rp   Rw   R7   R–   R—   (    (    (    s?   P:\graphics\Tools\Python26\lib\site-packages\matplotlib\path.pyR      sR   0	*			J	
								;L
c          G   sJ   d d k  l } t |  d ƒ d j o t d ƒ ‚ n | i t |  Œ  Œ  S(   sp   
    Given a sequence of :class:`Path` objects, returns the bounding
    box that encapsulates all of them.
    iÿÿÿÿ(   RL   i   i    s   No paths provided(   RM   RL   R   R{   t   from_extentst   _get_path_collection_extents(   R'   RL   (    (    s?   P:\graphics\Tools\Python26\lib\site-packages\matplotlib\path.pyR   8  s    (   Rš   t   matht   weakrefR    t   numpyR   R   t   matplotlib._pathR   R   R   R   R   R   R   t   matplotlib.cbookR	   t
   matplotlibR
   t   objectR   R    (    (    (    s?   P:\graphics\Tools\Python26\lib\site-packages\matplotlib\path.pyt   <module>   s   4ÿ ÿ (