%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__/renderPDF.cpython-312.pyc

�

׸�e4;���dZdZddlmZddl�ddlmZddlmZddl	m
Z
ddlmZm
Z
mZmZe
j fd	�ZGd
�de�ZddlmZGd
�de�Zde
j difd�Zde
j difd�Zdd�Zedk(r?ed��ddlZeej8�dkDrej8dZndZeed��yy)z3.3.0z�Render Drawing objects within others PDFs or standalone

Usage::
    
    import renderpdf
    renderpdf.draw(drawing, canvas, x, y)

Execute the script to see some test drawings.
changed
�)�BytesIO)�*)�Canvas)�stringWidth)�	rl_config)�Renderer�
getStateDelta�renderScaledDrawing�STATE_DEFAULTSc�V�t�}|jt|�||||��y)z
As it says��showBoundaryN)�_PDFRenderer�drawr
)�drawing�canvas�x�yr�Rs      �>/usr/lib/python3/dist-packages/reportlab/graphics/renderPDF.pyrrs%����A��F�F��w�'���A�L�F�Q�c�j�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zy)rz�This draws onto a PDF document.  It needs to be a class
    rather than a function, as some PDF-specific state tracking is
    needed outside of the state info in the SVG model.c� �d|_d|_y�Nr)�_stroke�_fill��selfs r�__init__z_PDFRenderer.__init__%s�������
rc��t|t�r|js|jj	�t|�}|jj|�|j|i�|j|�|jj�t|t�r|js|jj�yy)zEThis is the recursive method called for each node
        in the treeN)�
isinstance�Path�
isClipPath�_canvas�	saveStater	�_tracker�push�applyStateChanges�drawNodeDispatcher�pop�restoreState)r�node�deltass   r�drawNodez_PDFRenderer.drawNode)s���
�4��&�4�?�?��L�L�"�"�$��t�$���
�
���6�"����v�r�*�	
����%��
�
�����4��&�4�?�?��L�L�%�%�'�,;rc	���|j|jcxk(rdk(rann^|jj|j|j
|j|j|j|j��y|jj|j|j
|j|j|j|j|j��y)Nr��stroke�fill�r2r1)�rx�ryr$�rectrr�width�heightrr�	roundRect)rr6s  r�drawRectz_PDFRenderer.drawRect=s����7�7�d�g�g�"��"��L�L����F�F�D�F�F��J�J�����<�<����	
�
�
�L�L�"�"��F�F�D�F�F��J�J����T�W�W�����<�<�	
#�
rc��|j}|r~t|d�s)tjj|j�rH|jj||j|j|j|j�yyy)N�mode)
�path�hasattr�os�existsr$�drawInlineImagerrr7r8)r�imager=s   r�	drawImagez_PDFRenderer.drawImagePsa���z�z���W�T�&�)�R�W�W�^�^�E�J�J�-G��L�L�(�(���G�G�U�W�W��K�K����
�.H�4rc��|jrG|jj|j|j|j
|j�yy�N)rr$�line�x1�y1�x2�y2)rrFs  r�drawLinez_PDFRenderer.drawLineZs6���<�<��L�L���d�g�g�t�w�w�������A�rc��|jj|j|j|j|j
|j��y�Nr3)r$�circle�cx�cy�rrr)rrNs  r�
drawCirclez_PDFRenderer.drawCircle^s:���L�L����I�I�v�y�y�&�(�(�����<�<�
 �
rc��|jr�t|j�dk\sJd��|jdd|jdd}}|jj	�}|j|d|d�t
dt|�d�D]}|j||||dz��|jj|�yy)N��#Polyline must have 2 or more pointsr�)	r�len�pointsr$�	beginPath�moveTo�range�lineTo�drawPath)r�polyline�head�tailr=�is      r�drawPolyLinez_PDFRenderer.drawPolyLinees����<�<��x���'�1�,�S�.S�S�,�!����1�-�x���q�r�/B�$�D��<�<�)�)�+�D��K�K��Q���a��)��1�c�$�i��+�
0�����D��G�T�!�A�#�Y�/�
0��L�L�!�!�$�'�rc���|jr |j|j��y|j|j|j
|j|jf\}}}}}|j�\}}}	|�|}||z
}
|jj�}|dk(s|�<|	dk(s|	�5|j||�|j||z
||z
||z||z||
�nE|j||z
||z
||z||z||
�|j||z
||	z
||z||	z||
�|j�|jj||j|j ��y)Nrr3)�annularr]�	asPolygon�centerx�centery�radius�startangledegrees�endangledegrees�
_xtraRadiir$rYrZ�arcTo�arc�closerr)r�wedgerfrgrhrirj�yradius�radius1�yradius1�angler=s            r�	drawWedgez_PDFRenderer.drawWedgeosi���=�=��M�M�%�/�/�+�,��]�]�E�M�M�5�<�<��9P�9P�RW�Rg�Rg�
g�
I�G�W�f�&7��).�)9�)9�);�&�G�W�h���&��#�$5�5�E��<�<�)�)�+�D���
�g�o�H�a�K�8�CS����G�W�-��
�
�7�6�>�7�7�?�G�F�N�G�T[�O�(�%�1����������'�&�.�'�RY�/�(�%�1��
�
�7�7�?�G�H�,<�g�g�o�w�W_�O_�&���0��J�J�L��L�L�!�!�$�!�Z�Z�#�|�|�
"�
rc�6�|j|jz
}|j|jz}|j|jz
}|j|jz}|jj|||||j|j��yrM)rOr4rPr5r$�ellipserr)rrvrGrIrHrJs      r�drawEllipsez_PDFRenderer.drawEllipse�sq��
�Z�Z�'�*�*�
$��
�Z�Z�'�*�*�
$��
�Z�Z�'�*�*�
$��
�Z�Z�'�*�*�
$�������R��2�b�d�j�j�����Mrc���t|j�dk\sJd��|jdd|jdd}}|jj�}|j	|d|d�tdt|�d�D]}|j
||||dz��|j�|jj||j|j��y)NrTrUrrVr0)rWrXr$rYrZr[r\rnr]rr)r�polygonr_r`r=ras      r�drawPolygonz_PDFRenderer.drawPolygon�s����7�>�>�"�a�'�N�)N�N�'��^�^�A�a�(�'�.�.���*<�d���|�|�%�%�'�����D��G�T�!�W�%��q�#�d�)�Q�'�	,�A��K�K��Q���a��c��+�	,��
�
������� �#'�<�<�!%���	�	rc	��t|dd�}|dv}|dv}|jr|s|jr�|r�|jj	�}|d|j
|j|j|jf\}}}}	}
|dvra|d|d}}t|	|||
�}
|d	k(r||
z}n>|d
k(r	||
dzz}n0|dk(r|t||	|
|||
�z}ntd
t|�z��|jj|||	|xsd��yyy)N�textRenderModer)rrT��)rVrT�r~�
textAnchor)�start�	inherited�fontName�fontSize�end�middleg�?�numericzbad value for textAnchor )r<)�getattrrrr&�getStaterr�text�encodingr�
numericXShift�
ValueError�strr$�
drawString)r�	stringObjr|�needFill�
needStroke�S�text_anchorrrr��enc�font�	font_size�textLens              rr�z_PDFRenderer.drawString�s-�� ��+;�A�>��!�Y�.��#�y�0�
��J�J�8����*��
�
�&�&�(�A�+,�\�?�I�K�K�	���T]�Tb�Tb�dm�dv�dv�+v�(�K��A�t�S��"7�7�"#�J�-��:��i��%�d�D�)�S�A����%���L�A� �(�*�����$�A� �)�+���{�4���Y�s�S�S�A�$�%@��[�AQ�%Q�R�R��L�L�#�#�A�q�$�^�5K�t�#�L�;E�rc�@�ddlm}|jj�}|j|j
|j|jf}t|dd�}|j}|j}||||xr|dk(��}|jj}	|jr|jjn|	}
t|dd�}|dk(r+|r|r|s|
||d�	�|	||d|�
�y|
||||��y|dk(r
|
||||��y|sd}|
||||��y)Nr)�_renderPath�	autoclose��pdf)�
forceClose�fillMode�svgr3)r1r2r�)r2r1r�)�reportlab.graphics.shapesr�r$rYrZr\�curveTornr�rrr]r#�clipPath)rr=r��pdfPath�	drawFuncsr�r2r1�isClosed�dP�cPr�s            rr]z_PDFRenderer.drawPath�s��9��,�,�(�(�*���^�^�W�^�^�W�_�_�g�m�m�T�	��D��R�0�	��z�z�������t�Y�4�;T�I�u�DT�U��
�\�\�
"�
"��&*�o�o�T�\�\�
"�
"�2���4�
�4�0���e����x��7��a�0��7�6��H�E��7��f�x�H�
��
��w�T�&�8�D�����w�T�&�8�Drc�:�|jj|�yrE)r$�setStrokeColor�r�cs  rr�z_PDFRenderer.setStrokeColor�s�����#�#�A�&rc�:�|jj|�yrE)r$�setFillColorr�s  rr�z_PDFRenderer.setFillColor�s�����!�!�!�$rc
���tjrt|j��n|j�D�]�\}}|dk(r3|jj|d|d|d|d|d|d��?|dk(r#|�d|_�Nd|_|j|��g|d
k(r|jj|���|dk(r|jj|���|dk(r|jj|���|d
k(r�|rht|ttf�r2t|�dk(r$t|dttf�r|d}|d}nd}|jj||���9|jj���U|dk(r%|�	d|_��ed|_|j#|���|dvrj|j%d|jj&�}|j%d|jj(�}|jj+||����|dk(r!|����|jj-|���|dk(r!|���|jj/|���9|dk(r|jj1|���[|dk(r|jj3|���}|dk(r|jj5|����|dk(s���||j_���y	)z`This takes a set of states, and outputs the PDF operators
        needed to set those properties�	transformrrVrT�r}r�strokeColorN�strokeWidth�
strokeLineCap�strokeLineJoin�strokeDashArray�	fillColor)r�r�r�r��fillOpacity�
strokeOpacity�
fillOverprint�strokeOverprint�
overprintMaskr�)r�	invariant�sorted�itemsr$r�rr��setLineWidth�
setLineCap�setLineJoinr!�list�tuplerW�setDashrr��get�	_fontname�	_fontsize�setFont�setFillAlpha�setStrokeAlpha�setFillOverprint�setStrokeOverprint�setOverprintMask�	_fillMode)r�delta�newState�key�value�phase�fontname�fontsizes        rr(z_PDFRenderer.applyStateChanges�s���5>�4G�4G�6�%�+�+�-�0�U�[�[�]�<	/�J�C���k�!����&�&�u�Q�x��q��5��8�!&�q��5��8�U�1�X�?��
�%��=�#$�D�L�#$�D�L��'�'��.��
�%����)�)�%�0���'����'�'��.��(�(����(�(��/��)�)��!�%��e��5�#�e�*�a�-�J�W\�]^�W_�af�gk�`l�Lm� %�a��� %�a��� !���L�L�(�(��u�5��L�L�(�(�*���#��=�!"�D�J�!"�D�J��%�%�e�,��0�0�!�9�9�Z����1G�1G�H�� �9�9�Z����1G�1G�H�����$�$�X�x�8��m�#��$��L�L�-�-�e�4��o�%��$��L�L�/�/��6��o�%����-�-�e�4��'�'����/�/��6��o�%����-�-�e�4��j��).����&�y<	/rN)�__name__�
__module__�__qualname__�__doc__rr.r:rCrKrRrbrtrwrzr�r]r�r�r(�rrrr sV��:��(�(�&�B��(��2N��M�*E�2'�%�?/rr)�Flowablec��eZdZdZd�Zd�Zy)�GraphicsFlowablez'Flowable wrapper around a Pingo drawingc�~�||_|jj|_|jj|_yrE)rr7r8)rrs  rrzGraphicsFlowable.__init__s+������\�\�'�'��
��l�l�)�)��rc�H�t|j|jdd�yr)rr�canvrs rrzGraphicsFlowable.draws���T�\�\�4�9�9�a��+rN)r�r�r�r�rrr�rrr�r�s��1�*�
,rr�r�rVc�*�t|�}dD]1}d|z}t|||j|td|z��||<�3t	|fi|��}|r3|jtjd�|jdd|�|j|�|r8|j|j|jf�t||dd|��nC|jtjd	�d
}	d}
|	|jz
}	t||d|	|��|j�|j�t j"dk(rIt%|d
�s<	ddl}ddl}|j+|�j-dd�|j/|�yyy#YyxYw)z�Makes a one-page PDF with just the drawing.

    If autoSize=1, the PDF will be the same size as
    the drawing; if 0, it will place the drawing on
    an A4 page with a title above it - possibly overflowing
    if too big.)�Name�Size�initialFontr��$�P��rr
���rV�mac�writeN�CAROzPDF )r
r�r*rrr�r�defaultGraphicsFontNamer��setTitle�setPageSizer7r8r�showPage�save�sys�platformr>�macfs�
macostools�FSSpec�SetCreatorType�touched)
�d�fn�msgr�autoSize�
canvasKwdsr�ar�rrar�r�s
             r�
drawToFilersb��	�A��A�
�P���!�O����!�J�N�N�1�^�F�1�H�5M�$N�O�
�1�
�P�	�r��J��A�
�	�	�	�)�3�3�R�8�	���R��c�"��J�J�s�O��	�
�
�q�w�w����)�*��Q��1�a�l�3�	
�	�	�)�3�3�R�8���
��
����L���Q��2�q�|�4��J�J�L��F�F�H�
�|�|�U��7�2�w�#7�	�$��L�L���+�+�F�F�;����r�"�	$8���
	��s�:F�Fc�X�t�}t||||||��|j�S)z>Returns a PDF as a string in memory, without touching the disk)r�rr�r�)rr�getvalue)r�r�rr�r��ss      r�drawToStringrDs(���	�A��q�!��<��V`�a��:�:�<�r�pdfoutc�"�ddlm}m}ddlm}ddl}|jj|�s|j|�|jj|d�}t|�}|j|d�|jddd�dd	l
m}g}	t|�D]>}
|
dd
dk(s�t!||
�}|�}t!|dd
�}
|	j#||
f��@|j|d�d}d}|	D]�\}}
|
�
Jd|z��|dkr|j%�d}|dz
}|j|d�|jd|d|z�|j|d�|dz
}|j'd|�}|j)|
�|j+|�|j-�}||j.z
}t1||d|�|dz}��|dk7r|j%�|j3�|s|dkDrt5dt7|�z�yy)Nr)�_baseGFontName�_baseGFontNameBI)�verbosez
renderPDF.pdfr�r�r�z
Graphics Test)�
testshapes�
�
getDrawingr�r�r�r�rVzDrawing %d has no docstring!i,�z
Drawing %d�rTzsaved %s)r�rr�reportlab.rl_configr	r?r=�isdir�mkdir�joinrr�r��reportlab.graphicsr
�dirr��appendr��	beginText�	textLines�drawText�getYr8rr��print�ascii)�outDir�shoutrrr	r?r�r�r
�drawings�funcname�funcr�	docstringrra�textObjs                 r�testr#Ps���J�+�
�
�7�7�=�=�� �
�����	�����f�_�	-�B��r�
�A��I�I�n�b�!��L�L��S�/�*�.��H��
�O�2���A�b�>�\�)��:�h�/�D��f�G���Y�r�2�I��O�O�W�i�0�1�2��I�I�n�b�!��A�	�A� (����)��%�J�(F��(J�J�%��s�7�
�J�J�L��A�
��F��	�	�	�"�2�&�	���R��L�1�,�-�	�	�	�.��$�
��F���+�+�b�!�$�����)�$�	�
�
�7���L�L�N��
�������W�a��Q��
��E��#�$	�#�v�q�z�z�|��F�F�H����	�
�j�5��9�$�%�r�__main__T)rN)rF)�__version__r��iorr��reportlab.pdfgen.canvasr�reportlab.pdfbase.pdfmetricsr�	reportlabr�reportlab.graphics.renderbaserr	r
r�_unset_rr�reportlab.platypusr�r�rrr#r�r�rW�argv�outdirr�rr�<module>r/s���
��		���'�*�4��f�f�.7�->�->�R�
q/�8�q/�f(�,�x�,��9�+<�+<�q�UW�$�L��):�):�A�QS��2&�h�Z���t���
�3�8�8�}�Q�����!�������d��r

Zerion Mini Shell 1.0