
 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	 Z
 d d l m Z m Z d d l m Z m Z m Z d e f d	     YZ d
   Z g  d  Z d S(   u  
A module for dealing with the polylines used throughout Matplotlib.

The primary class for polyline handling in Matplotlib is `Path`.  Almost all
vector drawing makes use of `Path`\s somewhere in the drawing pipeline.

Whilst a `Path` instance itself cannot be drawn, some `.Artist` subclasses,
such as `.PathPatch` and `.PathCollection`, can be used for convenient `Path`
visualisation.
i    (   t   absolute_importt   divisiont   print_functiont   unicode_literalsN(   t   WeakValueDictionaryi   (   t   _patht   rcParams(   t   _to_unmasked_float_arrayt   simple_linear_interpolationt   maxdictt   Pathc        
   B` s2  e  Z d  Z d Z d Z d Z d Z d Z d Z i d e 6d e 6d e 6d e 6d e 6d e 6Z	 e
 j Z d5 d e e d  Z e d5 d   Z d	   Z e d
    Z e j d    Z e d    Z e j d    Z e d    Z e j d    Z e d    Z e d    Z e j d    Z e d    Z d   Z e Z d5 d  Z e Z e d    Z e d    Z  d   Z! d   Z" d5 e# d5 e d d5 e# d5 d  Z$ d5 e d5 e e e d e d5 d 	 Z% d   Z& d5 d d  Z' d5 d d   Z( d5 d!  Z) d5 d"  Z* e# d#  Z+ e# d$  Z, d%   Z- d5 d d e# d&  Z. d5 Z/ e d'    Z0 e1   Z2 e d(    Z3 e1   Z4 e d) d*   Z5 e d+    Z6 d5 Z7 e d,    Z8 e d6 d e d-   Z9 d5 Z: e d.    Z; e d5 e d/   Z< e d5 d0   Z= e> d1  Z? e d2 d3   Z@ e# d4  ZA RS(7   u  
    :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`
    or :meth:`cleaned` 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`.

    Some behavior of Path objects can be controlled by rcParams. See
    the rcParams whose keys contain 'path.'.

    .. note::

        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   iO   c         C` s  t  |  } | j d k s. | j d d k r= t d   n  | d	 k	 r t j | |  j  } | j d k s t |  t |  k r t d   n  t |  r"| d |  j	 k r"t d j
 |  j	    q"nQ | r"t j t |  d |  j } |  j	 | d <|  j | d d +|  j | d <n  | |  _ | |  _ | |  _ |  j   | rt |  j j _ |  j d	 k	 r}t |  j j _ n  t |  _ n	 t |  _ d	 S(
   um  
        Create a new path with the given vertices and codes.

        Parameters
        ----------
        vertices : array_like
            The ``(n, 2)`` float array, masked array or sequence of pairs
            representing the vertices of the path.

            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`.
        codes : {None, array_like}, optional
            n-length array integers representing the codes of the path.
            If not None, codes must be the same length as vertices.
            If None, *vertices* will be treated as a series of line segments.
        _interpolation_steps : int, optional
            Used as a hint to certain projections, such as Polar, that this
            path should be linearly interpolated immediately before drawing.
            This attribute is primarily an implementation detail and is not
            intended for public use.
        closed : bool, optional
            If *codes* is None and closed is True, vertices will be treated as
            line segments of a closed polygon.
        readonly : bool, optional
            Makes the path behave in an immutable way and sets the vertices
            and codes as read-only arrays.
        i   i   u4   'vertices' must be a 2D list or array with shape Nx2uE   'codes' must be a 1D list or array with the same length of 'vertices'i    u:   The first element of 'code' must be equal to 'MOVETO' ({})t   dtypeiN(   R   t   ndimt   shapet
   ValueErrort   Nonet   npt   asarrayt	   code_typet   lent   MOVETOt   formatt   emptyt   LINETOt	   CLOSEPOLYt	   _verticest   _codest   _interpolation_stepst   _update_valuest   Falset   flagst	   writeablet   Truet	   _readonly(   t   selft   verticest   codesR   t   closedt   readonly(    (    s.   lib/python2.7/site-packages/matplotlib/path.pyt   __init__e   s4    "'				
c         C` s   | p	 i  } |  j  |   } t |  | _ | | _ | j d t  | _ | j d t  | _ | j d t	 d  | _
 | j d t  | _ | j d d  | _ | r t d j d	 j |     n  | S(
   u  
        Creates a Path instance without the expense of calling the constructor

        Parameters
        ----------
        verts : numpy array
        codes : numpy array
        internals : dict or None
            The attributes that the resulting path should have.
            Allowed keys are ``readonly``, ``should_simplify``,
            ``simplify_threshold``, ``has_nonfinite`` and
            ``interpolation_steps``.

        u   readonlyu   should_simplifyu   simplify_thresholdu   path.simplify_thresholdu   has_nonfiniteu   interpolation_stepsi   u@   Unexpected internals provided to _fast_from_codes_and_verts: {0}u   
 *(   t   __new__R   R   R   t   popR   R!   R    t   should_simplifyR   t   simplify_thresholdt   _has_nonfiniteR   R   R   t   join(   t   clst   vertsR$   t	   internalst   pth(    (    s.   lib/python2.7/site-packages/matplotlib/path.pyt   _fast_from_codes_and_verts   s    			c         C` s   t  d |  _ |  j d k ob t  d ob t |  j  d k ob |  j d  k pb t j |  j t j	 k  |  _
 t j |  j  j   |  _ d  S(   Nu   path.simplify_thresholdi    u   path.simplifyi   (   R   t   _simplify_thresholdR   R   R   R   R   t   allR
   R   t   _should_simplifyt   isfiniteR,   (   R"   (    (    s.   lib/python2.7/site-packages/matplotlib/path.pyR      s    
-c         C` s   |  j  S(   uK   
        The list of vertices in the `Path` as an Nx2 numpy array.
        (   R   (   R"   (    (    s.   lib/python2.7/site-packages/matplotlib/path.pyR#      s    c         C` s/   |  j  r t d   n  | |  _ |  j   d  S(   Nu%   Can't set vertices on a readonly Path(   R!   t   AttributeErrorR   R   (   R"   R#   (    (    s.   lib/python2.7/site-packages/matplotlib/path.pyR#      s    		c         C` s   |  j  S(   uu  
        The list of codes in the `Path` as a 1-D numpy array.  Each
        code is one of `STOP`, `MOVETO`, `LINETO`, `CURVE3`, `CURVE4`
        or `CLOSEPOLY`.  For codes that correspond to more than one
        vertex (`CURVE3` and `CURVE4`), that code will be repeated so
        that the length of `self.vertices` and `self.codes` is always
        the same.
        (   R   (   R"   (    (    s.   lib/python2.7/site-packages/matplotlib/path.pyR$      s    
c         C` s/   |  j  r t d   n  | |  _ |  j   d  S(   Nu"   Can't set codes on a readonly Path(   R!   R7   R   R   (   R"   R$   (    (    s.   lib/python2.7/site-packages/matplotlib/path.pyR$      s    		c         C` s   |  j  S(   ui   
        The fraction of a pixel difference below which vertices will
        be simplified out.
        (   R3   (   R"   (    (    s.   lib/python2.7/site-packages/matplotlib/path.pyR+      s    c         C` s   | |  _  d  S(   N(   R3   (   R"   t	   threshold(    (    s.   lib/python2.7/site-packages/matplotlib/path.pyR+      s    c         C` s   |  j  S(   uD   
        `True` if the vertices array has nonfinite values.
        (   R,   (   R"   (    (    s.   lib/python2.7/site-packages/matplotlib/path.pyt   has_nonfinite   s    c         C` s   |  j  S(   uD   
        `True` if the vertices array should be simplified.
        (   R5   (   R"   (    (    s.   lib/python2.7/site-packages/matplotlib/path.pyR*     s    c         C` s   | |  _  d  S(   N(   R5   (   R"   R*   (    (    s.   lib/python2.7/site-packages/matplotlib/path.pyR*     s    c         C` s   |  j  S(   u4   
        `True` if the `Path` is read-only.
        (   R!   (   R"   (    (    s.   lib/python2.7/site-packages/matplotlib/path.pyR&     s    c         C` s   d d l  } | j  |   S(   u   
        Returns a shallow copy of the `Path`, which will share the
        vertices and codes with the source `Path`.
        i    N(   t   copy(   R"   R:   (    (    s.   lib/python2.7/site-packages/matplotlib/path.pyt   __copy__  s    c         C` sO   y |  j  j   } Wn t k
 r, d } n X|  j |  j j   | d |  j S(   u{   
        Returns a deepcopy of the `Path`.  The `Path` will not be
        readonly, even if the source `Path` is.
        R   N(   R$   R:   R7   R   t	   __class__R#   R   (   R"   t   memoR$   (    (    s.   lib/python2.7/site-packages/matplotlib/path.pyt   __deepcopy__   s    
c   
      C` s   | j  \ } } } | d k r- t d   n  | d } | | } t j | d f  } t j | t  |  j } |  j | d d |  <|  j | | d |  <x7 t	 |  D]) }	 | d d  |	 f | |	 d |  <q W|  | |  S(   u  
        Make a compound path object to draw a number
        of polygons with equal numbers of sides XY is a (numpolys x
        numsides x 2) numpy array of vertices.  Return object is a
        :class:`Path`

        .. plot:: gallery/api/histogram_path.py

        i   u%   The third dimension of 'XY' must be 2i   i    N(
   R   R   R   t   zerost   onest   intR   R   R   t   range(
   R.   t   XYt   numpolyst   numsidest   twot   stridet   nvertsR/   R$   t   i(    (    s.   lib/python2.7/site-packages/matplotlib/path.pyt   make_compound_path_from_polys/  s    

'c   	      G` s7  | s( t  t j d d g d t j  Sg  | D] } t |  ^ q/ } t |  } t j g  | D] } | j ^ q`  } | j | d f  t j | d |  j	 } d } x~ | D]v } | j
 d k r |  j | | <|  j | | d | t | j  +n | j
 | | | t | j
  +| t | j  7} q W|  | |  S(   u1   Make a compound path from a list of Path objects.i    i   R   i   N(   R
   R   R   t   float32R   t   sumt   vstackR#   t   reshapeR   R$   R   R   R   (	   R.   t   argst   xt   lengthst   total_lengthR#   R$   RI   t   path(    (    s.   lib/python2.7/site-packages/matplotlib/path.pyt   make_compound_pathL  s    "%$c         C` s   d |  j  |  j f S(   Nu   Path(%r, %r)(   R#   R$   (   R"   (    (    s.   lib/python2.7/site-packages/matplotlib/path.pyt   __repr__e  s    c         C` s   t  |  j  S(   N(   R   R#   (   R"   (    (    s.   lib/python2.7/site-packages/matplotlib/path.pyt   __len__h  s    g      ?c	         c` s   t  |   s d S|  j d | d | d | d | d | d | d | d	 |  }	 |	 j }
 |	 j } |
 j d
 } |  j } |  j } d
 } x` | | k  r | | } | | k r d S| | } |
 | | | !j   } | | f V| | 7} q Wd S(   u  
        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.

        Additionally, this method can provide a number of standard
        cleanups and conversions to the path.

        Parameters
        ----------
        transform : None or :class:`~matplotlib.transforms.Transform` instance
            If not None, the given affine transformation will
            be applied to the path.
        remove_nans : {False, True}, optional
            If True, will remove all NaNs from the path and
            insert MOVETO commands to skip over them.
        clip : None or sequence, optional
            If not None, must be a four-tuple (x1, y1, x2, y2)
            defining a rectangle in which to clip the path.
        snap : None or bool, optional
            If None, auto-snap to pixels, to reduce
            fuzziness of rectilinear lines.  If True, force snapping, and
            if False, don't snap.
        stroke_width : float, optional
            The width of the stroke being drawn.  Needed
             as a hint for the snapping algorithm.
        simplify : None or bool, optional
            If True, perform simplification, to remove
             vertices that do not affect the appearance of the path.  If
             False, perform no simplification.  If None, use the
             should_simplify member variable.  See also the rcParams
             path.simplify and path.simplify_threshold.
        curves : {True, False}, optional
            If True, curve segments will be returned as curve
            segments.  If False, all curves will be converted to line
            segments.
        sketch : None or sequence, optional
            If not None, must be a 3-tuple of the form
            (scale, length, randomness), representing the sketch
            parameters.
        Nt	   transformt   remove_nanst   clipt   snapt   stroke_widtht   simplifyt   curvest   sketchi    (   R   t   cleanedR#   R$   R   t   NUM_VERTICES_FOR_CODEt   STOPt   flatten(   R"   RW   RX   RY   RZ   R[   R\   R]   R^   R_   R#   R$   t   len_verticesR`   Ra   RI   t   codet   num_verticest   curr_vertices(    (    s.   lib/python2.7/site-packages/matplotlib/path.pyt   iter_segmentsk  s*    -					

c
      
   C` s|   t  j |  | | | | | | | |	 	 \ }
 } i |  j o= | d 6|  j oN | d 6|  j d 6|  j d 6} t j |
 | |  S(   u&  
        Cleans up the path according to the parameters returning a new
        Path instance.

        .. seealso::

            See :meth:`iter_segments` for details of the keyword arguments.

        Returns
        -------
        Path instance with cleaned up vertices and codes.

        u   should_simplifyu   has_nonfiniteu   simplify_thresholdu   interpolation_steps(   R   t   cleanup_pathR*   R9   R+   R   R
   R2   (   R"   RW   RX   RY   t   quantizeR\   R]   R[   RZ   R^   R#   R$   R0   (    (    s.   lib/python2.7/site-packages/matplotlib/path.pyR_     s    
c         C` s"   t  | j |  j  |  j |  j  S(   u/  
        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
   RW   R#   R$   R   (   R"   RW   (    (    s.   lib/python2.7/site-packages/matplotlib/path.pyt   transformed  s    g        c         C` sd   | d k	 r | j   } n  | rC | j rC | j |   }  d } n  t j | d | d | |  |  S(   u   
        Returns whether the (closed) path contains the given point.

        If *transform* is not ``None``, the path will be transformed before
        performing the test.

        *radius* allows the path to be made slightly larger or smaller.
        i    i   N(   R   t   frozent	   is_affinet   transform_pathR   t   point_in_path(   R"   t   pointRW   t   radius(    (    s.   lib/python2.7/site-packages/matplotlib/path.pyt   contains_point  s    		c         C` s@   | d k	 r | j   } n  t j | | |  |  } | j d  S(   u*  
        Returns a bool array which is ``True`` if the (closed) path contains
        the corresponding point.

        If *transform* is not ``None``, the path will be transformed before
        performing the test.

        *radius* allows the path to be made slightly larger or smaller.
        u   boolN(   R   Rk   R   t   points_in_patht   astype(   R"   t   pointsRW   Rp   t   result(    (    s.   lib/python2.7/site-packages/matplotlib/path.pyt   contains_points  s    
c         C` s1   | d k	 r | j   } n  t j |  d | |  S(   u   
        Returns whether this (closed) path completely contains the given path.

        If *transform* is not ``None``, the path will be transformed before
        performing the test.
        N(   R   Rk   R   t   path_in_path(   R"   RS   RW   (    (    s.   lib/python2.7/site-packages/matplotlib/path.pyt   contains_path  s    c         C` sh   d d l  m } |  } | d k	 rR | j   } | j sR |  j |  } d } qR n  | t j | |   S(   u  
        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
   transformsRy   R   Rk   Rl   Rj   R   t   get_path_extents(   R"   RW   Ry   RS   (    (    s.   lib/python2.7/site-packages/matplotlib/path.pyt   get_extents	  s    		c         C` s   t  j |  | |  S(   u  
        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   t   path_intersects_path(   R"   t   othert   filled(    (    s.   lib/python2.7/site-packages/matplotlib/path.pyt   intersects_path  s    c         C` s(   t  j |  | j | j | j | j |  S(   u]  
        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 the path completely encloses the bounding box,
        :meth:`intersects_bbox` will return True.

        The bounding box is always considered filled.
        (   R   t   path_intersects_rectanglet   x0t   y0t   x1t   y1(   R"   t   bboxR   (    (    s.   lib/python2.7/site-packages/matplotlib/path.pyt   intersects_bbox%  s    	c         C` s   | d k r |  St  |  j |  } |  j } | d k	 rx t j t j t |  d | d f  } | | d d |  <n d } t | |  S(   u|   
        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.   lib/python2.7/site-packages/matplotlib/path.pyt   interpolated3  s    	+c         C` s   t  |  j  d k r g  S| d k	 r4 | j   } n  |  j d k r | d k s[ | d k r |  j } | r t  |  d k  r g  St j | d | d k  r t |  | d g } q n  | d k r | g S| j |  g Sn  t	 j
 |  | | | |  S(   u  
        Convert this path to a list of polygons or polylines.  Each
        polygon/polyline 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.

        If *closed_only* is `True` (default), only closed polygons,
        with the last point being the same as the first point, will be
        returned.  Any unclosed polylines in the path will be
        explicitly closed.  If *closed_only* is `False`, any unclosed
        polygons in the path will be returned as unclosed polygons,
        and the closed polygons will be returned explicitly closed by
        setting the last point to the same as the first point.
        i    i   iN(   R   R#   R   Rk   R$   R   t   anyt   listRW   R   t   convert_path_to_polygons(   R"   RW   t   widtht   heightt   closed_onlyR#   (    (    s.   lib/python2.7/site-packages/matplotlib/path.pyt   to_polygonsD  s     '	c         C` s|   |  j  d k ru |  d d g d d g d d g d d g d d g g |  j |  j |  j |  j |  j g d t |  _  n  |  j  S(   uf   
        Return a :class:`Path` instance of the unit rectangle
        from (0, 0) to (1, 1).
        g        g      ?R&   N(   t   _unit_rectangleR   R   R   R   R    (   R.   (    (    s.   lib/python2.7/site-packages/matplotlib/path.pyt   unit_rectangler  s    'c         C` s  | d k r! |  j  j |  } n d } | d k rd t j | t j | d  j | d d f  } | t j d 7} t j t j |  t j	 |  f d  } t j
 | d f  } |  j | d <|  j | d d +|  j | d <|  | | d t } | d k r| |  j  | <qn  | S(	   u   
        Return a :class:`Path` instance for a unit regular
        polygon with the given *numVertices* and radius of 1.0,
        centered at (0, 0).
        i   i   i   g       @i    iR&   N(   t   _unit_regular_polygonst   getR   R   t   pit   arangeRN   t   concatenatet   cost   sinR   R   R   R   R    (   R.   t   numVerticesRS   t   thetaR/   R$   (    (    s.   lib/python2.7/site-packages/matplotlib/path.pyt   unit_regular_polygon  s     '*g      ?c   	      C` sO  | d k r' |  j  j | | f  } n d } | d k rK| d } d t j | t j | d  } | t j d 7} t j | d  } | | d d d  <t j | t j |  | t j	 |  f  j
   } t j | d f  } |  j | d <|  j | d d +|  j | d <|  | | d t } | d k rK| |  j  | | f <qKn  | S(	   u   
        Return 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       @Ni    iR&   (   t   _unit_regular_starsR   R   R   R   R   R@   RM   R   R   t	   transposeR   R   R   R   R    (	   R.   R   t   innerCircleRS   t   ns2R   t   rR/   R$   (    (    s.   lib/python2.7/site-packages/matplotlib/path.pyt   unit_regular_star  s$    
"5c         C` s   |  j  | d  S(   u   
        Return a :class:`Path` for a unit regular
        asterisk with the given numVertices and radius of 1.0,
        centered at (0, 0).
        g        (   R   (   R.   R   (    (    s.   lib/python2.7/site-packages/matplotlib/path.pyt   unit_regular_asterisk  s    c         C` s:   |  j  d k r3 |  j d d d d d t  |  _  n  |  j  S(   u   
        Return the readonly :class:`Path` of the unit circle.

        For most cases, :func:`Path.circle` will be what you want.

        t   centeri    Rp   i   R&   N(   i    i    (   t   _unit_circleR   t   circleR    (   R.   (    (    s.   lib/python2.7/site-packages/matplotlib/path.pyt   unit_circle  s    c   	      C` s  d } t  j d  } | | } t  j 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 d t } |  j g d } |  j | d <|  j | d	 <t | | | | d
 | S(   u   
        Return a Path representing a circle of a given radius and center.

        Parameters
        ----------
        center : pair of floats
            The center of the circle. Default ``(0, 0)``.
        radius : float
            The radius of the circle. Default is 1.
        readonly : bool
            Whether the created path should have the "readonly" argument
            set when creating the Path instance.

        Notes
        -----
        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      ?R   i   i    iR&   (   R   t   sqrtt   arrayt   floatt   CURVE4R   R   R
   (	   R.   R   Rp   R&   t   MAGICt   SQRTHALFt   MAGIC45R#   R$   (    (    s.   lib/python2.7/site-packages/matplotlib/path.pyR     sD    
	

					

		

		c         C` s4  |  j  d
 k r-d } t j d  } | | } t j 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  } |  j t j d  } |  j | d <|  j	 | d <|  | | d	 t
 |  _  n  |  j  S(   u}  
        Return a :class:`Path` of the right half
        of a unit circle. The circle is approximated using cubic Bezier
        curves.  This uses 4 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      ?i   i    iR&   N(   t   _unit_circle_righthalfR   R   R   R   R   R   R@   R   R   R    (   R.   R   R   R   R#   R$   (    (    s.   lib/python2.7/site-packages/matplotlib/path.pyt   unit_circle_righthalf  s2    
		

						c         C` s~  t  j d } | } | d t  j | | d  } | | k rW | | k rW | d 7} n  t  j | | g  \ } } | d k r t d t  j | | |   } n  | d k  r t d   n  | | | } t  j d |  }	 t  j	 |  t  j
 d d |	 |	  d d }
 t  j | | | d t  } t  j |  } t  j	 |  } | d  } | d  } | } | } | d } | d } | } | } | r/| d	 d
 } t  j | d f t  } |  j t  j | f |  j  } | d | d g | d <|  j |  j g | d d +|  j |  j g | d )d } | d } nv | d	 d } t  j | d f t  } |  j t  j | f |  j  } | d | d g | d <|  j | d <d } | } | |
 | | | | d	  d f <| |
 | | | | d	  d f <| |
 | | | d | d	  d f <| |
 | | | d | d	  d f <| | | d | d	  d f <| | | d | d	  d f <|  | | d t S(   u  
        Return an arc on the unit circle from angle
        *theta1* to angle *theta2* (in degrees).

        *theta2* is unwrapped to produce the shortest arc within 360 degrees.
        That is, if *theta2* > *theta1* + 360, the arc will be from *theta1* to
        *theta2* - 360 and not a full circle plus some extra overlap.

        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      ?ih  i   i   u   n must be >= 1 or Noneg      @g      @ii   i   i    iR&   N(   R   R   t   floort   deg2radR   RA   t   ceilR   t   tanR   R   t   linspaceR    R   R?   R   R   R@   R   R   R   R   R   (   R.   t   theta1t   theta2t   nt   is_wedget   halfpit   eta1t   eta2t   detat   tt   alphaR   t   cos_etat   sin_etat   xAt   yAt   xA_dott   yA_dott   xBt   yBt   xB_dott   yB_dott   lengthR#   R$   t   vertex_offsett   end(    (    s.   lib/python2.7/site-packages/matplotlib/path.pyt   arcL  s^    $0



!!%%c         C` s   |  j  | | | t  S(   u(  
        Return a wedge of the unit circle from angle
        *theta1* to angle *theta2* (in degrees).

        *theta2* is unwrapped to produce the shortest wedge within 360 degrees.
        That is, if *theta2* > *theta1* + 360, the wedge will be from *theta1*
        to *theta2* - 360 and not a full circle plus some extra overlap.

        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.   lib/python2.7/site-packages/matplotlib/path.pyt   wedge  s    i   i   c         C` sn   d d l  m } | d k r  d S|  j j | | f  } | d k	 rH | S| | |  } | |  j | | f <| S(   u   
        Given a hatch specifier, *hatchpattern*, generates a Path that
        can be used in a repeated hatching pattern.  *density* is the
        number of lines per unit square.
        i    (   t   get_pathN(   t   matplotlib.hatchR   R   t   _hatch_dictR   (   R.   t   hatchpatternt   densityR   t
   hatch_path(    (    s.   lib/python2.7/site-packages/matplotlib/path.pyt   hatch  s    c         C` sA   t  j |  | |  } g  | D] } t |  ^ q } |  j |   S(   u.  
        Clip the path to the given bounding box.

        The path must be made up of one or more closed polygons.  This
        algorithm will not behave correctly for unclosed paths.

        If *inside* is `True`, clip to the inside of the box, otherwise
        to the outside of the box.
        (   R   t   clip_path_to_rectR
   RT   (   R"   R   t   insideR/   t   polyt   paths(    (    s.   lib/python2.7/site-packages/matplotlib/path.pyt   clip_to_bbox  s    N(   g        g        (B   t   __name__t
   __module__t   __doc__Ra   R   R   t   CURVE3R   R   R`   R   t   uint8R   R   R   R'   t   classmethodR2   R   t   propertyR#   t   setterR$   R+   R9   R*   R&   R;   R:   R>   t   deepcopyRJ   RT   RU   RV   R    Rg   R_   Rj   Rq   Rv   Rx   R|   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R	   R   R   R   (    (    (    s.   lib/python2.7/site-packages/matplotlib/path.pyR
      s   6

	>!	
					F			
	,			F.Nc         C` s\   d d l  m } t |  d k r1 t d   n  | j t j |  | t j |  | |    S(   u  
    Given a sequence of :class:`Path` objects,
    :class:`~matplotlib.transforms.Transform` objects and offsets, as
    found in a :class:`~matplotlib.collections.PathCollection`,
    returns the bounding box that encapsulates all of them.

    *master_transform* is a global transformation to apply to all paths

    *paths* is a sequence of :class:`Path` instances.

    *transforms* is a sequence of
    :class:`~matplotlib.transforms.Affine2D` instances.

    *offsets* is a sequence of (x, y) offsets (or an Nx2 array)

    *offset_transform* is a :class:`~matplotlib.transforms.Affine2D`
    to apply to the offsets before applying the offset to the path.

    The way that *paths*, *transforms* and *offsets* are combined
    follows the same method as for collections.  Each is iterated over
    independently, so if you have 3 paths, 2 transforms and 1 offset,
    their combinations are as follows:

        (A, A, A), (B, B, A), (C, A, A)
    i   (   Ry   i    u   No paths provided(	   Rz   Ry   R   R   t   from_extentsR   t   get_path_collection_extentsR   t
   atleast_3d(   t   master_transformR   Rz   t   offsetst   offset_transformRy   (    (    s.   lib/python2.7/site-packages/matplotlib/path.pyR     s    c         C` s_   d d l  m } m } t |   d k r7 t d   n  | j t j |   |  | g  |      S(   ui  
    Given a sequence of :class:`Path` objects and optional
    :class:`~matplotlib.transforms.Transform` objects, returns the
    bounding box that encapsulates all of them.

    *paths* is a sequence of :class:`Path` instances.

    *transforms* is an optional sequence of
    :class:`~matplotlib.transforms.Affine2D` instances to apply to
    each path.
    i   (   Ry   t   Affine2Di    u   No paths provided(   Rz   Ry   R   R   R   R   R   R   (   R   Rz   Ry   R   (    (    s.   lib/python2.7/site-packages/matplotlib/path.pyt   get_paths_extents  s
    (   R   t
   __future__R    R   R   R   t   sixt   weakrefR   t   numpyR   t    R   R   t   cbookR   R   R	   t   objectR
   R   R   (    (    (    s.   lib/python2.7/site-packages/matplotlib/path.pyt   <module>
   s   "   	#