%PDF- %PDF-
Mini Shell

Mini Shell

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

�

��d�t���dZdZddl�ddlmZmZddlmZmZddl	m
Z
ddlmZdd	l
mZmZdd
lZdd
lZddlmZmZddlmZmZmZmZd'd
�Z	eej8�Zd�Zd�Zej@fd�Z!ddlm"Z"Gd�de"�Z#d�Z$d�Z%d�Z&d'd�Z'dZ(Gd�d�Z)ddd
ej@ej8fd�Z*ddd
ej@ej8fd�Z+ddd
ej@ej8fd�Z,d ddd
ej@ej8fd!�Z-d ddd
ej@ej8fd"�Z.e-Z/d(d#�Z0e1d$k(r
e0d%�&�y
y
#e$rd
ZY��wxYw))z3.3.0a$Render drawing objects in common bitmap formats

Usage::

    from reportlab.graphics import renderPM
    renderPM.drawToFile(drawing,filename,fmt='GIF',configPIL={....})

Other functions let you create a PM drawing as string or into a PM buffer.
Execute the script to see some test drawings.�)�*)�
getStateDelta�renderScaledDrawing)�getFont�
unicode2T1)�	isUnicode)�	rl_config�)�setFont�
RenderPMErrorN)�BytesIO�StringIO)�sin�cos�pi�ceilc�h�|stj}|dk(r	ddl}|Sd|j
�vr	ddl}|Std|����#t$r)}	ddl}n#t$rtd��wxYwYd}~|Sd}~wwxYw#t$r-}	ddl}n#t$rtd|�d���wxYwYd}~|Sd}~wwxYw)N�	_renderPMrz�Cannot import desired renderPM backend, {backend}.
No module named _rl_renderPM
it may be badly or not installed!
You may need to install development tools
or seek advice at the users list see
https://pairlist2.pair.net/mailman/listinfo/reportlab-users�cairoz'cannot import desired renderPM backend z^
Seek advice at the users list see
https://pairlist2.pair.net/mailman/listinfo/reportlab-userszInvalid renderPM backend, )r	�renderPMBackend�_rl_renderPM�ImportError�	rlPyCairor�lower)�backend�M�errMsgs   �=/usr/lib/python3/dist-packages/reportlab/graphics/renderPM.py�
_getPMBackendrs���i�7�7�G����	@�$�.
�H�
�G�M�M�O�	#�	@�!�
�H��8��	�B�C�C��+�		@�
@�%���
@�#�%?�@�@�
@��&�(
�H��-		@���	@�
@�(���
@�#�(O�PW�y�Y<�%?�@�@�
@��)�
�H��	@�sR�A�A;�	A8�A�A3�A*�*A3�3A8�;	B1�B
�	B,�
B#�#B,�,B1c�<�	ddlm}|S#t$rddl}Y|SwxYw)Nr��Image)�PILr"rr!s r�	_getImager$<s*�����L������L��s�
�
�c��|rYdtd|jz�zdzdtd|jz�zdzzdtd|jz�zzS|S)N���)�int�red�green�blue)�cs r�	Color2Hexr.Cs_���4��C����I��&�2�-�4��C����K�8H�3H�Q�2N�O�SW�X[�\_�`a�`f�`f�\f�Xg�Sg�h�
h��H�c�V�t�}|jt|�||||��y)z
As it says��showBoundaryN)�_PMRenderer�drawr)�drawing�canvas�x�yr2�Rs      rr4r4Is%���
�A��F�F��w�'���A�L�F�Qr/)�Rendererc�f�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zdd�Z
d�Zd
�Zd�Zd�Zy)r3z�This draws onto a pix map image. It needs to be a class
    rather than a function, as some image-specific state tracking is
    needed outside of the state info in the SVG model.c�X�|jj�|j�y�N)�_tracker�pop�
applyState��selfs rr?z_PMRenderer.popTs���
�
�������r/c�p�t|�}|jj|�|j�yr=)rr>�pushr@)rB�node�deltass   rrDz_PMRenderer.pushXs(���t�$���
�
���6�"����r/c���|jj�}|d|j_|d|j_|d}|�||j_|jj
|d�|d|j_|d|j_|d|j_	|d}|sd}nDt|ttf�s|f}t|�d	k7st|d
ttf�sd|f}||j_|d}|�||j_|jj!|d
�|jj#|d|d�y)N�ctm�strokeWidth�
strokeOpacity�strokeColor�
strokeLineCap�strokeLineJoin�fillMode�strokeDashArray�r
r�fillOpacity�	fillColor�fontName�fontSize)r>�getState�_canvasrHrIrJ�setStrokeColor�lineCap�lineJoinrN�
isinstance�list�tuple�len�	dashArrayrQ�setFillColorr)rB�s�alpha�das    rr@z_PMRenderer.applyState]sB���M�M�"�"�$���U�8�����#$�]�#3���� ��/�"����).�D�L�L�&����#�#�A�m�$4�5� ��1����� !�"2� 3����� !�*�
�����
� �
!����B��b�$�u��.��S���2�w��z��B�q�E�4��,�!?���U��!#������-� ����',�D�L�L�$����!�!�!�K�.�1������Q�z�]�A�j�M�:r/c���|jjd}|jjdd||fzx|d<|d<|jj	|�|j�y)N���r��	transformrH)r>�	_combinedrV�_baseCTMrDr@)rBr7r8rFs    r�	initStatez_PMRenderer.initStatews_�����(�(��,��.2�l�l�.C�.C�A�a�.H�!�A��.N�N��{��f�U�m��
�
���6�"����r/c�h�|j|�|j|�|j�y)zEThis is the recursive method called for each node
        in the treeN)rD�drawNodeDispatcherr?)rBrEs  r�drawNodez_PMRenderer.drawNode}s*��
	
�	�	�$��	
����%�	
���
r/c�~�|j}|j|jcxk(rdk(r@nn=|j|j|j
|j|j�y|j|j|j
|j|j|j|j�y)Nr)	rV�rx�ry�rectr7r8�width�height�	roundRect)rBrpr-s   r�drawRectz_PMRenderer.drawRect�sp���L�L���7�7�d�g�g�"��"�
�F�F�4�6�6�$�&�&�$�*�*�d�k�k�:�
�K�K����t�v�v�t�z�z�4�;�;�������Qr/c��|jj|j|j|j|j
�yr=)rV�line�x1�y1�x2�y2)rBrvs  r�drawLinez_PMRenderer.drawLine�s*�������$�'�'�$�'�'�$�'�'�$�'�'�:r/c�^�|j}t|t�rK|rtjj	|�syt�j
|�jd�}nt|d�r|jd�}ny|j\}}|j|j}}|�|}|�|}|jj|j|j|||jj dk(r|n(t|d�r|j"n|j$�||d�y)N�RGB�convertr�tobytes�)�pathrZ�str�os�isfiler$�openr~�hasattr�sizerqrrrV�	_aapixbufr7r8�_backendr�tostring)rB�imager��im�srcW�srcH�dstW�dstHs        r�	drawImagez_PMRenderer.drawImage�s����z�z���d�3���R�W�W�^�^�D�1�F���!�!�$�'�/�/��6�B�
�T�)�
$����e�$�B���W�W�
��d��[�[�%�,�,�d���<����<��������������$���|�|�,�,�k�9��N���9�(=�"�*�*�2�;�;�Q��d�A�		r/c��|j}|j|j|j|j�|j�yr=)rV�circle�cx�cy�r�fillstrokepath)rBr�r-s   r�
drawCirclez_PMRenderer.drawCircle�s3���L�L��	������6�9�9�f�h�h�/�	���r/c�~�|j}t|�dk\sJd��|j}|j�|j	|d|d�tdt|�d�D]}|j
||||dz��|r |j�|j�|j�y)NrPz#Polyline must have 1 or more pointsrr
)
�pointsr]rV�	pathBegin�moveTo�range�lineTo�	pathClose�pathFill�
pathStroke)rB�polyline�_doClose�Pr-�is      r�drawPolyLinez_PMRenderer.drawPolyLine�s����O�O���1�v��{�A�A�A�{��L�L��	���
�	����1��q��t���q�#�a�&�!�$�	#�A�
�H�H�Q�q�T�1�Q�q�S�6�"�	#��
�K�K�M�
�J�J�L�	���r/c��|j}|j|j|j|j|j
�|j
�yr=)rV�ellipser�r�rnror�)rBr�r-s   r�drawEllipsez_PMRenderer.drawEllipse�s9��
�,�,��	�	�	�'�*�*�g�j�j�'�*�*�W�Z�Z�@�	���r/c�*�|j|d��y)Nr
)r�)r�)rB�polygons  r�drawPolygonz_PMRenderer.drawPolygon�s�����'�1��-r/c	�6�|j}|j}t|dd�}|�|r�|jj	�}|d}|d}|d}|j
}	|j}
|j}|dvr`t|	||�}|dk(r|
|z}
nH|dk(r	|
|d	zz}
n:|d
k(r|
t||	||||j�z}
ntdt|�z��|j}
||_
	|j|
||	||f��|
|_
yy#|
|_
wxYw)
N�textRenderModer�
textAnchorrSrT)�start�	inherited�end�middlerP�numericzbad value for textAnchor )�	_fontInfo)rVrR�getattrr>rU�textr7r8�stringWidth�
numericXShift�encoding�
ValueErrorr�r��
drawString)rB�	stringObj�canv�fillr��S�text_anchorrSrTr�r7r8�textLen�oldTextRenderModes              rr�z_PMRenderer.drawString�s9���|�|���~�~�� ��+;�A�>����~��
�
�&�&�(�A��L�/�K���}�H���}�H��>�>�D����A����A��"7�7�%�d�H�X�>����%���L�A� �(�*�����N�A� �)�+���{�4����R[�Rd�Rd�e�e�A�$�%@��[�AQ�%Q�R�R� $� 3� 3��"0�D��
8�����!�D�H�X�3F��G�&7��#�/ .��.'8��#�s�/D�	Dc���	�
��|j�
�ture�
jd=�
jr;�
jd}|j}d|_|j	|�||_y�
j�yddlm�	�
j�
j�
j�
jf�t�dd�}d
�	�
��fd�	}�jr2|��
j��
jj���
jdu}�
j du}t�dd�}|d	k(rn|r4|r2|d
���
j#|�|��
j%�y|r|d
���
j#|�y|r|��
j%�yy|dk(r0|d
��|r�
j#|�|r�
j%�yy|�r�
j#|��
j%�y)Nrdr
r)�_renderPath�	autoclose�c�:���j����|��S)N��
forceClose)r�)r�r�r-�	drawFuncsr�s ����r�rPz _PMRenderer.drawPath.<locals>.rP�s���
�K�K�M��t�Y�:�F�Fr/rN�svgTr��pdf)F)rV�
EmptyClipPath�
_clipPaths�
isClipPath�drawPath�
clipPathClear�reportlab.graphics.shapesr�r�r��curveTor�r��clipPathSet�appendrRrKr�r�)rBr�r��icpr�r�r��strokerNr�r-r�s `       @@@rr�z_PMRenderer.drawPath�s�����L�L���=� ����R� ��|�|��L�L��$���l�l�� ����
�
�a� �"���
����!��9��X�X�q�x�x����A�K�K�@�	��D��R�0�	�	G�	G��?�?��D�
�M�M�O�
�L�L����%��{�{�$�&�����d�*���4�
�2�.���e�����d�#��
�
�8�$���������d�#��
�
�8�$�����������
��$����
�
�8�$��������t��
�
�8�$�
�L�L�Nr/N)r)�__name__�
__module__�__qualname__�__doc__r?rDr@rirlrtr{r�r�r�r�r�r�r��r/rr3r3OsN��:���
;�4��R�;��(�
��
.�8�:/r/r3c�f�t�}|jd|j|j��S)Nr���dither�palette)r$r~�NONE�ADAPTIVE)r�r"s  r�
_convert2pilpr�s&���K�E�
�:�:�c�%�*�*�e�n�n�:�E�Er/c�$�|jd�S)N�L�r~�r�s r�
_convert2pilLr����
�:�:�c�?�r/c�$�|jd�S)N�1r�r�s r�
_convert2pil1r�r�r/c	�6�t|�}|j\}}tj||t	|d�r|j
n|j�|jj��}t	|d�sttjj|�ddz|j�zd�5}|j|�ddd�tjdk(rddlm}||d�	�yy|j|�y#1swY�@xYw)
Nr�writer�.�wb�mac��markfilename�PICT��ext)r�r��
_pmBackend�pil2pictr�rr�r��
getpaletter�r�r��splitextrr��name�reportlab.lib.utilsr�)	r��fn�fmt�transparent�cols�rowsr`�fr�s	         r�_saveAsPICTrs���	�r�	�B����J�D�$����D��'[�W�R�	�5J�r�z�z�PR�P[�P[�&^�_a�_d�_d�_o�_o�_q�r�A��2�g��
�"�'�'�"�"�2�&�q�)�#�-�c�i�i�k�9�$�
?�	�1�
�G�G�A�J�	�
�7�7�E�>�8����'��	�����
	�	�s�>D�Dg�OQ��?c���eZdZ		dd�Zedd��Zd d�Zd�Zd d�Zd!d�Z	d�Z
d d	�Zd
�Zd�Z
d"d�Zd
�Zd�Zd�Zd#d�Zd�Zd$d�Zd�Zd"d�Zd�Zd�Zd�Zd�Zd�Zd�ZeZd�Zd�Zd�Z y)%�PMCanvasNc��|dz}t||zdz�}t||zdz�}|j||||�|jd<||jd<|dd|ddf|jd<g|jd<||jd<||jd	<t|jj
�tt�k(rd
nd|jd<||jd
<|j|_y)z-configPIL dict is passed to image save methodgR@g�?�_gs�_bgrrhr��	configPIL�_dpirrr��_backendfmtN)	r)�
_getGState�__dict__�typer	r��powrhrH)	rB�w�h�dpi�bgrr�
backendFmt�scales	         r�__init__zPMCanvas.__init__*s����D�����%��������%������#���q��2�g�>��
�
�e��!��
�
�e��%*�1�Q�u�Q�q�$9��
�
�j�!�&(��
�
�l�#�%.��
�
�k�"� #��
�
�f��37����8J�8J�3K�T�RU�Y�3V�K�\g��
�
�j�!�'1��
�
�m�$��=�=��r/c�~�t|�}|�tj}|dk(r	|j|||��Sd|j
�vr	|j||||��Std|����#t$r"	|j||||��cYS#YnxYwY�8wxYw#t$r|j|||��cYSwxYw)Nr�r�rrz.Cannot obtain PM graphics state using backend )	rr	r�gstate�	TypeError�GStater�AttributeError�RuntimeError)rrrrr�mods      rrzPMCanvas._getGState;s����G�$���?��/�/�G��K��
��z�z�!�A��z�,�,���
�
��
'�
-��z�z�!�A�b�S�z�1�1��K�G�;�W�X�X���
���:�:�a��"��:�5�5�����D�	
��"�
-��z�z�!�A��z�,�,�
-�s;�A.�B�.	B�8B�B�B�B�B�B<�;B<c���|�|j}||c|j_|j_dddddddd�}|j}|j
|j}}|j�D]}t||�||<�~|`tj|||��x}|jd<|j�D]}t||||��|j||�y)N)rHrIrKrXrYr^rRrr	)r
�_drawingrqrrr	rSrT�keysr�r�rr�setattrr)	rBrrr�A�gs�fN�fS�ks	         r�_drawTimeResizezPMCanvas._drawTimeResizeOs���
�:�D�H�H�r�45�q�1��
�
��T�]�]�1��t�4�4�\`�nr�AE�
F��
�X�X�����R�[�[�2������	!�A��2�a�=�A�a�D�	!����$.�$5�$5�a��R�$5�$@�@��T�]�]�5�
!�����	!�A��D��1�Q�4� �	!�
�
�
�2�b�r/c���t�jd|jj|jjf��}|j|jj�|S)Nr})r�)r$�newr	rqrr�	frombytes�pixBuf)rBr�s  r�toPILzPMCanvas.toPIL]sD��
�[�_�_�U�$�(�(�.�.�$�(�(�/�/�)J�_�
K��
���T�X�X�_�_�%��	r/c
��|j�}|�_t|t�stdt	|�z��t
jj|�d}|jd�r|dd}|jxsi}|jdd�|jd�}|r||�}|j�}|dvrt|�}n�|dvrY|jd�rt|�}n9|jd�rt|�}n|jd	�rt!|�}d
}n=|dvrt#||||j%dd��
�S|dvrn|dvrd}nt'd|z��|d
k(r�|j%dd�}|r�ddlm}m}ddgz}	t/d|j1��D]
\}
}d|	|
|z<�|j3d|j5�|j7|j9|	�j;d�j9ddgzdgz��fz�}d|j<fdfD]\}}
|j%||
�||<�|jdd�|jd�rddlm}|j7|�}|jdd�|jd�}|r||�}|j>||fi|��tA|d�s%t
jBdk(rddl"m#}|||� �yyy)!Nz*Invalid value '%s' for fn when fmt is Noner
r��preConvertCB��GIF)�TIFF�TIFFP�TIFFL�TIF�TIFF1r�r�r�r5)�PCTr�r)r)�PNG�BMP�PPM)�JPG�JPEGr?zUnknown image kind %sr)�
ImageChopsr"i)r�ir&�RGBA�
resolution)zresolution unit�inch�chops_invert)r@�	preSaveCBr�r�r�r�)$r0rZr�r��asciir�r�r��
startswithr�
setdefaultr?�upperr��endswithr�r�r�getrr#r@r"�zip�
bitmap_rgb�merge�split�invert�pointr~r�saver�r�r�r�)rBr�rr�rr2�tcr@r"�T�or-�a�drFr�s                r�
saveToFilezPMCanvas.saveToFilebs���
�Z�Z�\���;��b��%� �!M�PU�VX�PY�!Y�Z�Z��'�'�"�"�2�&�q�)�C��~�~�c�"�#�a�b�'�C��N�N�(�b�	����^�D�1��]�]�>�2����b�!�B��i�i�k���(�?��r�"�B�
�:�
:��|�|�C� �"�2�&�����c�"�"�2�&�����c�"�"�2�&���C�
�N�
"��r�"�S�Y�]�]�=�QU�5V�W�W�
�(�
(��
�N�
"��C�� 7�#� =�>�>���;����}�T�2�B��1����G����R�]�]�_�=�!�D�A�q� �A�a��c�F�!��[�[������Z�5F�5F�r�x�x�PQ�{�GZ�GZ�[^�G_�Ge�Ge�fi�kl�jm�fm�or�ns�fs�Gt�5u�4w�)w�x��$�T�Y�Y�/�0J�J�
2���!�(�}�}�Q�q�1�	�!��
2����^�A�.��=�=��(�&��"�"�2�&�B����[��.��-�-��,�	���2��B������3�#��#��r�'�"�r�w�w��~�8����$�(6�"r/c�\�t�}|j||��|j�S)Nr)r
rY�getvalue)rBrr`s   r�saveToStringzPMCanvas.saveToString�s%���I������c��"��z�z�|�r/c�h�ddl}|j}|j|j|j}}}|j|j
ddt|�dzddd||dd�
�|d	z}tt|�d|�D]}|j|||z
|��|jd
�y)z�
        Niki Spahiev, <niki@vintech.bg>, asserts that this is a respectable way to get BMP without PIL
        f is a file like object to which the BMP is written
        rNz=2sLLLLLLhh24x�BM�6�(r
�r�z)	�structr	r/rqrrr��packr]r�)	rBrrbr'�pixrqrr�rowbrVs	         r�
_saveToBMPzPMCanvas._saveToBMP�s���
	�
�X�X���Y�Y����"�)�)�F�U��	������,�T�#�c�(�2�+�a��2�e�F�ST�UW�X�Y��q�y���s�3�x��4�%�(�	#�A�
�G�G�C��$��q�M�"�	#�	����r/c�2�t|j||�yr=)�_setFontr	)rBrSrT�leadings    rrzPMCanvas.setFont�s������(�8�,r/c�2�t|j||�yr=)r%r	)rBr��values   r�__setattr__zPMCanvas.__setattr__�s�������e�$r/c�.�t|j|�Sr=)r�r	)rBr�s  r�__getattr__zPMCanvas.__getattr__�s���t�x�x��%�%r/c�N�|r|j�|r|j�yyr=)r�r�)rBr�r�s   rr�zPMCanvas.fillstrokepath�s��������4�?�?�$�6r/c��t||z
�dksJ�tt|zdz�}tt|zdz�}|||zz}	|||zz}
tt|zdz�}tt|zdz�}|||zz}
|||zz}||z}||z}t||z
zdz}tddt|�z
zt|�z�}|	||zz}|
||zz}||z}||z}|
||zz
}|||zz
}|	|
f||f||f|
|fffS)a-compute the control points for a bezier arc with theta1-theta0 <= 90.
        Points are computed for an arc with angle theta increasing in the
        counter-clockwise (CCW) direction.  returns a tuple with starting point
        and 3 control points of a cubic bezier curve for the curvto opertator�Zg�f@g�v@gUUUUUU�?g�?)�absrrr)rBr�r�rnro�theta0�theta1�cos0�sin0�x0�y0�cos1�sin1�x3�y3�dx1�dy1�halfAngr*rwrx�dx2�dy2ryrzs                         r�_bezierArcSegmentCCWzPMCanvas._bezierArcSegmentCCW�sK���6�F�?�#�r�)�)�)��2�f�9�U�?�#���2�f�9�U�?�#��
�"�T�'�\��
�"�T�'�\���2�f�9�U�?�#���2�f�9�U�?�#��
�"�T�'�\��
�"�T�'�\���c�D�j���4�i���f�V�m�$�k�2���	�S�3�w�<�/�1�C��L�A�C��
�#��'�\��
�#��'�\���c�D�j���4�i��
�#��'�\��
�#��'�\���B��2�b�'�B�r�7�R��G�4�6�6r/c	���||z
}t|�dkr||fg}n`ttt|�dz��}	t|�|	z}
g}t	|	�D]"}|||
zz}||
z}
|j||
f��$g}|D]b\}}
|s.|j
||||||
�\\}}}|j|��6|j
||||||
�\\}}}|j|��df|fS)z�return a set of control points for Bezier approximation to an arc
        with angle increasing counter clockwise. No requirement on (theta1-theta0) <= 90
        However, it must be true that theta1-theta0 > 0.g�V@)rrr)r�floatr�r�r�)rBr�r�rnrorsrt�
angularExtent�	angleList�Nfrag�	fragAngle�iirW�b�ctrlptsrwrx�pts�tmpx�tmpys                    r�bezierArcCCWzPMCanvas.bezierArcCCW�s�����
��}���%� ���)�I���s�=�1�#�5�6�8�E��m�,�e�3�I��I��E�l�
(���R�)�^�+���	�M��� � �!�A��'�
(�
���	$�E�Q�q��!%�!:�!:�2�b�"�R��1�!M���"�R�#����s�#�%)�%>�%>�r�"�b��Q�q�%Q�"��$�t�c����s�#�
	$��B���!�!r/c	��|j||||||�\\}}}	|j||�|	D]%\\}
}\}}
\}}|j|
|||
||��'y)z�adds an ellisesoidal arc segment to a path, with an ellipse centered
        on cx,cy and with radii (major & minor axes) rx and ry.  The arc is
        drawn in the CCW direction.  Requires: (ang2-ang1) > 0N)r�r�r�)rBr�r�rnro�ang1�ang2rwrxr�rwrxryrzr{r|s                r�addEllipsoidalArczPMCanvas.addEllipsoidalArc�sm��
"�.�.�r�"�b��D��F���"�R�'����B�r��*1�	,�&�W�b��g�r�"�g�r�"��L�L��B�r�"�R��+�	,r/c�.�|j||||��y)N�r��r�)rBr7r8r�r�s     r�drawCentredStringzPMCanvas.drawCentredStrings������!�D�k��:r/c�.�|j|||d��y)Nr�r�r�)rBr�r7r8s    r�drawRightStringzPMCanvas.drawRightString	s������Q�q�U��3r/c�P�|j}|j}|j}|r|||fk7r|\}	}
t||	|
�n|}	|}
	|dvr=t	||	|
�}|dk(r||z}n%|dk(r	||dzz}n|dk(r|t||||	|
�z}|jdk(r|j|||�n�t|	�}|jr|j|||�n�|}
t|�s	|jd�}t||g|jz�}t!|�}|dz
}t#|�D]o}||\}}||
k7rt||j|
�|}
|j|||�||k7s�B||j	|j|j$�|
�z
}�q|j'||�y#t$rW}|jdd	\}}t|jdd	|jd	�d
||dz
|�d|||�d
|||dz��fz��d}~wwxYw#|j'||�wxYw)N)r�r�r�r�r�g@r�r�utf8rPre�
�
z-->z<--r
)r	rTrSrhr�r�r�r�r�_dynamicFontr�decode�UnicodeDecodeError�argsr�substitutionFontsr]r��encNamer)rBr7r8r�r�r�r'�gs_fontSize�gs_fontNamerSrTr��font�fc�er��j�FT�n�nm1r�ts                      rr�zPMCanvas.drawStringsz��
�X�X���k�k���k�k����[��$=�=�!*��H�h��R���*�"�H�"�H�%	0��5�5�%�d�H�X�>����%���L�A� �(�*�����O�A� �)�+���{�4����R�R�A��}�}�k�)��
�
�a��$�'��x�(���$�$��M�M�!�A�d�+��B�$�T�?�L�#'�;�;�v�#6�D�
$�D�$���0F�0F�)F�G�B��B��A��A�#�C�"�1�X�M��!�!�u���1��b�5�$�R��
�
�8�<�!"�B��
�
�a��!�,��c�6�����q�x�x��	�	�/B�8�!L�L�A�M�
�J�J�{�;�/��! 2�L�"#�&�&��1�+�C�A�a�"4�q�v�v�b�q�z�YZ�Y_�Y_�`a�Yb�cg�hi�jl�hl�mn�co�pt�uv�wx�py�z~�@A�BC�DF�BF�{G�DH�CJ�8J�#L�L��L�� 
�J�J�{�;�/�s9�BH�#F.�4A6H�+0H�.	H�7AH	�	H�H�H%c��|j�E|j�|j||�|j||�|j	�yyr=)rKr�r�r�r�)rBrwrxryrzs     rrvz
PMCanvas.line>sC�����'��N�N���K�K��2���K�K��2���O�O��	(r/c��|j�|j||�|j||z|�|j||z||z�|j|||z�|j�|j	||��y)N)r�r�)r�r�r�r�r�)rBr7r8rqrrr�r�s       rrpz
PMCanvas.rectEsq���������A�q�����A�e�G�Q�����A�e�G�Q��Z�(����A�q�6�z�"��������6�t��4r/c��|dk(r|}|dk(r|}||z}||z}|j�|j||z|�|j||z
||z||dd�|j||z
||z
||dd�|j||z||z
||dd�|j||z||z||dd�|j�|j	�y)z�rect(self, x, y, width, height, rx,ry):
        Draw a rectangle if rx or rx and ry are specified the corners are
        rounded with ellipsoidal arcs determined by rx and ry
        (drawn in the counter-clockwise direction)riihrq�N)r�r�r�r�r�)	rBr7r8rqrrrnroryrzs	         rrszPMCanvas.roundRectNs���
�q�5�r�"�
�q�5�r�"�
��Y��
��Z���������A�b�D������r�"�u�a��d�B��C��>����r�"�u�b��e�R��Q��;����q��t�R��U�B��B��<����q��t�Q�r�T�2�r�3��=��������r/c�,�|j||||�y)zRadd closed path circle with center cx,cy and axes r: counter-clockwise orientationN)r�)rBr�r�r�s    rr�zPMCanvas.circle`s�����R��1�Q�r/c�z�|j�||z}|}|}||z
}||z}	||tzz
}
||tzz}|}|j||�|j|	|
||||�|}|}||z
}|}||tzz
}	||z
}
|}||tzz
}|j|	|
||||�|}|}|}||z}||z
}	||tzz}
||tzz
}||z}|j|	|
||||�|}|}||z}|}||tzz}	||z}
||z}||tzz}|j|	|
||||�|j	�y)z�add closed path ellipse with center cx,cy and axes rx,ry: counter-clockwise orientation
        (remember y-axis increases downward) N)r��BEZIER_ARC_MAGICr�r�r�)
rBr�r�rnrorwrxr{r|rwrxryrzs
             rr�zPMCanvas.ellipseds���	
����
�"�W��
��
��
��U��
��U��
��#�#�
#��
�"�%�%�
%��
�����B������R��2�b��B�'�
��
��
��U��
��
��#�#�
#��
��U��
��
��$�$�
$�����R��2�b��B�'�
��
��
��
��U��
��U��
��#�#�
#��
��$�$�
$��
��U�����R��2�b��B�'�
��
��
��U��
��
��#�#�
#��
��U��
��U��
��#�#�
#�����R��2�b��B�'����r/c��y)zdo nothing for compatibilityNr�rAs r�	saveStatezPMCanvas.saveState�s��r/c�R�t|�|_t|dd�}|�||_yy�Nra)r.rRr�rQ�rB�aColorras   rr_zPMCanvas.setFillColor�s/��"�6�*�����w�t�,����$�D��r/c�R�t|�|_t|dd�}|�||_yyr�)r.rKr�rJr�s   rrWzPMCanvas.setStrokeColor�s0��$�V�,�����w�t�,����!&�D��r/c��||_yr=)rX)rB�caps  r�
setLineCapzPMCanvas.setLineCap�s	����r/c��||_yr=)rY)rB�joins  r�setLineJoinzPMCanvas.setLineJoin�s	����
r/c��||_yr=)rI)rBrqs  r�setLineWidthzPMCanvas.setLineWidth�s
�� ��r/)�H��NNr})N�RGB24r=r3)r
r
)r�)N�left)!r�r�r�r�staticmethodrr+r0rYr\rfrrlrnr�r�r�r�r�r�r�rvrprsr�r�r�r_rW�restoreStater�r�r�r�r/rrr)s���DH�$�!�"�Y��Y�&��
6%�p�
�-�%�&�%�!7�F"�<	,�;�4�00�d�5��$ �9�v
�%�'��L���!r/rr�r�c��t|�}t|j|j||||��}t	||dd|��|S)N)rrrrrr1)rrrqrrr4)rXrrrr2rr-s       r�drawToPMCanvasr��s>���A��A�����!�(�(���i�QX�Y�A���A�q�!�,�/��Hr/c�@�t||||||��j�S)N�rrrr2r)r�r0)rXrrrr2rs      r�	drawToPILr��s!���!���y�|�el�m�s�s�u�ur/c��t�}t||||||��}|jd|j|j��S)Nr�r�r�)r$r�r~r�r�)rXrrrr2rr"r�s        r�
drawToPILPr��s;���K�E�	�1�#�"�	��]d�	e�B�
�:�:�c�%�*�*�e�n�n�:�E�Er/r4c�J�t||||||��}|j||�y)zocreate a pixmap and draw drawing, d to it then save as a file
    configPIL dict is passed to image save methodr�N)r�rY)	rXr�rrrrr2rr-s	         r�
drawToFiler��s'��	�q�c�b�I�L�ah�i�A��L�L��C�r/c	�Z�t�}t|||||||��|j�S)N)rrrrr)r
r�r[)rXrrrrr2rr`s        r�drawToStringr��s)���	�A��q��s���i��P��:�:�<�r/c	�.����� �d�}ddl}ddlm}ddlm� |j
}g}|jj|�s|j|�d}d}|g}	i}
tjdd}|D�cgc]}|jd�s�|��}
}|
sgd	�}
nI|
D]}|j|��d
j|
D�cgc]}|dd��	c}�jd
�}
g�ddl�ddlm������ fd
�}|t%t&d���D�]�\}}}|
j)|d�dzx}|
|<|dkDr|d|dz
zz
}|r||vr�9|}t+|j,�}t+|j.�}|	j1d|�d|�d��|
D�]0}|dvr"|	j1d|j3�z�	|�d||���}|jj||�}|jj5|�r|j|�|dk(rddlm}t;|||d|i��n)|dvr|j=ddg||��nt;|||��|d vr|	j1d!|z�n3|dk(r|	j1d"|z�n|dk(r|	j1d#|z��s� d$kDrt?d%tA|�z���3|jDjGd&d'�d(k(rd|jHd)<d*D]}	|j=|g||������r:|	djKd+d,�|	d<|	j1d-�|	jM��|	j1|�|jj|d.�}tO|d/�5}|jQ|	�ddd�tjRd0k(rdd1l*m+}||d2�3��s� d$kDrt?d%|z�yycc}wcc}w#tB$r
|||�Y��jwxYw#|||�Y��xYw#1swY�wxYw)4Nc��|dk(rd}|S)N�tiff�tifr�)r7s rr�ztest.<locals>.ext�s���f�9��a��r/r)�
testshapes)�verbosezq<html><head><title>renderPM output results</title></head>
    <body>
    <h1>renderPM results of output</h1>
    z</body>
    </html>
    r
z--ext=)�gifr��png�jpg�pct�pyr��,�)�escapec����d|�d|�d�}�s�dkDrt|��jd|z�t�}�j|���jd�|j	��z�y)NzProblem drawing z fmt=z filerPz"<br/><h2 style="color:red">%s</h2>)�filez
<pre>%s</pre>)�printr�r�	print_excr[)	r�r�msg�buf�errsr��shout�	tracebackr�s	    �����r�handleErrorztest.<locals>.handleError�sb���04�S�9���G�A�I�u�S�z����8�3�>�?��j�������%����O�f�S�\�\�^�&<�<�=r/�ft_get_face)�doTTFz.%02dz<hr><h2>Drawing z</h2>
<pre>z</pre>)r�r�r�r�z<p>%s format</p>
r�r�)�whiter)rr)r�r�r�r�)�formats�outDir�fnRootr)r�r�r�z<img src="%s" border="1"><br>
z#<a href="%s">python source</a><br>
z<a href="%s">SVG</a><br>
rPzwrote %s�RL_NOEPSPREVIEW�0r��preview)�epsr�z</h1>z7 <a href="#errors" style="color: red">(errors)</a></h1>z<a name="errors"/>z
pm-index.htmlrr�r��HTMLr�),r��reportlab.graphicsr��reportlab.rl_configr��getAllTestDrawingsr��isdir�mkdir�sys�argvrH�remover�rPr��xml.sax.saxutilsr�r�r�rIr)rqrrr�rJr��reportlab.lib.colorsr�r�rSr�rGr�environrLr�replace�extendr��
writelines�platformr�r�)!r�r�r�r�r�r��drawings�htmlTop�
htmlBottom�html�namesr�rW�Er�r5�	docstringr�r�r�rrr*�filename�fullpathr��htmlFileNamerr�r�r�r�r�s! `                           @@@@r�testr�s�����
�-�+�#�6�6���H�
�7�7�=�=�� ��������G��J�
�9�D��E��8�8�A�B�<�D��3�q�A�L�L��2��3�A�3��<���	�A��K�K��N�	�
�X�X�a�(��q���u�(�
)�0�0��5��
�D��'�>�>�'9�w�z�R_�?`�&a�&$�"��)�T��*�*�4��2�1�4�4��E�$�K��Q�3���1�Q�3��'���D��$�h�����
�
�������������i�P�Q��	$�A��-�-����0�1�7�7�9�<�=�
$�&,�c�!�f�5���7�7�<�<���9���7�7�>�>�(�+��B�I�I�h�'��e�8�:��w�x�A��u�@U�V��,�&��L�L�$�u��V�6�L�R��w�x�A�6��+�+��K�K� A�H� L�M���W��K�K� F�� Q�R���X��K�K� <�x� G�H��G�A�I�u�Z��h��-G�'H��+	$�0�:�:�>�>�+�C�0�#�5�UV�w�7G�7G�	�7R��	$�A�
$����a�S��f��E�	$�E&$�P��q�'�/�/�'�*c�d��Q�����(�)����D���K�K�
���7�7�<�<���8�L�	
�l�C�	 ��A�	���T���
�|�|�U��4��\�f�-����	�5��l�!:�;�	��O	4��)��Z"�
$��D��#�
$��
$��D��#����s=�4O�O�?O�7DO!�4O:�P�!O7�6O7�:P�P�__main__T)r�r=)�pmoutF)2�__version__r�r��reportlab.graphics.renderbaserr�reportlab.pdfbase.pdfmetricsrrr�r�	reportlabr	�utilsrrhrr�r��ior
r�mathrrrrrrr�r$r.�_unset_r4r:r3r�r�r�rr�rr�r�r�r�r�rSrr�r�r/r�<module>rs���
��	1��(�L�<�)��5�� �#�#�
�:��y�8�8�9�J��
�.7�->�->�R�
3�@�(�@�DF���� ��P!�P!�d��T�	�HY�HY�bk�b{�b{�
��H��9�CT�CT�]f�]v�]v�v��X��I�DU�DU�^g�^w�^w�F�
�2�(�d�QZ�Qb�Qb�kt�lE�lE���"��T�PY�Pa�Pa�js�kD�kD��
��^<�@�Z���t����{���J��s�E	�	E�E

Zerion Mini Shell 1.0