Warning: session_start(): Session cannot be started after headers have already been sent in /home/tvrreohg/public_html/manga.php on line 13
3 ›tîa2ã@s�dZdZddlTddlmZddlmZddlmZm Z dd „Z Gd d „d ƒZ d d „Z dd„Z dd„ZGdd„dƒZedkrŒedƒeeƒdS)z3.3.0zXSuperclass for renderers to factor out common functionality and default implementations.é)Ú*)Ú DerivedValue)Ú rl_configé)ÚmmultÚinversecCs2i}x(|jƒjƒD]\}}|tkr|||<qW|S)zðUsed to compute when we need to change the graphics state. For example, if we have two adjacent red shapes we don't need to set the pen color to red in between. Returns the effect the given shape would have on the graphics state)Z getPropertiesÚitemsÚSTATE_DEFAULTS)ÚshapeÚdeltaÚpropÚvalue©rú>/tmp/tmp4i9tl1d3/lib64/python/reportlab/graphics/renderbase.pyÚ getStateDeltas  rc@sReZdZdZddd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z dd„Z dS)Ú StateTrackera*Keeps a stack of transforms and state properties. It can contain any properties you want, but the keys 'transform' and 'ctm' have special meanings. The getCTM() method returns the current transformation matrix at any point, without needing to invert matrixes when you pop.NcCsŽg|_g|_|dkrtjƒ}|rjxHtjƒD]<}d|dd…jƒ|dd…}t||ƒr*t||ƒ||<q*Wd|kr~|d|d<|jj|ƒdS)NÚinitialrÚ transformÚctm) Ú_deltasÚ _combinedr ÚcopyÚkeysÚupperÚhasattrÚgetattrÚappend)ÚselfÚdefaultsÚ defaultObjÚkÚarrrÚ__init__!s   zStateTracker.__init__cCs|S)Nr)rÚdrrrÚ_applyDefaultObj5szStateTracker._applyDefaultObjcCsz|jdjƒ}xN|jƒD]B\}}|dkrR|d|d<t|jdd|dƒ|d<q|||<qW|jj|ƒ|jj|ƒdS)z™Take a new state dictionary of changes and push it onto the stack. After doing this, the combined state is accessible through getState()rrrNéÿÿÿÿr%)rrrrrr)rr ÚnewstateÚkeyr rrrÚpush8s   zStateTracker.pushcCst|jd=|jd}|jd}|jd=i}xF|jƒD]:\}}||}||kr2|dkrdt|dƒ||<q2|||<q2W|S)zústeps back one, and returns a state dictionary with the deltas to reverse out of wherever you are. Depending on your back end, you may not need the return value, since you can get the complete state afterwards with getState()rrr%r%r%r%)rrrr)rÚnewStateZ lastDeltaZ reverseDeltar'ZcurValueZ prevValuerrrÚpopKs   zStateTracker.popcCs |jdS)z1returns the complete graphics state at this pointrr%)r)rrrrÚgetStatebszStateTracker.getStatecCs|jddS)z7returns the current transformation matrix at this pointrrr%)r)rrrrÚgetCTMfszStateTracker.getCTMcCs|jd|S)z>returns the complete graphics state value of key at this pointrr%)r)rr'rrrÚ __getitem__jszStateTracker.__getitem__cCs||jd|<dS)z6sets the complete graphics state value of key to valuerNr%)r)rr'r rrrÚ __setitem__nszStateTracker.__setitem__)NN) Ú__name__Ú __module__Ú __qualname__Ú__doc__r"r$r(r*r+r,r-r.rrrrrs rc Csêtdƒdddddddddgdœ}ddlm}ddidd |d œd d ddd ddgid d ddd d dgiddig}t|ƒ}td|jƒƒtƒx0|D](}td|ƒ|j|ƒtd|jƒdƒqŽWx*|D]"}td|jƒƒtd|jƒdƒqÀWdS)NzTesting state trackerrr)Ú fillColorÚ strokeColorÚfontNamer)Ú_baseGFontNamer3ZredZgreenZblue)r3r4r5rgà?éér4zinitial:zpushing:zstate: Ú zpopping:)ÚprintÚreportlab.graphics.shapesr6rr+r(r*)rr6ÚdeltasÚstr rrrÚtestStateTrackerrs$       r>c CsDt|tƒr@z*t|dƒrd}n ||_d}|}|jƒ}Wd|s>|`X|S)NÚ_canvasr)Ú isinstanceZUserNoderr?Z provideNode)ÚnodeÚcanvasÚocanvasZonoderrrÚ_expandUserNodeŠs   rDcCsL|j}|dkrH|}|j|j||j|ƒ}|jjƒ|_|j||ƒd|_|S)Ngð?)Ú renderScaleÚ __class__ÚwidthÚheightÚ__dict__rZscale)r#rEÚorrrÚrenderScaledDrawing˜s  rKc@sÎeZdZdZdd„Zddejfdd„Zdd„Zd d „Z d d „Z d d„Z dd„Z dd„Z ddddddddœZdd„Zdd„Zdd „Zd!d"„Zd#d$„Zd%d&„Zd'd(„Zd)d*„Zd+d,„Zd-d.„Zd/d0„Zd1d2„Zd3S)4ÚRendererz*Virtual superclass for graphics renderers.cCstd||jfƒ‚dS)Nz/%s operation not defined at superclass class=%s)Ú ValueErrorrF)rZ operationrrrÚ undefined¥szRenderer.undefinedrc CsÀt|d�|_|tjkrtj}||_||jd<|_d|_zl|rtt |dƒr`|j ||||j |j ƒn|j |||j |j ƒ|jƒ|j||ƒ|j|ƒ|jƒ|jƒWd|`|`|`|`|`XdS)z�This is the top level function, which draws the drawing at the given location. The recursive part is handled by drawNode.)rÚ_drawingNÚ drawBoundary)rÚ_trackerrÚ_unset_Ú showBoundaryr?rIrOÚ_parentrrPrGrHÚrectZ saveStateÚ initStateÚdrawNoder*Z restoreState)rZdrawingrBÚxÚyrSrrrÚdraw¨s"      z Renderer.drawcCsL|jjd}tt|dƒdd…ƒ||f|d<|jj|ƒ|j|iƒdS)Nrrér%)rQrÚtupleÚlistr(ÚapplyStateChanges)rrXrYr<rrrrVÁs $ zRenderer.initStatecCs|jjƒdS)N)rQr*)rrrrr*Çsz Renderer.popcCs|jdƒdS)zEThis is the recursive method called for each node in the treerWN)rN)rrArrrrWÊszRenderer.drawNodecCs|jjd}||S)z,Return current state parameter for given keyrr%)rQr)rr'Z currentStaterrrÚ getStateValueÐs zRenderer.getStateValuecCs<x6|jjƒD](\}}t|tƒr |j||ƒ}||j|<q WdS)z»Examine a node for any values which are Derived, and replace them with their calculated values. Generally things may look at the drawing or their parent. N)rIrr@rZgetValue)rrAr'r ZnewValuerrrÚfillDerivedValuesÕs  zRenderer.fillDerivedValuesc Cs t|ddƒ}�z€t||ƒ}|s"dSt|dƒr2d}n ||_d}|j|ƒt|ddƒ}|rd||||d�t|tƒr||j|ƒ�nt|tƒr’|j |ƒnút|t ƒr¨|j |ƒnät|t ƒr¾|j |ƒnÎt|tƒrÔ|j|ƒn¸t|tƒrê|j|ƒn¢t|tƒ�r|j|ƒnŠt|tƒ�r|j|ƒnrt|tƒ�r2|j|ƒnZt|tƒ�rJ|j|ƒnBt|tƒ�rb|j|ƒn*t|tƒ�rz|j|ƒntddt|ƒƒWd|�sš|`XdS)z1dispatch on the node's (super) class: shared coder?NrZ_drawTimeCallback)rBZrendererZ DrawingErrorz!Unexpected element %s in drawing!) rrDrr?r`r@ZLineÚdrawLineZImageÚ drawImageZRectÚdrawRectZCircleÚ drawCircleZEllipseÚ drawEllipseZPolyLineÚ drawPolyLineZPolygonÚ drawPolygonÚPathÚdrawPathÚStringÚ drawStringÚGroupÚ drawGroupZWedgeÚ drawWedgeZ DirectDrawZ drawDirectlyr:Ústr)rrArBrCZdtcbrrrÚdrawNodeDispatcheräsP                            zRenderer.drawNodeDispatcherZ_strokeZ _lineWidthZ_lineCapZ _lineJoinZ_fillZ_fontZ _fontSize)ZstrokeZ stroke_widthZstroke_linecapZstroke_linejoinÚfillZ font_familyZ font_sizec Cszt|ddƒ}xh|jƒD]\}t||ƒ}|s*q|j|ƒz.t|dƒrFd}n ||_d}||_|j|ƒWd|`|sp|`XqWdS)Nr?r)rZ getContentsrDr`rr?rTrW)rÚgrouprBrArCrrrrms     zRenderer.drawGroupcCs,|jƒ}t|tƒr|j|ƒn |j|ƒdS)N)Z asPolygonr@rhrirg)rZwedgeÚPrrrrn/s  zRenderer.drawWedgecCs$|jƒ}x|D]}|j|ƒqWdS)N)Z asPolygonsrg)rÚpathZpolygonsZpolygonrrrri8s zRenderer.drawPathcCs|jdƒdS)Nrc)rN)rrUrrrrc=szRenderer.drawRectcCs|jdƒdS)Nra)rN)rÚlinerrrraAszRenderer.drawLinecCs|jdƒdS)Nrd)rN)rZcirclerrrrdDszRenderer.drawCirclecCs|jdƒdS)Nrf)rN)rÚprrrrfGszRenderer.drawPolyLinecCs|jdƒdS)Nre)rN)rZellipserrrreJszRenderer.drawEllipsecCs|jdƒdS)Nrg)rN)rrvrrrrgMszRenderer.drawPolygoncCs|jdƒdS)Nrk)rN)rZ stringObjrrrrkPszRenderer.drawStringcCs|jdƒdS)z\This takes a set of states, and outputs the operators needed to set those propertiesr^N)rN)rr r)rrrr^SszRenderer.applyStateChangescOs tdƒ‚dS)Nrb)ÚNotImplementedError)rÚargsÚkwdsrrrrbXszRenderer.drawImageN)r/r0r1r2rNrrRrZrVr*rWr_r`rpZ _restoresrmrnrircrardrfrergrkr^rbrrrrrL¢s01 rLÚ__main__z&this file has no script interpretationN)Ú __version__r2r;Zreportlab.lib.validatorsrÚ reportlabrrrrrrr>rDrKrLr/r:rrrrÚs   Y :