Ñò 8”tJc@ s5dZddklZddkZddklZlZddkl Z l Z l Z ddk l Z lZddklZddklZdd klZlZdd klZdd klZdd klZlZdd klZddkl Z dZ!de fd„ƒYZd„Z"de fd„ƒ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_AUTOHINT(tMathTextParser(tPath(tBboxtBboxBase(t RendererAgg(t_pngsv2.2RcB s¤eZdZdZd„Zdd„Zd„Zd„Zd„Z d„Z d„Z d „Z d „Z d „Zd „Zd „Zd„Zd„Zddd„ZRS(s The renderer handles all the drawing primitives using a graphics context instance that controls the colors/styles icC sûti|ƒtdƒ|_tdƒ|_||_||_||_tt |ƒt |ƒ|dt ƒ|_ |i i |_ |i i |_ |i i|_|i i|_|i i|_|i i|_tdƒ|_tidd|i|iƒ|_dS(Ni2tdebugtAggi(Rt__init__Rttexdt_fontdtdpitwidththeightt _RendererAggtinttFalset _renderert draw_markerstdraw_path_collectiontdraw_quad_mesht draw_imagetcopy_from_bboxttostring_rgba_minimizedR tmathtext_parserRt from_boundstbbox(tselfRRR((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_agg.pyR1s     '!cC sŒtd}|iid}|djoH||jo;|io1|djo$|iƒdjoti|t|ƒƒ}t ti||ƒƒ}ti d||ƒ} ti | ƒ} | dd| d*|| d Draw the math text using matplotlib.mathtext iN(R$tparseRRRtdraw_text_image(R'R6txtytstproptangletoxtoyRRtdescentt font_imagetused_characters((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_agg.pyt draw_mathtextds0c C sÞ|o|i||||||ƒS|i|ƒ}|djodSt|ƒdjo0t|ƒdjo|it|ƒdtƒn|i|ddtƒ|iƒ|i i |i ƒt |ƒt |ƒd||ƒdS(s! Render the text iitflagsiN( RQt _get_agg_fontR+tlentordt load_charR tset_texttdraw_glyphs_to_bitmapRRFt get_imageR( R'R6RGRHRIRJRKtismathtfont((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_agg.pyt draw_textqs & cC s|djoS|iƒ}|iƒ}|iƒ}|i||d|ƒ\}}} ||| fS|o>|ii||i|ƒ\} } } } }}}| | |fS|i|ƒ}|i|ddtƒ|i ƒ\}}|i ƒ} |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 tTeXtrenderergRRgP@( tget_size_in_pointstget_texmanagertget_text_width_height_descentR$RERRSRWR tget_width_heightt get_descent(R'RIRJRZtsizet texmanagertfontsizetwthtdRLRMRRRNtfontsRPR[((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_agg.pyRaˆs$    0    c C sª|iƒ}|iƒ}|||i||iƒf} |ii| ƒ} | djo5|i|||iƒ} ti | dti ƒ} n|i i | ||||ƒdS(Ngào@( R_R`Rtget_font_configRtgetR+tget_greyR-tarraytuint8RRF( R'R6RGRHRIRJRKRdRetkeytimtZ((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_agg.pytdraw_tex§s   cC s|i|ifS(s4return the canvas width and height in display coords(RR(R'((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_agg.pytget_canvas_width_height´scC s·t|ƒ}|ii|ƒ}|djo_t|ƒ}|ii|ƒ}|djo#tt|ƒƒ}||i|>> 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(R+t get_extentst isinstanceRtextentsRtrestore_region2trestore_region( R'tregionR&txytx1ty1tx2ty2RLRM((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_agg.pyR…ñs   &N(t__name__t __module__t__doc__RRR+R5RQR\RaRsRtRSR{R|R}R~RwR€R…(((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_agg.pyR+s"           cO s@|idtƒ}|||Ž}t|ƒ}t||ƒ}|S(s. Create a new figure manager instance t FigureClass(tpopRtFigureCanvasAggR(tnumtargstkwargsRtthisFigtcanvastmanager((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_agg.pytnew_figure_managers  R‘cB steZdZd„Zd d d„Zd„Zd„Zd„Zd„Z d„Z d„Z d „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|iƒ}|i|ƒS(N(t get_rendererR"(R'R&R^((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_agg.pyR"+s cC s|iƒ}|i|||ƒS(N(R™R…(R'R†R&R‡R^((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_agg.pyR…/s cC s&|iƒ|_|ii|iƒdS(s4 Draw the figure using the renderer N(R™R^tfiguretdraw(R'((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_agg.pyR›3scC s¥|iii\}}}}|||iif}y|i|ifWntj o t}nX|i|j}|o(t|||iiƒ|_||_n|iS(N( RšR&tboundsRt_lastKeyR^tAttributeErrorRR(R'tltbRgRhRptneed_new_renderer((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_agg.pyR™<s  cC s |iiƒS(N(R^R|(R'((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_agg.pyR|HscC s |iiƒS(N(R^R}(R'((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_agg.pyR}MscC s|ii||ƒS(N(R^R~(R'RGRH((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_agg.pyR~RscC sdS(Ntpng((R'((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_agg.pytget_default_filetypeWscO snti|ƒ|iƒ}|i}|ii|_t|ƒot|dƒ}n|ii|ƒ||_dS(Ntwb( R‘R›R™RRšRtfileRt write_rgba(R'tfilename_or_objR“R”R^t original_dpi((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_agg.pyt print_rawZs    cO s’ti|ƒ|iƒ}|i}|ii|_t|ƒot|dƒ}nti|i i ddƒ|i |i ||iiƒ||_dS(NR¤i( R‘R›R™RRšRR¥Rt write_pngRR~RR(R'R§R“R”R^R¨((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_agg.pyt print_pnges     N(RŒRRŽR"R+R…R›R™R|R}R~R£R©t print_rgbaR«(((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_agg.pyR‘!s      ($RŽt __future__RtnumpyR-t matplotlibRRtmatplotlib.backend_basesRRRtmatplotlib.cbookRRtmatplotlib.figureRtmatplotlib.font_managerR tmatplotlib.ft2fontR R tmatplotlib.mathtextR tmatplotlib.pathR tmatplotlib.transformsRRt _backend_aggRRRtbackend_versionR˜R‘(((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_agg.pyts" ç