;ς 8ΫDc@sΖdZdklZdkZdfd„ƒYZdkZdkZdkZdkZdk Z dk Z dk Z dk Z defd„ƒYZdefd„ƒYZd „Zd efd „ƒYZdS( s€The canvas module provides a PostScript canvas class and related classes A canvas holds a collection of all elements and corresponding attributes to be displayed. (s nested_scopesNs canvasitemcBs)tZdZd„Zd„Zd„ZRS(s=Base class for everything which can be inserted into a canvascCsdS(s!return bounding box of canvasitemN((sself((s>/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/canvas.pysbbox'scCs tƒ‚dS(s~process canvasitem by writing the corresponding PS code to file and by updating context, registry as well as bbox - the PS code corresponding to the canvasitem has to be written in the stream file, which provides a write(string) method - writer is the PSwriter used for the output - context is an instance of pswriter.context which is used for keeping track of the graphics state (current linewidth, colorspace and font)) - registry is used for tracking resources needed by the canvasitem - bbox has to be updated to include the bounding box of the canvasitem N(sNotImplementedError(sselfsfileswriterscontextsregistrysbbox((s>/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/canvas.pys processPS+s cCs tƒ‚dS(sXprocess canvasitem by writing the corresponding PDF code to file and by updating context, registry as well as bbox - the PDF code corresponding to the canvasitem has to be written in the stream file, which provides a write(string) method - writer is the PDFwriter used for the output, which contains properties like whether streamcompression is used - context is an instance of pdfwriter.context which is used for keeping track of the graphics state, in particular for the emulation of PS behaviour regarding fill and stroke styles, for keeping track of the currently selected font as well as of text regions. - registry is used for tracking resources needed by the canvasitem - bbox has to be updated to include the bounding box of the canvasitem N(sNotImplementedError(sselfsfileswriterscontextsregistrysbbox((s>/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/canvas.pys processPDF9s(s__name__s __module__s__doc__sbboxs processPSs processPDF(((s>/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/canvas.pys canvasitem#s   sclipcBs;tZdZd„Zd„Zd„Zd„Zd„ZRS(s9class for use in canvas constructor which clips to a pathcCs ||_dS(s*construct a clip instance for a given pathN(spathsself(sselfspath((s>/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/canvas.pys__init__WscCstiƒSdS(N(s bboxmodulesempty(sself((s>/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/canvas.pysbbox[scCs|iiƒSdS(N(sselfspathsbbox(sself((s>/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/canvas.pysclipbbox_scCs1|idƒ|ii||ƒ|idƒdS(Nsnewpath sclip (sfileswritesselfspathsoutputPSswriter(sselfsfileswriterscontextsregistrysbbox((s>/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/canvas.pys processPScs cCs$|ii||ƒ|idƒdS(NsW n (sselfspaths outputPDFsfileswriterswrite(sselfsfileswriterscontextsregistrysbbox((s>/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/canvas.pys processPDFhs(s__name__s __module__s__doc__s__init__sbboxsclipbboxs processPSs processPDF(((s>/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/canvas.pysclipSs     s_canvascBs’tZdZged„Zd„Zd„Zd„Zd„Zd„Z ed„Z d„Z gd „Z gd „Z d „Zd „Zd „ZRS(s*a canvas holds a collection of canvasitemscCs6g|_tiƒ|_t|_|tj o ||_ndk}|i|_ti |ti t t it igƒ|}|iƒx©|D]‘}t|ti ƒo|i||_net|t ƒoT|itjo|iƒi|iƒ|_q|i|iƒi|iƒ9_n|ii|ƒqWdS(s‚construct a canvas The canvas can be modfied by supplying args, which have to be instances of one of the following classes: - trafo.trafo (leading to a global transformation of the canvas) - canvas.clip (clips the canvas) - style.strokestyle, style.fillstyle (sets some global attributes of the canvas) Note that, while the first two properties are fixed for the whole canvas, the last one can be changed via canvas.set(). The texrunner instance used for the text method can be specified using the texrunner argument. It defaults to text.defaulttexrunner N(sselfsitemsstrafosNonesclipbboxs texrunnerstextsdefaulttexrunnersattrs checkattrssattrsstrafo_ptsclipsstyles strokestyles fillstylesreversesaattrs isinstances transformedsclippboxsappend(sselfsattrss texrunnerstextsaattr((s>/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/canvas.pys__init__us(      % %cCst|iƒSdS(N(slensselfsitems(sself((s>/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/canvas.pys__len__£scCs|i|SdS(N(sselfsitemssi(sselfsi((s>/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/canvas.pys __getitem__¦scCsitiƒ}x!|iD]}||iƒ7}qW|i|iƒ|i t j o||i 9}n|SdS(sΗreturns bounding box of canvas Note that this bounding box doesn't take into account the linewidths, so is less accurate than the one used when writing the output to a file. N( s bboxmodulesemptysobboxsselfsitemsscmdsbboxs transformstrafosclipbboxsNone(sselfscmdsobbox((s>/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/canvas.pysbbox©s  cCs©|ƒ}|io’|idƒtiƒ}x*|iD]}|i |||||ƒq6W|i |i ƒ|itj o||i9}n||7}|idƒndS(Nsgsave s grestore (scontextsselfsitemssfileswrites bboxmodulesemptysnbboxsitems processPSswritersregistrys transformstrafosclipbboxsNonesbbox(sselfsfileswriterscontextsregistrysbboxsitemsnbbox((s>/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/canvas.pys processPS»s      cCs?|ƒ}|io(|idƒtiƒ}x“|iD]ˆ}t |t i ƒo)|i o|idƒd|_ q₯n.|i o#|idƒd|_ t |_n|i|||||ƒq6W|i o#|idƒd|_ t |_n|i|iƒ|it j o||i9}n||7}|idƒndS(Nsq sBT isET isQ (scontextsselfsitemssfileswrites bboxmodulesemptysnbboxsitems isinstances type1fontstext_pts textregionsNonesfonts processPDFswritersregistrys transformstrafosclipbboxsbbox(sselfsfileswriterscontextsregistrysbboxsitemsnbbox((s>/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/canvas.pys processPDFΙs0                cCsmt|tƒ otdƒ‚n|o-t|ƒ}|i|ƒ|i i |ƒn|i i |ƒ|SdS(s•insert item in the canvas. If attrs are passed, a canvas containing the item is inserted applying attrs. returns the item s?only instances of base.canvasitem can be inserted into a canvasN( s isinstancesitems canvasitems RuntimeErrorsattrss_canvassscsinsertsselfsitemssappend(sselfsitemsattrsssc((s>/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/canvas.pysinsertδs  cCsγti|ƒ}ti|titititigƒx/ti |tigƒD]}|i |ƒ}qPWti |titigƒ}ti|d|ƒ}x3ti |tigƒD]}|i||iƒq΅W|i|ƒdS(s!draw path on canvas using the style given by args The argument attrs consists of PathStyles, which modify the appearance of the path, PathDecos, which add some new visual elements to the path, or trafos, which are applied before drawing the path. sstylesN(sattrs mergeattrssattrss checkattrssdecosdeformersstyles fillstyles strokestylesgetattrss adeformersdeformspathsstyless decoratedpathsdpsadecosdecoratesselfs texrunnersinsert(sselfspathsattrssstylessdps adeformersadeco((s>/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/canvas.pysdrawψs(cCs$|i|tigt|ƒƒdS(s#stroke path on canvas using the style given by args The argument attrs consists of PathStyles, which modify the appearance of the path, PathDecos, which add some new visual elements to the path, or trafos, which are applied before drawing the path. N(sselfsdrawspathsdecosstrokedslistsattrs(sselfspathsattrs((s>/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/canvas.pysstrokescCs$|i|tigt|ƒƒdS(s!fill path on canvas using the style given by args The argument attrs consists of PathStyles, which modify the appearance of the path, PathDecos, which add some new visual elements to the path, or trafos, which are applied before drawing the path. N(sselfsdrawspathsdecosfilledslistsattrs(sselfspathsattrs((s>/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/canvas.pysfillscCs ||_dS(sDsets the texrunner to be used to within the text and text_pt methodsN(s texrunnersself(sselfs texrunner((s>/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/canvas.pys settexrunner)scOs)|i|ii|||||ŽƒSdS(sinsert a text into the canvas inserts a textbox created by self.texrunner.text into the canvas returns the inserted textboxN( sselfsinserts texrunnerstextsxsysatextsargsskwargs(sselfsxsysatextsargsskwargs((s>/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/canvas.pystext.scGs&|i|ii||||ŒƒSdS(sinsert a text into the canvas inserts a textbox created by self.texrunner.text_pt into the canvas returns the inserted textboxN(sselfsinserts texrunnerstext_ptsxsysatextsargs(sselfsxsysatextsargs((s>/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/canvas.pystext_pt8s(s__name__s __module__s__doc__sNones__init__s__len__s __getitem__sbboxs processPSs processPDFsinsertsdrawsstrokesfills settexrunnerstextstext_pt(((s>/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/canvas.pys_canvasqs .         cs‡d†}|SdS(NcsJtiti|||Žgƒ}ˆi|_ˆi|_ˆ||ƒSdS(N( sdocumentspagesselfsargsskwargssdsmethods__name__s__doc__sfile(sselfsfilesargsskwargssd(smethod(s>/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/canvas.pyswrappedindocumentFs!  (swrappedindocument(smethodswrappedindocument((smethods>/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/canvas.pys_wrappedindocumentEs scanvascBsttZdZeeiiƒZeeiiƒZeeiiƒZeeiiƒZde dddddd„Z RS(s*a canvas holds a collection of canvasitemss-idsgssic Ksγ|tjo8|idƒo d}n|idƒo d}qEn|d|||f7}|o|d|7}n|tj o|d|7}n|tj o|d|7}n|d 7}t i |d ƒ} |i | |dS( Ns.pngspng16ms.jpgsjpegsE -dEPSCrop -dNOPAUSE -dQUIET -dBATCH -r%i -sDEVICE=%s -sOutputFile=%ss %ss -dTextAlphaBits=%is -dGraphicsAlphaBits=%is -sw(sdevicesNonesfilenamesendswiths gscommands resolutions gsoptionss textalphabitssgraphicsalphabitssosspopensinputsselfs writeEPSfileskwargs( sselfsfilenamesdevices resolutions gscommands gsoptionss textalphabitssgraphicsalphabitsskwargssinput((s>/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/canvas.pyspipeGSWs     ( s__name__s __module__s__doc__s_wrappedindocumentsdocuments writeEPSfiles writePSfiles writePDFfiles writetofilesNonespipeGS(((s>/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/canvas.pyscanvasNs (s__doc__s __future__s nested_scopessoss canvasitemsattrsdecosdeformersdocumentsstylestrafos type1fontsbboxs bboxmodulesclips_canvass_wrappedindocumentscanvas(sstylesdecosattrs nested_scopesscanvass bboxmodules_wrappedindocuments type1fonts_canvassclips canvasitemsossdocumentsdeformerstrafo((s>/mnt/gmirror/ports/graphics/py-PyX/work/PyX-0.10/pyx/canvas.pys?s  (? Τ