%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/reportlab/graphics/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/reportlab/graphics/__pycache__/renderSVG.cpython-312.pyc

�

��d6����dZddlZddlZddlZddlZddlZddlmZmZddl	m
Z
ddlmZddl
mZddlmZmZmZddlmZmZmZdd	l�dd
lmZddl
mZmZmZddlmZmZd
dlm Z ddl!m"Z"ejFZ#ejHZ$ejJZ%djM�Z'djM�Z(djM�Z)djM�Z*djM�Z+ejXfd�Z-ejXfd�Z.ddejXfd�Z/d�Z0d'd�Z1Gd�de2�Z3edddddedddddiZ4d �Z5Gd!�d"�Z6Gd#�d$e�Z7d(d%�Z8e9d&k(re8�yy))aAn experimental SVG renderer for the ReportLab graphics framework.

This will create SVG code from the ReportLab Graphics API (RLG).
To read existing SVG code and convert it into ReportLab graphics
objects download the svglib module here:

  http://python.net/~gherman/#svglib
�N)�BytesIO�StringIO)�stringWidth)�fp_str)�asNative)�
getStateDelta�Renderer�renderScaledDrawing)�STATE_DEFAULTS�Path�UserNode)�*)�	rl_config)�RLString�	isUnicode�isBytes)�
FILL_EVEN_ODD�
FILL_NON_ZERO�)�	_getImage)�getDOMImplementationzsstroke-width stroke-linecap stroke stroke-opacity fill fill-opacity stroke-dasharray stroke-dashoffset fill-rule idzWstroke-width stroke-linecap stroke stroke-opacity stroke-dasharray stroke-dashoffset idz<font-family font-weight font-style font-variant font-size idzTstroke-width stroke-linecap stroke stroke-opacity stroke-dasharray stroke-dashoffsetzfill fill-opacityc�T�t�}t||fd|i|��|j�S)z>Returns a SVG as a string in memory, without touching the disk�showBoundary)r�
drawToFile�getvalue)�dr�kwds�ss    �>/usr/lib/python3/dist-packages/reportlab/graphics/renderSVG.py�drawToStringr 's)���
�A��q�!�6�,�6��6��:�:�<��c��t|�}t|j|jffi|��}t	||dd|��|j|�y)Nr�r)r
�	SVGCanvas�width�height�draw�save)r�fnrr�cs     rrr-sC���A��A��1�7�7�A�H�H�%�-��-�A���A�q�!�,�/��F�F�2�Jr!c�V�t�}|jt|�||||��y)zAs it says.r#N)�_SVGRendererr'r
)�drawing�canvas�x�yr�rs      rr'r'3s%����A��F�F��w�'���A�L�F�Qr!c�x�g}tdt|�d�D]}|j||||dzf�� |S)zo
    given a list of coordinates [x0, y0, x1, y1....]
    produce a list of points [(x0,y0), (y1,y0),....]
    r�r)�range�len�append)�L�P�is   r�_pointsFromListr:9sH��	�A�
�1�S��V�Q�
�!��	���!�A�$��!�A�#��� �!�
�Hr!c���|j|�}|j�D]L\}}t|�}|s|j||��&|j	|�}|j||xs|��N|S)a�Transform a DOM node into new node and copy selected attributes.

    Creates a new DOM node with tag name 'newTag' for document 'doc'
    and copies selected attributes from an existing 'node' as provided
    in 'attrDict'. The source 'node' can be None. Attribute values will
    be converted to strings.

    E.g.

        n = transformNode(doc, "node1", x="0", y="1")
        -> DOM node for <node1 x="0" y="1"/>

        n = transformNode(doc, "node1", x=0, y=1+1)
        -> DOM node for <node1 x="0" y="2"/>

        n = transformNode(doc, "node1", node0, x="x0", y="x0", zoo=bar())
        -> DOM node for <node1 x="[node0.x0]" y="[node0.y0]" zoo="[bar()]"/>
    )�
createElement�items�str�setAttribute�getAttribute)	�doc�newTag�node�attrDict�newNode�newAttr�attr�sattr�attrVals	         r�
transformNoderJEsv��(����'�G�!���)�<�
����T����� � ��%�0��'�'��.�G�� � ��'�*:�U�;�
<��Nr!c��eZdZdZej
ejejejejejd�Zdd�Zd�Z
d�Zy)�
EncodedWriterz�
    EncodedWriter(encoding) assumes .write will be called with
    either unicode or utf8 encoded bytes. it will accumulate
    unicode
    )zutf-32z	utf-32-bez	utf-32-lezutf-16z	utf-16-bez	utf-16-lec���tj|�tj|�jx|_}|rd|vsd|vr|j
|j|�yy)N�16�32)�list�__init__�codecs�lookup�name�encoding�write�BOMS)�selfrU�boms   rrQzEncodedWriter.__init__rsT���
�
�d��#)�=�=��#:�#?�#?�?��
���4�8�#�t�x�'7��J�J�t�y�y��*�+�(8r!c��t|�r	|jd�}n"t
|�stdt|�z��|j|�y#tj�\}}}t	|�}~~td|�d|����xYw)N�utf-8zString z not encoded as 'utf-8'
error=z?EncodedWriter.write(%s) argument should be 'utf-8' bytes or str)	r�decode�sys�exc_infor>�
ValueErrorr�asciir6)rX�u�et�ev�tbs     rrVzEncodedWriter.writexs����1�:�
X��X�X�g�&���1���^�af�gh�ai�i�j�j����A���
X� �\�\�^�
��B����W���� �QR�SU�!V�W�W�s�A�8Bc�2�dj|�}|dd�=|S)N���join)rXr1s  rrzEncodedWriter.getvalue�s���G�G�D�M����G��r!N)F)�__name__�
__module__�__qualname__�__doc__rR�	BOM_UTF32�BOM_UTF32_BE�BOM_UTF32_LE�	BOM_UTF16�BOM_UTF16_BE�BOM_UTF16_LErWrQrVr�r!rrLrLdsU����!�!��'�'��'�'��!�!��'�'��'�'�

�D�,��r!rL�nonzeroznon-zero�evenoddzeven-oddc�2�djd�|D��S)N� c3�bK�|]'}d|zjd�jd����)y�w)z%f�0�.N)�rstrip)�.0�as  r�	<genexpr>zpy_fp_str.<locals>.<genexpr>�s*����F�A�d�Q�h�&�&�s�+�2�2�3�7�F�s�-/rg)�argss r�	py_fp_strr��s���8�8�F��F�G�Gr!c�V�eZdZd/d�Zd0d�Zd1d�Zgdfd�Zd�Zd	�Zdde	dfd
�Z
d�Zd�Zgdfd
�Z
d�Zd�Zd�Zd�Zd�Zd�Zd2d�Zd2d�Zd3d�Z		d4d�Z		d5d�Zd�Zd6d�Zd�Zd0d�Zd0d�Zd7d�Zd8d�Zd9d �Z d1d!�Z!d"�Z"e#d�#�fd$�Z$d%�Z%d&�Z&d'�Z'd(�Z(d)�Z)d*�Z*d+�Z+d,�Z,d-�Z-d.�Z.y):r$rc�	��|�_tj|�j�_|�_|j
dd�}|j
di��_|j
dd��_|j
dd�}t�_
|x\�_�_�_
g�_i�_d�_dx�_x�_x�_x�_x�_x�_�_|j
dd�rt0�_nt2�_�fd	��_t7d
�}|j9ddd
�}	|j;dd|	��_�j<j>�_ tCtE|d�tE�j�dd�j�jfzdd��}
tF�j|
d<d|
d<|
jI|j
di��|
jK�D]!\}}�j@jM||��#�j<jOd�}
�j<jQd�}|
jS|��j@jS|
��j<jOd�}�j<jQd�}|jS|��j@jS|��jUtVdtVd��jYtVd��j[d��j]d��j_d�|s�ta�j<d d!�"�}ta�j<d#dd�j�j�$�}|jS|��j@jS|�tCd%�&�}n%tCd�j�jfz�'�}ta�j<d(fd)d*�jzd+�|���_1|rita�j<d(|d,�+��_2�jdjS�jb��j@jS�jd�n%�j@jS�jb��jb�_3y)-a�
        verbose = 0 >0 means do verbose stuff
        useClip = False True means don't use a clipPath definition put the global clip into the clip property
                        to get around an issue with safari
        extraXmlDecl = ''   use to add extra xml declarations
        scaleGroupId = ''   id of an extra group to add around the drawing to allow easy scaling
        svgAttrs = {}       dictionary of attributes to be applied to the svg tag itself
        �useClipF�	fontHacks�extraXmlDeclrf�scaleGroupIdN�
use_fp_strc�B���j|�jdd�S)Nrw�,)r�replace)rrXs �r�<lambda>z$SVGCanvas.__init__.<locals>.<lambda>�s���[�T�[�[�$�%7�%?�%?��C�%H�r!�minidom�svgz-//W3C//DTD SVG 1.0//ENz8http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtdrz
xMinYMin meetz	0 0 %d %dzhttp://www.w3.org/2000/svgz1.0)r%r&�preserveAspectRatio�viewBox�xmlns�version�	fill-rulezhttp://www.w3.org/1999/xlinkzxmlns:xlink�svgAttrs�titlez...�desc�fontName�fontSize�strokeColorr3r�clipPath�clip)�id�rect)r/r0r%r&zclip-path: url(#clip))�style)r��g�groupzscale(1,-1) translate(0,-%d))r��	transformz
scale(1,1))4�verboserRrSrTrUrY�popr�r�r�	_fillModer%r&�size�coder��path�_strokeColor�
_fillColor�
_lineWidth�_font�	_fontSize�_lineCap�	_lineJoinrr��cfp_strr�createDocumentType�createDocumentrA�documentElementr��dictr>�_fillRuleMap�updater=r?r<�createTextNode�appendChild�setFontr�setStrokeColor�
setLineCap�setLineJoin�setLineWidthrJ�	groupTree�	scaleTree�	currGroup)rXr�rUr�rYrr�r��implementation�doctyper��k�vr��textr�r��clipRect�gtkws`                  rrQzSVGCanvas.__init__�s��������
�
�h�/�4�4��
�����(�(�9�U�+�����+�b�1��� �H�H�^�B�7����x�x��r�2��&���.2�2���
�D�K�$�)���	���
���	�"�	"���	"�D�O�	"�d�o�	"��J�	"���	"�*.�-��N��8�8�L��'� �D�K�#�D�K�H���-�i�8��!�3�3�E�+�L�N��"�0�0��e�G�D����8�8�+�+������Q��L��t�{�{�+�(7�'�4�:�:�t�{�{�*C�C�7�!�
��!-�T�^�^� <����"@�����������B�/�0��>�>�#�	'�C�A�a��H�H�!�!�!�A�&�	'����&�&�w�/���x�x�&�&�u�-��
���$�������U�#��x�x�%�%�f�-���x�x�&�&�u�-������������T�"����^�J�/��
�1K�L����N�=�9�:��������������!���$�T�X�X�z�f�E�H�$�T�X�X�v��a��j�j����6�H�� � ��*��H�H� � ��*��5�6�D��[�D�J�J�t�{�{�+C�C�D�D�&�t�x�x����4�t�{�{�B�������*�4�8�8�S�\�Ua�b�D�N��N�N�&�&�t�~�~�6��H�H� � ����0��H�H� � ����0�����r!Nc��t|j|j��}|jj	|dd|j��t|d�r|}nt
|d|j��}|j�}|j}|r|jdd|z�}|j|�||ur|j�yy)	N)rY�	�
)�	addindent�newlrUrV�w)rUz?>)rLrUrYrA�writexml�hasattr�openrr�r�rV�close)rXr)�writer�fr��exds      rr(zSVGCanvas.saves����t�}�}����:�������&�4�T�4�=�=��Q��2�g���A��R��d�m�m�4�A��o�o���������+�+�d�4��8�,�C�	������B�;�
�G�G�I�r!c�\�|xs|j}|xs|j}t|||�S)zuReturn the logical width of the string if it were drawn
        in the current font (defaults to self.font).
        )r�r�r)rXr�fontr�s    r�NOTUSED_stringWidthzSVGCanvas.NOTUSED_stringWidths/��
�!�t�z�z���-�t�~�~���1�d�H�-�-r!rfc��|jj�}|j|�t|j	��}|r|D�cgc]	}||vs�|��}}|r7|j�}|D�cgc]}||vs�|dzt
||�z��}}n!|D�cgc]}|dzt
||�z��}}dj|�dzScc}wcc}wcc}w)Nz: z; �;)r��copyr�rP�keys�splitr>rh)rX�include�excluderr�r�r�r=s        r�_formatStylezSVGCanvas._formatStyle s����
�
���!��
���T���E�J�J�L�!���#�4�!�q�G�|�A�4�D�4���m�m�o�G�37�L�a�1�G�;K�Q�t�V�C��a��M�)�L�E�L�37�8�a�Q�t�V�C��a��M�)�8�E�8��y�y���#�%�%��
5��M��8s�	C	�C	�1	C�;C�Cc��|S)zKI don't think this was ever needed; seems to have been copied from renderPSrs)rXrs  r�_escapezSVGCanvas._escape-s���r!c��y)zXCalculate the path for an arc inscribed in rectangle defined
        by (x1,y1),(x2,y2).N)�abs)rX�x1�y1�x2�y2�startAng�extent�xScale�yScaler/r0�codeline�arc�datas              r�_genArcCodezSVGCanvas._genArcCode1s��	r!c���i}|rt||d<t|jd|j|j	|���}|r|j||�}|jj|�d|_y)Nr�r��rr�rf)r�rJrAr�r��	_add_linkr�r�)rXr�r��	link_info�styles�fillMode�xtrar�s        r�_fillAndStrokezSVGCanvas._fillAndStrokeGsm����� ,�X� 6�D����T�X�X�v��i�i�t�0�0��8�����>�>�$�	�2�D����"�"�4�(���	r!c�b�dddd�}|j|k7r||_|||jd<yy)N�butt�round�square�rrr3�stroke-linecap)r�r��rXr��valss   rr�zSVGCanvas.setLineCapUs9���G�x�0���=�=�A���D�M�+/��7�D�J�J�'�(�r!c�b�dddd�}|j|k7r||_|||jd<yy)N�miterr��bevelr�r�)r�r�r�s   rr�zSVGCanvas.setLineJoin[s9���W��0���>�>�Q���D�N�+/��7�D�J�J�'�(�r!c��t|ttf�r/djt	t
||g��|jd<yt|ttf�rft|�dkDrW|dk\sJd��djt	t
|��|jd<|dkDrt|�|jd<yyyy)z7Two notations. Pass two numbers, or an array and phase.�, zstroke-dasharrayrzphase is a length in user spacezstroke-dashoffsetN)
�
isinstance�float�intrh�mapr>r��tuplerPr5)rX�array�phases   r�setDashzSVGCanvas.setDashas����e�U�3�K�(�-1�Y�Y�s�3�%���7Q�-R�D�J�J�)�*�
��u�T�l�
+��E�
�Q���A�:�@�@�@�:�-1�Y�Y�s�3���-G�D�J�J�)�*��Q�w�25�e�*��
�
�.�/��1?�
+r!c�@�||_|dk(rd|jd<y|j|j|j}}}d|dz|dz|dzfz|jd<|j
}|dk7rd|z|jd<yd|jvr|jd=yy)N�none�stroke�rgb(%d%%,%d%%,%d%%)�dr�%szstroke-opacity)r�r��red�green�blue�normalizedAlpha�rX�colorr1r��b�alphas      rr�zSVGCanvas.setStrokeColorls���!����D�=�#)�D�J�J�x� ��i�i����e�j�j�!�q�A�#8�A�c�E�1�S�5�!�C�%�;P�#P�D�J�J�x� ��)�)�E��a�x�/3�e�|��
�
�+�,�!�T�Z�Z�/��J�J�/�0�0r!c�@�||_|dk(rd|jd<y|j|j|j}}}d|dz|dz|dzfz|jd<|j
}|dk7rd|z|jd<yd|jvr|jd=yy)Nr�fillrrrrzfill-opacity)r�r�rrrrrs      r�setFillColorzSVGCanvas.setFillColorys�������D�=�!'�D�J�J�v���i�i����e�j�j�!�q�A�!6�!�C�%��3���#��9N�!N�D�J�J�v���)�)�E��a�x�-1�E�\��
�
�>�*��4�:�:�-��J�J�~�.�.r!c�>�||_t||jd<y)Nr�)r�r�r�)rXr�s  r�setFillModezSVGCanvas.setFillMode�s�����".�q�/��
�
�;�r!c�P�||jk7r||_||jd<yy)Nzstroke-width)r�r�)rXr%s  rr�zSVGCanvas.setLineWidth�s(���D�O�O�#�#�D�O�).�D�J�J�~�&�$r!c���|j|k7s|j|k7r�||_||_|j}tD]
}||vs�||=�||jvr|j|ni}t|t�r2|jt|jj���|r+|j�D]\}}d|z}|tvs�|||<�d|vr||d<d|z|d<yy)Nzfont-zfont-familyz%spxz	font-size)r�r�r��TEXT_STYLESr�rrr��iterr�r=)rXr�r�r�r�r�r�r}s        rr�zSVGCanvas.setFont�s����:�:������8�!;��D�J�%�D�N��J�J�E� �
!����:��a��
!�04�t�~�~�/E�t�~�~�d�+�2�H��$�x�(�����T�]�]�%8�%8�%:� ;�<��#�>�>�+�%�C�A�a���	�A��K�'�#$��a��%��E�)�'+��m�$�!'�(�!2�E�+��#"<r!c�z�t|t�sJ�t|jdfi|��}|j	|�|S)Nr})rr�rJrAr�)rX�
dom_objectr��links    rr�zSVGCanvas._add_link�s:���)�T�*�*�*��T�X�X�s�8�i�8������$��r!c
�X�|jrtd�t||�}	t||�}
i}t|jdf|	|
t||�|	z
t||�|
z
|j
t�d�|��}|r|j||�}|jj|�y)z)Draw a rectangle between x1,y1 and x2,y2.z+++ SVGCanvas.rectr�)r/r0r%r&r�N)r��print�minrJrA�maxr��AREA_STYLESr�r�r�)
rXr�r�r�r��rx�ryr��	_svgAttrsr/r0rr�s
             rr�zSVGCanvas.rect�s����<�<��3�4���2�J����2�J�����T�X�X�v�>��1�C��2�J�q�L��R���A���#�#�K�0�>�3<�>����>�>�$�	�2�D����"�"�4�(r!c���t|jdf||||z
||z
|||jt�d�|��}	|r|j	|	|�}	|j
j
|	�y)z�Draw a rounded rectangle between x1,y1 and x2,y2.

        Corners inset as ellipses with x-radius rx and y-radius ry.
        These should have x1<x2, y1<y2, rx>0, and ry>0.
        r�)r/r0r%r&r*r+r�N�rJrAr�r)r�r�r�)
rXr�r�r�r�r*r+r�r,r�s
          r�	roundRectzSVGCanvas.roundRect�sm���T�X�X�v�?��B�b��e�B�r�E�b�R��#�#�K�0�?�4=�?����>�>�$�	�2�D����"�"�4�(r!c	��|dk(ryt|�}|jrtd�|dk(xs|dk(xs|dk(xs|dk(}	|dk(xs|dk(xs|dk(xs|dk(}
|jdk7r|	s|jdk7�r�|
�r�|d	vr}t||j|j�}|d
k(r||z}nQ|dk(r	||dzz}nC|d
k(r'|t||||j|j�z}ntdt|�z��|j|�}|jt�}|dk7r|d|j|||�zz}|	r||jt�z
}n|dz
}|
r||jt �z
}n|dz
}t#|j$df|||dd|zzd�|��}
|j$j'|�}|
j)|�|r|j+|
|�}
|j,j)|
�yyy)N�z+++ SVGCanvas.drawStringrr3��r�)�start�	inherited�left�end�middle�@�numericzbad value for text_anchor z rotate(%s);z fill:none;z
 stroke:none;r�ztranslate(0,%d) scale(1,-1))r/r0r�r�)rr�r&r�r�rr�r��
numericXShiftr_r>r�r�r r�EXTRA_FILL_STYLES�EXTRA_STROKE_STYLESrJrAr�r�r�r�)rXrr/r0�angler��text_anchor�textRenderModer,�needFill�
needStroke�textLen�str��contents               r�
drawStringzSVGCanvas.drawString�s(���1��f��Q�K���<�<��9�:�!�1�$�c���(9�c�^�Q�=N�c�R`�bc�Rc��#�Q�&�e�.�!�*;�e�~�q�?P�e�Tb�de�Te�
��O�O�T�!�h�D�4E�4E�t�4K�PZ��"@�@�%�a��
�
�4�>�>�B����%���L�A� �(�*�����O�A� �)�+���{�1�W�T�Z�Z����W�W�A�$�%A�C��DT�%T�U�U����Q��A��"�"�;�/�B���z���$�+�+�e�Q��*B�B�B�r���d�'�'�(9�:�:���m�#����d�'�'�(;�<�<���o�%��!����6���q��7�1�Q�3�?����D�
�h�h�-�-�a�0�G����W�%���~�~�d�I�6���N�N�&�&�t�,�IQ[�4Kr!c�f�|jrtd�|j|||f||||d�|��y)Nz+++ SVGCanvas.drawCentredString�r?r�r@rA�r�r&rG)	rXrr/r0r?r@r�rAr,s	         r�drawCentredStringzSVGCanvas.drawCentredString�s;���<�<��@�A������!�A�	<�E�Y�K�-�	<�1:�	<r!c�f�|jrtd�|j|||f||||d�|��y)Nz+++ SVGCanvas.drawRightStringrIrJ)	rXr�r/r0r?r@r�rAr,s	         r�drawRightStringzSVGCanvas.drawRightString�s;���<�<��>�?������Q�q�	<�u�	�{�-�	<�1:�	<r!c�:�|jj|�}y)zAdd a comment.N)rA�
createComment)rXr��comments   rrPzSVGCanvas.comments���(�(�(�(��.�r!c�@�t�}|j|d�ttj|j���}|jjt|jd||||d|zd|jddddd|d|zz�z�	��y)
N�png�imagezdata:image/png;base64,�
matrix(%s)rr���r3)r/r0r%r&�hrefr�)rr(r�base64�	b64encoderr�r�rJrAr�)rXrSr/r0r%r&�embed�bufs        r�	drawImagezSVGCanvas.drawImage
s����i��
�
�
�3�u���v�'�'�����7�8�����"�"��d�h�h�w��!�%�v�1�#�5�*�T�\�\�!�A�a��1�V�A�a�C�Z�-P�P��	r!c��|jdk7rp	t|jdd|j||��d|j||��d�|jt���}|j
j
|�yy)Nr��M � L z Zr�)r�rJrAr��LINE_STYLESr�r�r�)rXr�r�r�r��liner�s       rr`zSVGCanvas.linesl������$��
!����6�#'�<�<��2�#6�t�|�|�B�r�7J�K��'�'��4�6�D�
�N�N�&�&�t�,�%r!c���t|jd||zdz||zdz||z
dz||z
dz|jt���}|r|j	||�}|j
j
|�y)z{Draw an orthogonal ellipse inscribed within the rectangle x1,y1,x2,y2.

        These should have x1<x2 and y1<y2.
        �ellipser:)�cx�cyr*r+r�Nr.)rXr�r�r�r�r�rbs       rrbzSVGCanvas.ellipse"st��
 ����)��2��s�{��2��s�{��2��s�{��2��s�{��#�#�K�0�2����n�n�W�i�8�G����"�"�7�+r!c
��t|jd||||jt���}|r|j	||�}|j
j
|�y)N�circle)rcrdr1r�r.)rX�xc�ycr1r�rfs      rrfzSVGCanvas.circle0sP���t�x�x���b�A��#�#�K�0�2����^�^�F�I�6�F����"�"�6�*r!c
��	y�N)rr�r�r6r�)rXr�r�r�r��x3�y3�x4�y4�closedr�r�s            r�	drawCurvezSVGCanvas.drawCurve:s���r!c��||zdz||zdz}	}||z
dz||z
dz}}
|
t|tzdz�z|z}|t|tzdz�z|	z}
|
t||ztzdz�z|z}|t||ztzdz�z|	z}|j}gj}|r|d|||	��d|||����|r"|d||
|�d|dk\d|||
�fz�n)|d|||
�||
|�d|dk\d|||
�fz�|r|d|||	�z�t|jd	d
j|j�|j���}|jj|�y)
aDraw a partial ellipse inscribed within the rectangle x1,y1,x2,y2.

        Starting at startAng degrees and covering extent degrees. Angles
        start with 0 to the right (+x) and increase counter-clockwise.
        These should have x1<x2 and y1<y2.
        r:�r]r^zA %s %d %d %d %srzM %s A %s %d %d %d %s ZzL %s Zr�rwr�N)�cos�pi�sinr�r6rJrArh�__self__r�r�r�)rXr�r�r�r�r�r��
fromcenterrcrdr*r+�mx�my�ax�ayr�rr�s                   r�drawArczSVGCanvas.drawArcGs����R�%���r�"�u�c�k�B���R�%���r�"�u�c�k�B��
�#�h�r�k�#�o�&�
&��
+��
�#�h�r�k�#�o�&�
&��
+��
�#�x����*�3�.�/�
/�"�
4��
�#�x����*�3�.�/�
/�"�
4���,�,���I�I���
�W�R��_�g�b�"�o�>�?��
� ��r�2���6�3�;��7�2�r�?�C�D�
E�
�'��r�2����B���F�C�K��G�B�PR�O�T�U�
V��
�h���R��(�)��T�X�X�v��h�h�q�z�z�"�$�*;�*;�*=�?�����"�"�4�(r!c�v�t|�dk\sJd��|jdk7s|jdk7r�dj|D�cgc]
}t	|���c}�}t|jd||jt���}|r|j||�}|jj|�yycc}w)Nr3z"Polygon must have 2 or more pointsr�polygon��pointsr�)r5r�r�rhrrJrAr�r)r�r�r�)rXr�ror��p�pts�polylines       rr~zSVGCanvas.polygonis����6�{�a��E�!E�E�����d�"�d�o�o�t�&;��)�)��8�A�V�Q�Z�8�9�C�$�T�X�X�y��$�"3�"3�K�"@�B�H���>�>�(�I�>���N�N�&�&�x�0�'<��8s�B6c��yrj)r�r�r6r)rX�lineListrr%r�r`s      r�lineszSVGCanvas.linesxs��r!c	�4�t|�dk\sJd��|jdk7rodj|D�cgc]
}t|���c}�}t	|j
d||j
td����}|jj|�yycc}w)Nrz#Polyline must have 1 or more pointsrr�)rr)
r5r�rhrrJrAr�r)r�r�)rXr�r�r�r�s     r�polyLinezSVGCanvas.polyLine�s����6�{�a��F�!F�F������$��)�)��8�A�V�Q�Z�8�9�C�$�T�X�X�z��$�"3�"3�K�T�"3�"J�L�H��N�N�&�&�x�0�	%��8s�B)r�c���|jrtd�|j}t|jdfi|��}|j|�||_|jrtd�|S)Nz+++ begin SVGCanvas.startGroupr�z+++ end SVGCanvas.startGroup)r�r&r�rJrAr�)rXrDr�r�s    r�
startGroupzSVGCanvas.startGroup�sY���<�<��?�@��N�N�	��d�h�h��8�x�8�����e�$�����<�<��=�>��r!c�p�|jrtd�||_|jrtd�yy)Nz+++ begin SVGCanvas.endGroupz+++ end SVGCanvas.endGroup)r�r&r�)rXr�s  r�endGroupzSVGCanvas.endGroup�s)���<�<��=�>�"����<�<��;�<�<r!c	��|jrtd||||||�|jjd�}||||||fdk7r;d|j	||||||�z}|jjd|�d|���yy)Nz!!! begin SVGCanvas.transformr�)rrrrrrrTrw)r�r&r�r@r�r?)	rXr}rr*r�er��tr�ts	         rr�zSVGCanvas.transform�s����<�<��>��1�a��A�q�Q�
�^�^�
(�
(��
5��
�q�!�Q��1��!3�3��t�|�|�A�a��!�A�a�8�8�A��N�N�'�'���A�5F�G�4r!c
��||fdk7rN|jjd|jjd��dd|j||�z���yy)N)rrr�rwz
translate(%s))r�r?r@r��rXr/r0s   r�	translatezSVGCanvas.translate�sP��
�a�5�E�>��N�N�'�'���>�>�.�.�{�;�#�d�l�l�1�Q�&7�7�69�
:�r!c
��||fdk7rQ|jjd|jdjd��dd|j	||�z���yy)N)rrr�rUrwz	scale(%s))r�r?�groupsr@r�)rX�sx�sys   r�scalezSVGCanvas.scale�sU���r�7�e���N�N�'�'���{�{�2��3�3�K�@�#�d�l�l�2�r�&:�:�6<�
=�r!c�R�|jd|j||�zz|_y)NzM %s �r�rr�s   r�moveTozSVGCanvas.moveTo��"���I�I��$�+�+�a��*;� ;�;��	r!c�R�|jd|j||�zz|_y)NzL %s r�r�s   r�lineTozSVGCanvas.lineTo�r�r!c
�Z�|jd|j||||||�zz|_y)NzC %s r�)rXr�r�r�r�rkrls       r�curveTozSVGCanvas.curveTo�s*���I�I��$�+�+�b�"�b�"�b�"�*M� M�M��	r!c�,�|jdz|_y)NzZ )r��rXs r�	closePathzSVGCanvas.closePath�s���I�I��$��	r!c��yrjrsr�s r�	saveStatezSVGCanvas.saveState����r!c��yrjrsr�s r�restoreStatezSVGCanvas.restoreState�r�r!))�,r�r[rFrj)NN)�r�N)rNr7r)rr9Nr)rr8Nr)T)r)rihr)rN)/rirjrkrQr(r�r�r�r�r)r�r�r�r
r�rrr�r�r�r�r/rGrKrMrPr[r`rbrfrpr|r~r�r�r�r�r�r�r�r�r�r�r�r�r�r�rsr!rr$r$�s��j(�X�$.�$&�r�&���,)*�T��VZ�
�3�3��a�	=�1�/�2�/�
3�(�)�")� +-�Z?G�+,�<�?D�+,�<�/�
�
-�,�+�)� )�D1�P�1�"&��!3��=�
H�:�=�<�<�N�%�
�
r!r$c��eZdZdZd�Zd�Zdddddd	d
d�Zd�Zd
�Zd�Z	d�Z
d�Zd�Zd�Z
d�Zd�Zd�Zefd�Zd�Zd�Zy)r,z%This draws onto an SVG document.
    c��d|_y)Nr)r�r�s rrQz_SVGRenderer.__init__�s	����r!c� �|jrtd|z�|jjd|z�|jjj�}t
|t�r|js	t|�}|jj|�|j|i�|j|�|jj�}t
|t�r|js	|jjd|z�|j�D]8\}}||j vs�t#|j|j ||��:||j_|jrtd|z�yy)zGThis is the recursive method called for each node in the tree.
        z#### begin _SVGRenderer.drawNode(%r)z
begin node %rzend node %rz!### end _SVGRenderer.drawNode(%r)N)r�r&�_canvasrPr�r�rr�
isClipPathr�_tracker�push�applyStateChanges�drawNodeDispatcherr�r=�	_restores�setattr)rXrCr��deltas�rDeltasr�r�s       r�drawNodez_SVGRenderer.drawNode�s8���<�<��D�t�K�L������_�T�1�2����"�"�'�'�)���4��&�4�?�?���t�$���
�
���6�"����v�r�*�	
����%��-�-�#�#�%���4��&�4�?�?�������]�4�/�0��M�M�O�	:�D�A�q��D�N�N�"�����T�^�^�A�%6�q�9�	:�#������<�<��B�T�I�J�<r!r�r�r�r�r�r�r�)r��strokeWidth�
strokeLineCap�strokeLineJoin�	fillColorr�r�c�X�t|dd�xsd}t|dd�xsd}|r||dd�Sy)N�hrefURLrf�	hrefTitle�_top)z
xlink:hrefzxlink:title�target)�getattr)rX�obj�urlr�s    r�_get_link_info_dictz _SVGRenderer._get_link_info_dict�sA���c�9�b�)�/�R����[�"�-�3����"%�E�F�K�K�$r!c���|jrtd�|jj�}|jj�d\}}}}}}|j
�D]6}	t|	t�r|	j�}
n|	}
|j|
��8|jj||||||�|jj|�|jrtd�yy)Nz ### begin _SVGRenderer.drawGroupr�z### end _SVGRenderer.drawGroup)
r�r&r�r�r��getState�getContentsrr
�provideNoder�r�r�)rXr�r�r}rr*rr�r��	childNode�node2s           r�	drawGroupz_SVGRenderer.drawGroup	s����<�<��A�B��L�L�+�+�-�	��=�=�1�1�3�K�@���1�a��A�q��*�*�,�	!�I��)�X�.�!�-�-�/��!���M�M�%� �	!�	
�����q�!�Q��1�a�0������i�(��<�<��?�@�<r!c�B�|j|�}t|di�}|j|jcxk(rdk(rhnne|jj
|j|j|j|jz|j|jzfd|i|��y|jj|j|j|j|jz|j|jz|j|jfd|i|��y)Nr,rr�)r�r�r*r+r�r�r/r0r%r&r/)rXr�r�r�s    r�drawRectz_SVGRenderer.drawRects����,�,�T�2�	��4��B�/���7�7�d�g�g�"��"��D�L�L����F�F�D�F�F��F�F�4�:�:�%�t�v�v�d�k�k�'9�
\�EN�
\�RZ�
\�
#�D�L�L�"�"��F�F�D�F�F��F�F�4�:�:�%�t�v�v�d�k�k�'9��G�G�T�W�W�
5�(�	
5�,4�	
5r!c
� �|jj�}|d|j|j|jf\}}}}|j
j|||f|j|�|t|dd�d�t|di���y)N�
textAnchorrAr)r�r@rAr,)	r�r�r/r0r�r�rGr�r�)rX�	stringObj�Sr@r/r0r�s       rrGz_SVGRenderer.drawString*s����M�M�"�"�$��"#�L�/�9�;�;�	���Y�^�^�"[���Q��4��������Q�q�	9�4�3K�3K�I�3V�'��	�JZ�[\�8]�	9��i��B�7�	9r!c��|jjrG|jj|j|j|j
|j�yyrj)r�r�r`r�r�r�r�)rXr`s  r�drawLinez_SVGRenderer.drawLine1s<���<�<�$�$��L�L���d�g�g�t�w�w�������A�%r!c��|jj|j|j|j|j|���y�N)r�)r�rfrcrdr1r�)rXrfs  r�
drawCirclez_SVGRenderer.drawCircle5s5�������V�Y�Y��	�	�6�8�8�t�G_�G_�`f�Gg��hr!c	��|j�\}}}|dk(s|��|dk(s|��|js�|j|j|j|j
|jf\}}}}}	|jxs|j}||z
||z
}}
||z||z}
}|	|z
}|jj|
|||
||d��y|j�}t|t�r|j|�y|j|�y)Nrr)rw)�
_xtraRadii�annular�centerx�centery�radius�startangledegrees�endangledegrees�yradiusr�r|�	asPolygonrr�drawPath�drawPolygon)rX�wedger��radius1�yradius1r�r�r�r�r�r�r�r�r�r�r8s                r�	drawWedgez_SVGRenderer.drawWedge8s��%*�%5�%5�%7�"���(��Q�J�'�/��!��x�?O�Y^�Yf�Yf�
�]�]�E�M�M�5�<�<��9P�9P�RW�Rg�Rg�
g�
I�G�W�f�&7���m�m�3�u�|�|�G��������R��������R�$�'8�8�F��L�L� � ��R��R�1B�F�WX� �Y����!�A��!�D�!��
�
�a� �� � ��#r!c��|jjr/|jjt|j��yyrj)r�r�r�r:r��rXr�s  r�drawPolyLinez_SVGRenderer.drawPolyLineIs/���<�<�$�$��L�L�!�!�/�!�(�(�";�<�%r!c	�*�|j|jz
}|j|jz}|j|jz
}|j|jz}|jj|||||j
|���yr�)rcr*rdr+r�rbr�)rXrbr�r�r�r�s      r�drawEllipsez_SVGRenderer.drawEllipseMsr��
�Z�Z�'�*�*�
$��
�Z�Z�'�*�*�
$��
�Z�Z�'�*�*�
$��
�Z�Z�'�*�*�
$�������R��2�b�D�4L�4L�W�4U��Vr!c��|jjt|j�d|j	|���y)Nr)ror�)r�r~r:r�r�r�s  rr�z_SVGRenderer.drawPolygonUs0�������_�Q�X�X�6�q�D�Ld�Ld�ef�Lg��hr!c����	�
�ddlm�	|j}|j|j|j
|jf�
|�t�dt�}|j��}t�dd�}�	�
�fd�}|dk(r'|�|jg�j||��y|d	k(r)|d
��|jg�j||��y|�}|sQ|j}|jd�	d}|jg�j||��|j|�y|jg�j||��y#|j|�wxYw)Nr)�_renderPathr��	autocloserfc������fi|��Srjrs)rr��	drawFuncsr�s ���r�rPz!_SVGRenderer.drawPath.<locals>.rPas����t�Y�7�$�7�7r!r�)r�r�r��pdfT)�
forceClose)�reportlab.graphics.shapesr�r�r�r�r�r�r�rr�r�r�r�r)rXr�r�r*r�r�r��isClosed�ofcr�r�s `       @@rr�z_SVGRenderer.drawPathXs6���9��L�L���X�X�q�x�x����A�K�K�@�	����t�J�}�=�H��,�,�T�2�	��D��R�0�	�	8��e���D�
���R�d�o�o��U]��^�
��
��$��
���R�d�o�o��U]��^��t�H���l�l�����t�$�(� $�I��$�$�R�d�o�o��]e�$�f��N�N�3�'�� � ��$�/�/�Y�Ya� �b���N�N�3�'�s�=!E�E#c��|j}t|t�r<|rtjj	|�syt�j
|�}nt|d�r|}ny|j\}}|j|j}}|�|}|�|}|jj||j|j||d��y)N�convertT)rY)r�rr>�os�isfilerr�r�r�r%r&r�r[r/r0)rXrSr��im�srcW�srcH�dstW�dstHs        rr[z_SVGRenderer.drawImagevs����z�z���d�3���R�W�W�^�^�D�1�F���!�!�$�'�B�
�T�)�
$��B���W�W�
��d��[�[�%�,�,�d���<����<��������r�5�7�7�E�G�G�T�4�t��Lr!c���|j�D�]�\}}|dk(r�
|dk(r|jj|��.|dk(r|jj|��O|dk(r|jj	|��p|dk(r|jj|���|dk(r�|rgt
|ttf�r2t|�dk(r$t
|dttf�r|d	}|d}nd	}|jj||���|jj���|d
k(r|jj|���=|dvrj|jd|jj�}|jd
|jj�}|jj||����|dk(s���|jj!|����y)z\This takes a set of states, and outputs the operators
        needed to set those propertiesr�r�r�r�r��strokeDashArrayr3rrr�)r�r�r�r�r�N)r=r�r�r�r�r�rrPrr5r
r�getr�r�r�r)rX�delta�newState�key�valuer	�fontname�fontsizes        rr�z_SVGRenderer.applyStateChanges�s��� �+�+�-�	0�J�C���k�!���
�%����+�+�E�2��
�%����)�)�%�0���'����'�'��.��(�(����(�(��/��)�)��!�%��e��5�#�e�*�a�-�J�W\�]^�W_�af�gk�`l�Lm� %�a��� %�a��� !���L�L�(�(��u�5��L�L�(�(�*���#����)�)�%�0��0�0� �9�9�Z����1C�1C�D�� �9�9�Z����1G�1G�H�����$�$�X�x�8��
�"����(�(��/�;	0r!N)rirjrkrlrQr�r�r�r�r�rGr�r�r�r�r�r�rr�r[r�rsr!rr,r,�s|����K�@ .�\�Zd�!,��QX�&�(�I��>A� 5�"9�B�i�$�"=�W�i�'4�c�<
M�!0r!r,c���tjj|�stj|�ddlm}g}t
|�D]>}|dddk(s�t||�}|�}t|dd�}|j||f��@d}|D]9\}}tjj|d|z�}	t||	�|dz
}�;dd	lm}
|
�}t|tjj|d
��ddl
m}ddlm}|�}
||
j"|
j$�}|j'|
�t|tjj|d
��y)Nr)�
testshapes�
�
getDrawingrlrfzrenderSVG_%d.svgr)�getDrawing01ztest.svg)�RL_CorpLogo)�Drawingzcorplogo.svg)r�r��isdir�mkdir�reportlab.graphicsr�dirr�r6rhr�reportlab.graphics.testshapesr�reportlab.lib.corprr�rr%r&�add)�outDirr�drawings�funcname�funcr-�	docstringr9r�filenamerrr�rls              r�testr �s,���7�7�=�=�� �
�����-��H��
�O�2���A�b�>�\�)��:�h�/�D��f�G���Y�r�2�I��O�O�W�i�0�1�2�	
�A�"����I��7�7�<�<��'9�A�'=�>���1�h��	�Q����
;���A��q�"�'�'�,�,�v�j�1�2�.�1�	��B��������#�A��E�E�"�I��q�"�'�'�,�,�v�n�5�6r!�__main__rj)zout-svg):rl�mathr]r�rRrW�iorr�reportlab.pdfbase.pdfmetricsr�reportlab.lib.rl_accelr�reportlab.lib.utilsr�reportlab.graphics.renderbaserr	r
r�rrr
�	reportlabrrrr�reportlab.pdfgen.canvasrr�renderPMr�xml.domrrursrtr�r)r_r r>r=rr rr'r:rJrPrLr�r�r$r,r rirsr!r�<module>r,sd��	��%�$�$� �4�)�(�V�V�D�D�'��<�<�@��(��h�h��
�h�h��	�W�W��D�J�J�L��g�m�m�o��L�R�R�T��l�r�r�t��'�-�-�/��"+�!7�!7��$-�#9�#9�����1G�1G�R�

��>$�D�$�N	�y��I��9��y��I��9�

��H�f
�f
�Pg0�8�g0�R 7�D�Z���F�r!

Zerion Mini Shell 1.0