Ñò 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 sEtiddƒti|ƒtdƒ|_tdƒ|_||_||_||_ tid||fdƒt t |ƒt |ƒ|dt ƒ|_ tiddƒ|i i|_|i i|_|i i|_|i i|_|i i|_|i i|_tdƒ|_tidd|i|i ƒ|_tid dƒdS( NsRendererAgg.__init__sdebug-annoyingi2s(RendererAgg.__init__ width=%s, height=%stdebugs&RendererAgg.__init__ _RendererAgg donetAggisRendererAgg.__init__ done(RtreportRt__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 sRendererAgg.draw_mathtextsdebug-annoyingiN(RRR%tparseRRRtdraw_text_image(R(R7txtytstproptangletoxtoyRRtdescentt font_imagetused_characters((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_agg.pyt draw_mathtextds  0c C sîtiddƒ|o|i||||||ƒS|i|ƒ}|djodSt|ƒdjo0t|ƒdjo|it|ƒdtƒn|i |ddtƒ|i ƒ|i i |i ƒt|ƒt|ƒd||ƒdS(s! Render the text sRendererAgg.draw_textsdebug-annoyingiitflagsiN(RRRRt _get_agg_fontR,tlentordt load_charR tset_texttdraw_glyphs_to_bitmapRRGt get_imageR( R(R7RHRIRJRKRLtismathtfont((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 tTeXtrenderergRSgP@( tget_size_in_pointstget_texmanagertget_text_width_height_descentR%RFRRTRXR tget_width_heightt get_descent(R(RJRKR[tsizet texmanagertfontsizetwthtdRMRNRRROtfontsRQR\((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_agg.pyRbˆs$    0    c C sª|iƒ}|iƒ}|||i||iƒf} |ii| ƒ} | djo5|i|||iƒ} ti | dti ƒ} n|i i | ||||ƒdS(Ngào@( R`RaRtget_font_configRtgetR,tget_greyR.tarraytuint8RRG( R(R7RHRIRJRKRLReRftkeytimtZ((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Çtiddƒ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'txytx1ty1tx2ty2RMRN((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_agg.pyR†ñs   &N(t__name__t __module__t__doc__RRR,R6RRR]RbRtRuRTR|R}R~RRxRR†(((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_agg.pyR+s"           cO sPtiddƒ|idtƒ}|||Ž}t|ƒ}t||ƒ}|S(s. Create a new figure manager instance sbackend_agg.new_figure_managersdebug-annoyingt FigureClass(RRtpopRtFigureCanvasAggR(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 s6tiddƒ|iƒ|_|ii|iƒdS(s4 Draw the figure using the renderer sFigureCanvasAgg.drawsdebug-annoyingN(RRRš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_tAttributeErrorR€R(R(tltbRhRiRqtneed_new_renderer((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_agg.pyRš<s  cC stiddƒ|iiƒS(NsFigureCanvasAgg.tostring_rgbsdebug-annoying(RRR_R}(R(((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_agg.pyR}Hs cC stiddƒ|iiƒS(NsFigureCanvasAgg.tostring_argbsdebug-annoying(RRR_R~(R(((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_agg.pyR~Ms cC s#tiddƒ|ii||ƒS(NsFigureCanvasAgg.buffer_rgbasdebug-annoying(RRR_R(R(RHRI((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_agg.pyRRs cC 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_pngRRRR(R(R¨R”R•R_R©((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_agg.pyt print_pnges     N(RRŽRR#R,R†RœRšR}R~RR¤Rªt print_rgbaR¬(((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_agg.pyR’!s      ($Rt __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" ç