³ò ™üàHc@s-dZddklZddd„ƒYZdS(s: SVG renderer. (C) 2006 Chris Liechti iÿÿÿÿ(tescapetSVGOutputVisitorcBs­eZdZddddddd„Zd„Zd„Zd„Zd „Zed „Z d „Z d „Z dd „Z d„Z d„Zd„Zd„Zd„Zd„ZRS(s%Render a list of shapes as SVG image.itiiÿcCsL||_||_||_||_||_||_||_d|_dS(NR(t file_liketscaletunitt line_widtht foregroundt backgroundt fillcolortindent(tselfRRRRRRR ((sp/home/bert/projects/docutils/trunk/sandbox/infrastructure/update-dir/aux/htdocs/sandbox/cliechti/aafigure/svg.pyt__init__ s       cCsd||i|ifS(s;helper to format numbers with scale and unit for svg outputs%d%s(RR(R tnumber((sp/home/bert/projects/docutils/trunk/sandbox/infrastructure/update-dir/aux/htdocs/sandbox/cliechti/aafigure/svg.pyt_numscCsd||ifS(s1helper to format numbers with unit for svg outputs%d%s(R(R R ((sp/home/bert/projects/docutils/trunk/sandbox/infrastructure/update-dir/aux/htdocs/sandbox/cliechti/aafigure/svg.pyt_unitscCs |\}}}d|||fS(Ns #%02x%02x%02x((R tcolortrtgtb((sp/home/bert/projects/docutils/trunk/sandbox/infrastructure/update-dir/aux/htdocs/sandbox/cliechti/aafigure/svg.pyt_color scCs&d|i|iƒ|i|iƒfS(sget image size as svg textswidth="%s" height="%s"(Rtwidththeight(R ((sp/home/bert/projects/docutils/trunk/sandbox/infrastructure/update-dir/aux/htdocs/sandbox/cliechti/aafigure/svg.pytget_size_attrs$scCs³||_|id|i|i|_|id|i|_|o|iiddƒn3|iid|i|iƒ|i|iƒfƒ|i|i ƒ|iidƒdS(sZProcess the given ASCIIArtFigure and output the shapes in the SVG file is@ s���100%sN��� s��� N(���s���100%s���100%( ���t���aa_imageR���t ���nominal_sizet ���aspect_ratioR���R���t���writeR���t ���visit_shapest���shapes(���R ���R���t ���xml_header(����(����sp���/home/bert/projects/docutils/trunk/sandbox/infrastructure/update-dir/aux/htdocs/sandbox/cliechti/aafigure/svg.pyt ���visit_image-���s����  �  c���������C���sa���xZ�|�D]R�}�|�i��i�i�ƒ��}�d�|�}�t�|��|�ƒ�o�t�|��|�ƒ�|�ƒ�q�d�|�GHq�Wd��S(���Ns���visit_%ss*���WARNING: don't know how to handle shape %r(���t ���__class__t���__name__t���lowert���hasattrt���getattr(���R ���R���t���shapet ���shape_namet ���visitor_name(����(����sp���/home/bert/projects/docutils/trunk/sandbox/infrastructure/update-dir/aux/htdocs/sandbox/cliechti/aafigure/svg.pyR���I���s����� c������ ���C���sz���|��i��i�d�|��i�|��i�|�ƒ�|��i�|�ƒ�|��i�|�ƒ�|��i�|�ƒ�|��i�|��i�ƒ�|��i�|��i�d�t�|�ƒ�ƒ�f�ƒ�d�S(���s6���Draw a line, coordinates given as four decimal numberssO���%s i���N( ���R���R���R ���R���R���R���R���R���t���bool(���R ���t���x1t���y1t���x2t���y2t���thick(����(����sp���/home/bert/projects/docutils/trunk/sandbox/infrastructure/update-dir/aux/htdocs/sandbox/cliechti/aafigure/svg.pyt���_lineS���s����     c������ ���C���sÂ���|�|�j�o�|�|�}�}�n�|�|�j�o�|�|�}�}�n�|��i��i�d�|��i�|��i�|�ƒ�|��i�|�ƒ�|��i�|�|�ƒ�|��i�|�|�ƒ�|��i�|��i�ƒ�|��i�|��i�ƒ�|��i�|��i�ƒ�|�f �ƒ�d�S(���s���Draw a rectange, coordinates given as four decimal numbers. ``style`` is inserted in the SVG. It could be e.g. "fill:yellow" s`���%s N(���R���R���R ���R���R���R ���R���R���(���R ���R)���R*���R+���R,���t���style(����(����sp���/home/bert/projects/docutils/trunk/sandbox/infrastructure/update-dir/aux/htdocs/sandbox/cliechti/aafigure/svg.pyt ���_rectangle_���s���� � �  c������ ���C���su���|��i��i�d�|��i�|��i�|�i�ƒ�|��i�|�i�ƒ�|��i�d�ƒ�|��i�|��i�ƒ�|��i�|��i�ƒ�|��i�|��i �ƒ�f�ƒ�d��S(���NsQ���%s gš™™™™™É?( ���R���R���R ���R���t���xt���yR���R���R���R���(���R ���t���point(����(����sp���/home/bert/projects/docutils/trunk/sandbox/infrastructure/update-dir/aux/htdocs/sandbox/cliechti/aafigure/svg.pyt ���visit_pointt���s����  c���������C���sR���|�i��i�|�i�i�}�}�|�i��i�|�i�i�}�}�|��i�|�|�|�|�|�i�ƒ�d��S(���N(���t���startR1���t���endR2���R.���R-���(���R ���t���lineR)���R+���R*���R,���(����(����sp���/home/bert/projects/docutils/trunk/sandbox/infrastructure/update-dir/aux/htdocs/sandbox/cliechti/aafigure/svg.pyt ���visit_line~���s����c���������C���s2���|��i��|�i�i�|�i�i�|�i�i�|�i�i�ƒ�d��S(���N(���R0���t���p1R1���R2���t���p2(���R ���t ���rectangle(����(����sp���/home/bert/projects/docutils/trunk/sandbox/infrastructure/update-dir/aux/htdocs/sandbox/cliechti/aafigure/svg.pyt���visit_rectangleƒ���s����c������ ���C���so���|��i��i�d�|��i�|��i�|�i�i�ƒ�|��i�|�i�i�ƒ�|��i�|�i�ƒ�|��i�|��i �ƒ�|��i �|��i �ƒ�f�ƒ�d��S(���NsH���%s ( ���R���R���R ���R���t���centerR1���R2���t���radiusR���R���R���R���(���R ���t���circle(����(����sp���/home/bert/projects/docutils/trunk/sandbox/infrastructure/update-dir/aux/htdocs/sandbox/cliechti/aafigure/svg.pyt ���visit_circleŠ���s���� $c������ ���C���s‚���|��i��i�d�|��i�|��i�|�i�i�ƒ�|��i�|�i�i�d�ƒ�|��i�|��i�i�ƒ�|��i �|��i �ƒ�t �|�i �i �d�ƒ�ƒ�|��i�f�ƒ�d��S(���Nse���%s %s %s g333333Ó?t���utf8(���R���R���R ���R���t���positionR1���R2���R���R���R���R���R����t���textt���encode(���R ���t���label(����(����sp���/home/bert/projects/docutils/trunk/sandbox/infrastructure/update-dir/aux/htdocs/sandbox/cliechti/aafigure/svg.pyt ���visit_label”���s���� (c���������C���sU���|��i��i�d�ƒ�|��i�}�|��i�d�7_�|��i�|�i�ƒ�|�|��_�|��i��i�d�ƒ�d��S(���Ns��� s��� s��� (���R���R���R ���R���R���(���R ���t���groupt ���old_indent(����(����sp���/home/bert/projects/docutils/trunk/sandbox/infrastructure/update-dir/aux/htdocs/sandbox/cliechti/aafigure/svg.pyt ���visit_group£���s ����  (���i����i����i����(���iÿ���iÿ���iÿ���(���i����i����i����(���R!���t ���__module__t���__doc__R ���R���R���R���R���t���TrueR���R���R.���R0���R4���R8���R<���R@���RF���RI���(����(����(����sp���/home/bert/projects/docutils/trunk/sandbox/infrastructure/update-dir/aux/htdocs/sandbox/cliechti/aafigure/svg.pyR��� ���s"���         N(����(���RK���t���xml.sax.saxutilsR����R���(����(����(����sp���/home/bert/projects/docutils/trunk/sandbox/infrastructure/update-dir/aux/htdocs/sandbox/cliechti/aafigure/svg.pys������s���