)Uc@sdZddlZddlmZddlZddlmZddlmZm Z m Z m Z m Z m Z mZmZddlmZmZddlmZdefd YZe Zd Z dS( s2 Contains a class for managing paths (polylines). iN(tWeakValueDictionary(tma(t point_in_pathtget_path_extentstpoint_in_path_collectiontget_path_collection_extentst path_in_pathtpath_intersects_pathtconvert_path_to_polygonst cleanup_path(tsimple_linear_interpolationtmaxdict(trcParamstPathcBseZdZdZdZdZdZdZdZddddddddddddddddgZ e j Z d"ddZedZed Zd Zd Zd"ed"ed d"ed ZdZd"dZd"dZd"dZedZedZdZd"dddZd"ZedZ e!Z"edZ#e!Z$eddZ%edZ&d"Z'edZ(d"Z)edZ*ed"edZ+ed"dZ,e-dZ.ed d!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. iiiiiiOcCstj|r0|jtjjtj}ntj|tj}|dk rxtj||j }t |rxqxnt dot |dko|dkptj |t jk|_t d|_tj|j |_||_||_||_dS(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`. *interpolation_steps* is 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. s path.simplifyispath.simplify_thresholdN(Rt isMaskedArraytastypetnptfloat_tfilledtnantasarraytNonet code_typetlenR tallR tLINETOtshould_simplifytsimplify_thresholdtisfinitet has_nonfinitetcodestverticest_interpolation_steps(tselfRRR ((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/path.pyt__init__Ss!   '   c Cs|j\}}}|d}||}tj|df}tj|t|j}|j|dd|<|j||d|s  cCs|dkr|St|j|}|j}|dk rxtjtjt|d|df}||dd|`_. grSl?g?g@ggg?iiiN( t _unit_circleRRtsqrttarrayRtCURVE4R%R'R((R*tMAGICtSQRTHALFtMAGIC45RR((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/path.pyt unit_circlesJ                      cCs>|jd kr7d}tjd}tj||d}tjddg|dg||| |g|| g||| |gd| gddgd|g||||g||g||||g|dgddgddggtj}|jtjd}|j|d<|j |d <||||_n|jS( s (staticmethod) Returns 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 `_. grSl?g?g@ggg?iiiN( t_unit_circle_righthalfRRR{R|RR}R%R'R((R*R~RRRR((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/path.pytunit_circle_righthalf s2              cCs|tjd9}|tjd9}tjd}tjd}tjtj|tj|}tjtj|tj|}||tj|||8}||tjkr||tjkr||7}n|dkrtdtj|||}n|dkr!t dn|||} tj d| } tj| tj dd| | dd} tj |||dt } tj| } tj| }| d }|d }| }|}| d}|d}| }|}|r|d d }tj|dftj}|jtj|f|j}|d |d g|d<|j|jg|d d+|j|jg|d )d}|d}ny|d d}tj|dftj}|jtj|f|j}|d |d g|d <|j|d `_. gf@g@g?iisn must be >= 1 or Noneg@g@iiiiiN(RRjtarctan2RnRmtfloorRR&tceilt ValueErrorttanR{tlinspacetTrueRoRR}R%RR'RR((R*ttheta1ttheta2tntis_wedgettwopithalfpiteta1teta2tdetatttalphaRatcos_etatsin_etatxAtyAtxA_dottyA_dottxBtyBtxB_dottyB_dotR<RRt vertex_offsettend((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/path.pytarc;sd  $$&  $ 0      !!%%cCs|j|||tS(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*. (RR(R*RRR((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/path.pytwedges iicCsnddlm}|dkr dS|jj||f}|dk rH|S|||}||j||f<|S(s 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(tget_pathN(tmatplotlib.hatchRRt _hatch_dictRi(R*t hatchpatterntdensityRt hatch_path((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/path.pythatchs  N(0t__name__t __module__t__doc__RAR'RtCURVE3R}R(R@Rtuint8RRR"t classmethodR3R=R>R?RtFalseRNRORRRTRXRZR`RcRfRgR\RRhRrRsRxRyRzRRRRRR RR(((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/path.pyR s^0    2     >       =.M cGsHddlm}t|ddkr5tdn|jt|S(sp Given a sequence of :class:`Path` objects, returns the bounding box that encapsulates all of them. i(RUiisNo paths provided(RVRURRt from_extentst_get_path_collection_extents(R7RU((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/path.pyRs(RtmathtweakrefRtnumpyRRtmatplotlib._pathRRRRRRRR tmatplotlib.cbookR R t matplotlibR tobjectR R(((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/path.pyts  :