HEX
Server: LiteSpeed
System: Linux standart9.isimtescil.net 3.10.0-962.3.2.lve1.5.26.7.el7.x86_64 #1 SMP Wed Oct 2 07:53:12 EDT 2019 x86_64
User: karalev (5310)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: //opt/alt/python27/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.pyo
�
`�3Lc@ s;dZddlmZddlZddlmZmZddlm	Z	m
Z
mZddlm
Z
mZddlmZddlmZdd	lmZmZmZdd
lmZddlmZddlmZmZdd
lmZ ddlm!Z!dZ"de	fd��YZd�Z#defd��YZ$dS(s�
An agg http://antigrain.com/ backend

Features that are implemented

 * capstyles and join styles
 * dashes
 * linewidth
 * lines, rectangles, ellipses
 * clipping to a rectangle
 * output to RGBA and PNG
 * alpha blending
 * DPI scaling properly - everything scales properly (dashes, linewidths, etc)
 * draw polygon
 * freetype2 w/ ft2font

TODO:

  * allow save to file handle

  * integrate screen dpi w/ ppi and text
i����(tdivisionN(tverbosetrcParams(tRendererBasetFigureManagerBasetFigureCanvasBase(tis_string_liketmaxdict(tFigure(tfindfont(tFT2FonttLOAD_FORCE_AUTOHINTtLOAD_NO_HINTING(tMathTextParser(tPath(tBboxtBboxBase(tRendererAgg(t_pngsv2.2RcB s�eZdZdZd�Zd�Zd�Zd�Zdd�Z	d�Z
d�Zd	�Zd
�Z
d�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zddd�Zd�Zd�ZRS(s
    The renderer handles all the drawing primitives using a graphics
    context instance that controls the colors/styles
    icC s�tj|�td�|_td�|_||_||_||_tt	|�t	|�|dt
�|_g|_|j
�td�|_tjdd|j|j�|_dS(Ni2tdebugtAggi(Rt__init__Rttexdt_fontdtdpitwidththeightt_RendererAggtinttFalset	_renderert_filter_rendererst_update_methodsR
tmathtext_parserRtfrom_boundstbbox(tselfRRR((sR/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.pyR1s
			'	
!cC stdrtStSdS(Nstext.hinting(RRR(R$((sR/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.pyt_get_hinting_flagHs
cO s|jj||�S(N(Rtdraw_markers(R$tkltkw((sR/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.pyR&NscC sm|jj|_|jj|_|jj|_|jj|_|jj|_|jj|_|jj|_dS(N(Rtdraw_path_collectiontdraw_quad_meshtdraw_gouraud_triangletdraw_gouraud_trianglest
draw_imagetcopy_from_bboxttostring_rgba_minimized(R$((sR/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.pyR Ssc
C s�td}|jjd}|dkrg||krg|jrg|dkrg|j�dkrgtj|t|��}t	tj||��}tj
d||�}	tj|	�}
|	dd|
d*||
d<x�t|	|
�D]�\}}|j||�dd�f}
|j
}|dk	r8|||!}tj|d<nt|
|�}|jj||||�q�Wn|jj||||�dS(s
        Draw the path
        sagg.path.chunksizeiidii����N(Rtverticestshapetshould_simplifytNonet	get_hatchtnptceiltfloatRtaranget
zeros_liketziptcodesRtMOVETORt	draw_path(R$tgctpatht	transformtrgbFacetnmaxtnptstnchtchsizeti0ti1tii0tii1tvtctp((sR/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.pyR=^s&
!
	
 cC st|jj||j|�\}}}	}
}}}
t|�|}t|�|}|jj|||d||�dS(s>
        Draw the math text using matplotlib.mathtext
        iN(R!tparseRRRtdraw_text_image(R$R>txtytstproptangletoxtoyRRtdescentt
font_imagetused_characters((sR/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.pyt
draw_mathtextws0c
C s�|r"|j||||||�S|j�}|j|�}	|	dkrMdSt|�dkr�t|�dkr�|	jt|�d|�n|	j|dd|�|	j�|j	j
|	j�t|�t|�d||�dS(s!
        Render the text
        iitflagsiN(
RYR%t
_get_agg_fontR3tlentordt	load_chartset_texttdraw_glyphs_to_bitmapRRNt	get_imageR(
R$R>RORPRQRRRStismathRZtfont((sR/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.pyt	draw_text�s$
cC stdr\|j�}|j�}|j�}|j||d|�\}}}	|||	fS|r�|jj||j|�\}
}}}
}}}||
|fS|j�}|j|�}|j	|dd|�|j
�\}}|j�}	|d}|d}|	d}	|||	fS(s
        get the width and height in display coords of the string s
        with FontPropertry prop

        # passing rgb is a little hack to make cacheing in the
        # texmanager more efficient.  It is not meant to be used
        # outside the backend
        stext.usetextrenderergRZgP@(Rtget_size_in_pointstget_texmanagertget_text_width_height_descentR!RMRR%R[R_tget_width_heighttget_descent(R$RQRRRbtsizet
texmanagertfontsizetwthtdRTRURRRVtfontsRXRZRc((sR/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.pyRh�s&	

0



cC s�|j�}|j�}|||j||j�f}	|jj|	�}
|
dkr�|j|||j�}tj	|dtj
�}n|jj|||||�dS(Ng�o@(
RfRgRtget_font_configRtgetR3tget_greyR5tarraytuint8RRN(R$R>RORPRQRRRSRkRltkeytimtZ((sR/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.pytdraw_tex�scC s|j|jfS(s4return the canvas width and height in display coords(RR(R$((sR/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.pytget_canvas_width_height�scC s�t|�}|jj|�}|dkr�t|�}|jj|�}|dkrvtt|��}||j|<n||j|<n|j�|j�}|j	||j
�|S(sK
        Get the font for text instance t, cacheing for efficiency
        N(thashRRsR3R	R
tstrtclearRftset_sizeR(R$RRRwRctfnameRk((sR/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.pyR[�s
cC s||jdS(sj
        convert point measures to pixes using dpi and the pixels per
        inch of the display
        gR@(R(R$tpoints((sR/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.pytpoints_to_pixels�scC s
|jj�S(N(Rttostring_rgb(R$((sR/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.pyR��scC s
|jj�S(N(Rt
tostring_argb(R$((sR/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.pyR��scC s|jj||�S(N(Rtbuffer_rgba(R$RORP((sR/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.pyR��scC s|jj�dS(N(RR~(R$((sR/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.pyR~�scC stS(N(tTrue(R$((sR/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.pytoption_image_nocompositescC stS(sA
        agg backend support arbitrary scaling of image.
        (R�(R$((sR/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.pytoption_scale_imagesc
	C s�|dk	s|dk	r�|dkr?|j�\}}}}n9t|t�rf|j\}}}}n|\}}}}|dkr�||}}	n|\}}	|jj|||||||	�n|jj|�dS(s:
        Restore the saved region. If bbox (instance of BboxBase, or
        its extents) is given, only the region specified by the bbox
        will be restored. *xy* (a tuple of two floasts) optionally
        specifies the new position (the LLC of the original region,
        not the LLC of the bbox) where the region will be restored.

        >>> region = renderer.copy_from_bbox()
        >>> x1, y1, x2, y2 = region.get_extents()
        >>> renderer.restore_region(region, bbox=(x1+dx, y1, x2, y2),
                                    xy=(x1-dx, y1))

        N(R3tget_extentst
isinstanceRtextentsRtrestore_region2trestore_region(
R$tregionR#txytx1ty1tx2ty2RTRU((sR/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.pyR�s%cC sK|jj|j�tt|j�t|j�|j�|_|j�dS(sX
        Start filtering. It simply create a new canvas (the old one is saved).
        N(	RtappendRRRRRRR (R$((sR/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.pytstart_filter.scC s%ddlm}t|j�t|j�}}|jj�\}}|\}}}	}
|jj�|_|j	�|	dkr!|
dkr!t
j|t
j�}||j
|
|	df�d|j�\}}}
||d�}|j�|j�}|jj||||||
|
|�ndS(s�
        Save the plot in the current canvas as a image and apply
        the *post_processing* function.

           def post_processing(image, dpi):
             # ny, nx, depth = image.shape
             # image (numpy array) has RGBA channels and has a depth of 4.
             ...
             # create a new_image (numpy array of 4 channels, size can be
             # different). The resulting image may have offsets from
             # lower-left corner of the original image
             return new_image, offset_x, offset_y

        The saved renderer is restored and the returned image from
        post_processing is plotted (using draw_image) on it.
        i����(t	fromarrayiig�o@iN(tmatplotlib._imageR�RRRRR/RtpopR R5t
fromstringRvtreshapeRt
flipud_outtnew_gcR-(R$tpost_processingR�RRtbuffertboundstltbRnRotimgRTRUtimageR>((sR/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.pytstop_filter7s 

N(t__name__t
__module__t__doc__RRR%R&R R3R=RYRdRhRzR{R[R�R�R�R�R~R�R�R�R�R�(((sR/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.pyR+s.					
		"	
										 		cO s@|jdt�}|||�}t|�}t||�}|S(s.
    Create a new figure manager instance
    tFigureClass(R�RtFigureCanvasAggR(tnumtargstkwargsR�tthisFigtcanvastmanager((sR/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.pytnew_figure_managerbs
R�cB steZdZd�Zddd�Zd�Zd�Zd�Zd�Z	d�Z
d�Zd	�ZeZ
d
�ZRS(s�
    The canvas the figure renders into.  Calls the draw and print fig
    methods, creates the renderers, etc...

    Public attribute

      figure - A Figure instance
    cC s|j�}|j|�S(N(tget_rendererR.(R$R#Re((sR/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.pyR.{scC s|j�}|j|||�S(N(R�R�(R$R�R#R�Re((sR/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.pyR�scC s&|j�|_|jj|j�dS(s4
        Draw the figure using the renderer
        N(R�Retfiguretdraw(R$((sR/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.pyR��scC s�|jjj\}}}}|||jjf}y|j|jfWntk
r]t}nX|j|k}|r�t|||jj�|_||_n|jS(N(	R�R#R�Rt_lastKeyRetAttributeErrorR�R(R$R�R�RnRoRwtneed_new_renderer((sR/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.pyR��s

cC s
|jj�S(N(ReR�(R$((sR/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.pyR��scC s
|jj�S(N(ReR�(R$((sR/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.pyR��scC s|jj||�S(N(ReR�(R$RORP((sR/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.pyR��scC sdS(Ntpng((R$((sR/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.pytget_default_filetype�scO sltj|�|j�}|j}|jj|_t|�rOt|d�}n|jj|�||_dS(Ntwb(	R�R�R�RR�RtfileRt
write_rgba(R$tfilename_or_objR�R�Retoriginal_dpi((sR/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.pyt	print_raw�s
	cO s�tj|�|j�}|j}|jj|_t|�rOt|d�}ntj|j	j
dd�|j|j||jj�||_dS(NR�i(
R�R�R�RR�RR�Rt	write_pngRR�RR(R$R�R�R�ReR�((sR/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.pyt	print_png�s
	N(R�R�R�R.R3R�R�R�R�R�R�R�R�t
print_rgbaR�(((sR/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.pyR�qs										(%R�t
__future__RtnumpyR5t
matplotlibRRtmatplotlib.backend_basesRRRtmatplotlib.cbookRRtmatplotlib.figureRtmatplotlib.font_managerR	tmatplotlib.ft2fontR
RRtmatplotlib.mathtextR
tmatplotlib.pathRtmatplotlib.transformsRRt_backend_aggRRRtbackend_versionR�R�(((sR/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.pyt<module>s$�8