³ò ™üàHc@sAdZddkZddkZddkZddd„ƒYZdS(si Bitmap renderer with the help of the Python Imaging Library. (C) 2006 Chris Liechti iÿÿÿÿNtPILOutputVisitorc Bs†eZdZddeddddd„Zd„Zd„Zd„Zd „Zd „Z d „Z d „Z d „Z d„Z d„ZRS(s*Render a list of shapes as ASCII art. itpngiiÿc CsL||_||_||_||_||_||_||_||_dS(N(t file_liketscaletdebugt line_widtht file_typet foregroundt backgroundt fillcolor( tselfRRRRRRRR ((sp/home/bert/projects/docutils/trunk/sandbox/infrastructure/update-dir/aux/htdocs/sandbox/cliechti/aafigure/pil.pyt__init__ s       cCs¾||_|id|i|i|_|id|i|_tidt|i|iƒt|i|iƒf|i ƒ}t i |ƒ|_ |i |iƒ|` |i|i|iƒdS(sZProcess the given ASCIIArtFigure and output the shapes in the SVG file itRGBN(taa_imagetwidtht nominal_sizet aspect_ratiotheighttImagetnewtintRRt ImageDrawtDrawtdrawt visit_shapestshapestsaveRR(R R timage((sp/home/bert/projects/docutils/trunk/sandbox/infrastructure/update-dir/aux/htdocs/sandbox/cliechti/aafigure/pil.pyt visit_images )  cCsaxZ|D]R}|iiiƒ}d|}t||ƒot||ƒ|ƒqd|GHqWdS(Nsvisit_%ss*WARNING: don't know how to handle shape %r(t __class__t__name__tlowerthasattrtgetattr(R Rtshapet shape_namet visitor_name((sp/home/bert/projects/docutils/trunk/sandbox/infrastructure/update-dir/aux/htdocs/sandbox/cliechti/aafigure/pil.pyR4s cCs|i|iƒdS(N(RR(R tgroup((sp/home/bert/projects/docutils/trunk/sandbox/infrastructure/update-dir/aux/htdocs/sandbox/cliechti/aafigure/pil.pyt visit_group=scCs)|ii||||fd|iƒdS(s6Draw a line, coordinates given as four decimal numberstfillN(RtlineR(R tx1ty1tx2ty2((sp/home/bert/projects/docutils/trunk/sandbox/infrastructure/update-dir/aux/htdocs/sandbox/cliechti/aafigure/pil.pyt_lineAscCs2|ii||||fd|id|iƒdS(sDraw a rectange, coordinates given as four decimal numbers. ``style`` is inserted in the SVG. It could be e.g. "fill:yellow" R'toutlineN(Rt rectangleR R(R R)R*R+R,((sp/home/bert/projects/docutils/trunk/sandbox/infrastructure/update-dir/aux/htdocs/sandbox/cliechti/aafigure/pil.pyt _rectangleEscCsgd}|ii|i|i||i|i||i|i||i|i|fd|iƒdS(NiR'(RtellipsetxRtyR(R tpointtdotsize((sp/home/bert/projects/docutils/trunk/sandbox/infrastructure/update-dir/aux/htdocs/sandbox/cliechti/aafigure/pil.pyt visit_pointMs  "(cCsh|ii|ii}}|ii|ii}}|i||i||i||i||iƒdS(N(tstartR2tendR3R-R(R R(R)R+R*R,((sp/home/bert/projects/docutils/trunk/sandbox/infrastructure/update-dir/aux/htdocs/sandbox/cliechti/aafigure/pil.pyt visit_lineWscCsN|i|ii|i|ii|i|ii|i|ii|iƒdS(N(R0tp1R2RR3tp2(R R/((sp/home/bert/projects/docutils/trunk/sandbox/infrastructure/update-dir/aux/htdocs/sandbox/cliechti/aafigure/pil.pytvisit_rectangle\s cCs‚|ii|ii|i|i|ii|i|i|ii|i|i|ii|i|ifd|id|iƒdS(NR'R.( RR1tcenterR2tradiusRR3R R(R tcircle((sp/home/bert/projects/docutils/trunk/sandbox/infrastructure/update-dir/aux/htdocs/sandbox/cliechti/aafigure/pil.pyt visit_circlecs  .4 c Csz|ii|ii|i|ii|iid|if|id|idt i dt |iid|iƒƒƒdS(Ngš™™™™™ñ?R'tfonts arial.ttf( RttexttpositionR2RR3R RRt ImageFontttruetypeR(R tlabel((sp/home/bert/projects/docutils/trunk/sandbox/infrastructure/update-dir/aux/htdocs/sandbox/cliechti/aafigure/pil.pyt visit_labelms  1  (iii(iÿiÿiÿ(iii(Rt __module__t__doc__tFalseR RRR&R-R0R6R9R<R@RG(((sp/home/bert/projects/docutils/trunk/sandbox/infrastructure/update-dir/aux/htdocs/sandbox/cliechti/aafigure/pil.pyR s        ((RIRRRDR(((sp/home/bert/projects/docutils/trunk/sandbox/infrastructure/update-dir/aux/htdocs/sandbox/cliechti/aafigure/pil.pyss$