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

�

��eWC����dZdZddlZddlZddlmZddlmZddlm	Z	ddl
mZmZddl
mZdd	lmZdd
l�ddlZgd�Zd�Zd
�ZddlmZee�e�d�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d�Z"ddl#m$Z$d�Z%d�Z&d�Z'd�Z(d�Z)d(d �Z*d)d!�Z+d(d"�Z,d#�Z-Gd$�d%ej\�Z/d&�Z0e1d'k(r&ejd�jge0��yy)*z $Id $ z�Execute this script to see some test drawings.

This contains a number of routines to generate test drawings
for reportlab/graphics.  For now many of them are contrived,
but we will expand them to try and trip up any parser.
Feel free to add more.
�N)�BytesIO)�colors)�cm)�asNative�base64_decodebytes)�Canvas)�stringWidth)�*)�Times-Roman�VerazTimes-BoldItalicc�h�ddlm}m}|j|j	dd��|j|j	dd��|j|j	dd��|j|j	d	d
��gd�}t
jdk(r�d
D]�\}}dD]x}tjj|d|�}tjj|�s�D	|j	||�}|j|�|j|��z��|S#Y��xYw)Nr)�
pdfmetrics�ttfontsrzVera.ttf�VeraBdz
VeraBd.ttf�VeraItz
VeraIt.ttf�VeraBIz
VeraBI.ttf)r�Courier�	Helveticarrrr�win32))zAdventurer Light SFz
Advlit.ttf)�ArialMSz	ARIAL.TTF)zArial Unicode MSzARIALUNI.TTF)zBook Antiquaz	BKANT.TTF)zCentury Gothicz
GOTHIC.TTF)z
Comic Sans MSz	COMIC.TTF)zElementary Heavy SF Boldz	Vwagh.ttf)z
Firenze SFzflot.ttf)�GaramondzGARA.TTF)�JaggerzRols.ttf)zMonotype CorsivazMTCORSVA.TTF)z
Seabird SFzseag.ttf)�Tahomaz
TAHOMA.TTF)�	VerdanaMSzVERDANA.TTF)zc:\WINNTz
c:\Windows�Fonts)�reportlab.pdfbaserr�registerFont�TTFont�sys�platform�os�path�join�isfile�append)rr�F�name�ttf�D�fn�fs        �?/usr/lib/python3/dist-packages/reportlab/graphics/testshapes.py�_setupr-s��5����G�N�N�6�:�>�?����G�N�N�8�\�B�C����G�N�N�8�\�B�C����G�N�N�8�\�B�C�R�A�
�|�|�W���	�I�D�#�1�
���W�W�\�\�!�G�C�0���7�7�>�>�"�%��#�N�N�4��4��"�/�/��2������

�	�0
�H����s�34D-�-D1c�^�t�D] }|tvs�tj|��"y)N)r-�_FONTSr%)r+s r,�
resetFontsr0As&��
�X����F�?��M�M�!���)�register_resetc���tdd�}gd�}|jt|dtztj
tj���tddd|zd�	�}|j|�|S)
a+Generate a drawing in case something goes really wrong.

    This will create a drawing to be displayed whenever some
    other drawing could not be executed, because the generating
    function does something terribly wrong! The box contains
    an attention triangle, plus some error message.
    ���)r5���Pir8��?��strokeWidth�strokeColor�	fillColor�(z"Error in generating function '%s'!�middle��
textAnchor)�Drawing�add�Polygonrr�red�yellow�String)�funcNamer)�points�ss    r,�getFailedDrawingrKNsl��	��S��A�
&�F��E�E�'�&�!�"�f�$�j�j�"�M�M�+�,�
	�s�B�3�h�>�"�	$�A��E�E�!�H��Hr1c	�(�tdd�}|jtddddtj���|jtdddtj���|jtdd	d
tj���|S)z{Hello World, on a rectangular background.

    The rectangle's fillColor is yellow.
    The string's fillColor is red.
    r4r5�2�,�d�r=��Hello World�VsSpecial characters ¢©®£αβ)rBrC�RectrrFrGrE�r)s r,�getDrawing01rVisl��	��S��A��E�E�$�r�2�s�C�6�=�=�
9�:��E�E�&��S�-�6�:�:�
>�?��E�E�&��R�_�kq�ku�ku�
v�w��Hr1c��tdd�}|jtddddtjdt
z���|jtddddtjdt
zgd��	��|S)
z�Various Line shapes.

    The lines are blue and their strokeWidth is 5 mm.
    One line has a strokeDashArray set to [5, 10, 15].
    r4r5rMrNrOr9)r<r;)��
�)r<r;�strokeDashArray)rBrC�Liner�bluerrUs r,�getDrawing02r^xsn��	��S��A��E�E�$�r�"�c�#�!�;�;��r�6����E�E�$�r�#�s�2�!�;�;��r�6�*���
�Hr1c
���tdd�}tddd�D]4}|jtd|dzzd|dzzdtd	|�
���6|jtdddtdd�
��|S)
z�Text strings in various sizes and different fonts.

    Font size increases from 12 to 36 and from bottom left
    to upper right corner.  The first ones should be in
    Times-Roman.  Finally, a solitary Courier string at
    the top right corner.
    r4r5��$�rY�rRr��fontName�fontSize��)rB�rangerCrGr/)r)�sizes  r,�getDrawing03rk�s���	��S��A��b�"�a� �%��	���f�R��Q��Y���Q��Y�"�$�Q�i�"�	$�	%�%��E�E�&��c�� ��)����
�Hr1c	���tdd�}d}tjtjtjfD]1}|jt
d|dzzd|dzzd|���|dz}�3|S)	zpText strings in various colours.

    Colours are blue, yellow and red from bottom left
    to upper right.
    r4r5rrM�rRrPrh)rBrr]rFrErCrG)r)�i�colors   r,�getDrawing04rp�ss��	��S��A�	�A��+�+�v�}�}�f�j�j�9���	���f�R��"��W�b��2��g�"�e�5�	6�
��E���

�Hr1c	��tdd�}d}|jt|d|dtj���d}dD]D}|jt||d	|�
��|jtd||dz��|d
z
}�F|S)ztText strings with various anchors (alignments).

    Text alignment conforms to the anchors in the left column.
    r4r5�rY��r<�)�startr?�endrRr@rM�:rm)rBrCr\r�grayrG)r)�lineX�y�anchors    r,�getDrawing05r}�s���	��S��A��E��E�E�$�u�R��s����
<�=��A�,���	���f�U�A�}��@�A�	���f�R��F�S�L�)�*�
��F���

�Hr1c��tj}tdd�}|jt	dddd��|jtddd|���|jtddd	|���|jtd
dd|���|jt
ddd	d
d	|���|jtgd�|���|jtgd�|���|jtddd	d|���|jtdddddtj|���|jtdddddd|���|jtdddtjd���|S)z�This demonstrates all the basic shapes at once.

    There are no groups or references.
    Each solid shape should have a green fill.
    r4r5rY�rsrO�rPr>rNrm�Ji����)�xrYrur�r7rYrgr��rYr6r�rQrYrsr�r5rY)
rNr�i^r�rr8rN�Kr�r>rMrgr��<r:��zBasic Shapesr)r=re)r�greenrBrCr\�Circle�Wedge�PolyLinerD�EllipserTrFrG�black)r�r)s  r,�getDrawing06r��sE��
�L�L�E���S��A��E�E�$�r�"�c�#�
���E�E�&��S��u�
-�.��E�E�&��S��u�
-�.��E�E�&��S��u�
-�.��E�E�%��C��C��e�
4�5��E�E�(�4�?D�F�G��E�E�'�:�e�
L�M��E�E�'�"�S�"�b�E�
2�3��E�E�$�s�3��2��!�=�=�� �!��E�E�$�s�C��R��R�5�
9�:��E�E�&��B��&�,�,��
U�V��Hr1c�@�tdd�}ttdddd�tdddd�tdddd�tdddd�tdddd�tdd	dd	�tdddd�tdddd�tdddd�td	dd	d�tdddd�td
dd
d�tdddd�tdddd�td
dd
d�tdddtj
���}t|�}|j
dd�|j|�t|�}|j
dd�|jd�|j|�t|tt
dd�td����}|j|�|S)z�This tests the ability to translate and rotate groups.  The first set of axes should be
    near the bottom left of the drawing.  The second should be rotated counterclockwise
    by 15 degrees.  The third should be rotated by 30 degrees.r4r5rrOrMrYr�rmr>r��Fr8�Z�#�Axes��fillrgrZrN��	transform)
rB�Groupr\rGrr��	translaterC�rotate�mmult)r)�Axis�firstAxisGroup�secondAxisGroup�thirdAxisGroups     r,�getDrawing07r��s���	��S��A���Q�q��Q���Q�q��2���Q�r�"�R���Q�r�"�R���Q�r�"�R���Q�r�"�R���R��"�R���R��"�R���R��"�R���R��"�R���R��"�R���R��"�R���R��"�R���R��"�R���R��"�R���r�2�v�F�L�L�1�!
�D�&�4�[�N����R��#��E�E�.���D�k�O����c�"�%����2���E�E�/���4�5��3�r�1B�F�2�J�+O�P�N��E�E�.���Hr1c���tdd�}ttdddd�tdddd�tdddd�tdddd�tdddd�tdd	dd	�tdddd�tdddd�tdddd�td	dd	d�tdddd�td
dd
d�tdddd�tdddd�td
dd
d�tdddtj
���}t|�}|j
dd�|j|�t|�}|j
dd�|jdd�|j|�t|�}|j
dd�|jdd�|j|�t|�}|j
dd�|jdd�|j|�|S)aaThis tests the ability to scale coordinates. The bottom left set of axes should be
    near the bottom left of the drawing.  The bottom right should be stretched vertically
    by a factor of 2.  The top left one should be stretched horizontally by a factor of 2.
    The top right should have the vertical axiss leaning over to the right by 30 degrees.r4r5rrOrMrYr�rmr>r�r�r8r�r�r�r�rgrhrc�}rr)
rBr�r\rGrr�r�rC�scale�skew)r)r�r�r�r��fourthAxisGroups      r,�getDrawing08r�s���
	��S��A���Q�q��Q���Q�q��2���Q�r�"�R���Q�r�"�R���Q�r�"�R���Q�r�"�R���R��"�R���R��"�R���R��"�R���R��"�R���R��"�R���R��"�R���R��"�R���R��"�R���R��"�R���r�2�v�F�L�L�1�!
�D�&�4�[�N����R��#��E�E�.���D�k�O����c�"�%����!�A���E�E�/���4�[�N����R��$�����1���E�E�.���D�k�O����c�#�&�����A���E�E�/��
�Hr1c
��tdd�}td}d}d}t|||�}tt	dd|||��tdd|d	z|d	zd
���}|j
|�d}t|||�}tt	dd|||��tdd|d	z|d	zd
���}|jdd
�|jd�|j
|�|S)z�This tests rotated strings

    Some renderers will have a separate mechanism for font drawing.  This test
    just makes sure strings get transformed the same way as regular graphics.r4r5rr`z4I should be totally horizontal and enclosed in a boxr�rd�rbNrPzGI should slope up by 15 degrees, so my right end is higher than my leftrMrZ)	rBr/r	r�rGrTrCr�r�)r)rerf�text�	textWidth�g1�g2s       r,�getDrawing09r�Js���
	��S��A��a�y�H��H�A�D��D�(�H�5�I�
��2�r�4�(�x�H���R��Q���1���E�
�B��E�E�"�I�T�D��D�(�H�5�I�	��2�r�4�(�x�H���R��Q���1���E�
�B��L�L��B���I�I�b�M��E�E�"�I��Hr1c
��tdd�}td}d}ttddddtj
��t
ddd	||�
��}|j|�t|tdd���}|j|�t|tdd���}|j|�t|tdd���}|j|�|S)
z�This tests nested groups with multiple levels of coordinate transformation.
    Each box should be staggered up and to the right, moving by 25 points each time.r4r5rr`rOr�rPrXzText in the boxrd�r�)	rBr/r�rTrrFrGrCr�)r)rerfr�r��g3�g4s       r,�getDrawing10r�is���	��S��A��a�y�H��H�	���A�s�B�&�-�-�8��1�a�*�X�(�S�
�B��E�E�"�I�	�r�y��B�/�	0�B��E�E�"�I�	�r�y��B�/�	0�B��E�E�"�I�	�r�y��B�/�	0�B��E�E�"�I�
�Hr1)�
SmileyFacec	��d�}tdd�}td��}|j|dddtj��|jtddd	dtj�
��|jtdddd	tj�
��|j|�td��}|j|dddtj��|jtddd	dtj�
��|jtdddd	tj�
��|j|�td��}|S)
ztest of anchoringc�h�|}t�}||_||z
|_||z
|_|dz|_|S)z'Make a smiley data item representation.rc)r�r=�xr{rj)r�r{rjro�drJs      r,�
makeSmileyz getDrawing11.<locals>.makeSmiley�s;�����L�������c�����c����1�����r1r4r5)rhrrrhrrr�rOrYr��nrt)rcrrrcrOi����)rcrrrcrr)rBr�rCrrEr\r�r])r�r)�gs   r,�getDrawing11r��s����	��S��A�
�
�&�A��E�E�*�S��R��
�
�
+�,��E�E�$�r�#�c�#�&�,�,�
7�8��E�E�$�s�2�c�#�&�,�,�
7�8��E�E�!�H�
�*�+�A��E�E�*�S��R����
,�-��E�E�$�r�#�c�#�&�,�,�
7�8��E�E�$�s�2�c�#�&�,�,�
7�8��E�E�!�H�
�
�&�A��Hr1c
��d}tdd�}tddd�D]-}|jtd|dzzd|dzzd	||�
���/|S)z�Text strings in a non-standard font.
    All that is required is to place the .afm and .pfb files
    on the font path given in rl_config.py,
    for example in reportlab/fonts/.
    �DarkGardenMKr4r5r`rarbrYrcrRrd)rBrirCrG)�faceNamer)rjs   r,�getDrawing12r��se���H���S��A��b�"�a� �%��	���f�R��Q��Y���Q��Y�"�&�"�	$�	%�%�
�Hr1c�f�dd�}|t�\}}}|dkDs|dkDr|t||�\}}}|S)zTest Various TTF Fontsr4r5c��t||�}d|z|dzz}|d|zz}|}	d}
|D]�}|	|z}	|td�z}t|||�}
t|
|
dz�}
|j	tt
d|	|z
|
dz|tjd	tj�
�td|	|||����|	d
z}	��|
||	z
|z|fS)Nrcg333333�?g�������?rsl: I should be totally horizontal and enclosed in a box and end in alphabetagamma ¢©®£ʥЖփאقকαβγr��rbr9)r<r;r=rYrdrX)rBrr	�maxrCr�rTrrE�	lightgreyrG)r&�w�hrf�slack�gapr)�th�ghr{�maxxrer�r�s              r,�drawitzgetDrawing13.<locals>.drawit�s����A�a�L��
�s�U�X�c�\�
!��
�2�h�;�
��
�����	�H�
��G�A��H�&f�g�g�D�#�D�(�H�=�I��t�I�b�L�)�D�
�E�E��d�1�a��d�I��M�2�6�:�:�[]�io�iy�iy�z��2�q�$��h�O�Q�
R�
��F�A�	��Q�q�S��W�a��r1)r4r5r`rcrX)r/)r�r��maxyr)�_s     r,�getDrawing13r��s=�� � �6�N�M�D�$���C�x�4��8�V�F�4��%=�U�Q�q���Hr1c�b�ddlm}td�}|�jt	|��S)zcreate a small PIL imager)�	_getImages�R0lGODdhCgAHAIMAAP/////29v/d3f+ysv9/f/9VVf9MTP8iIv8ICP8AAAAAAAAAAAAAAAAAAAAA
AAAAACwAAAAACgAHAAAIMwABCBxIsKABAQASFli4MAECAgEAJJhIceKBAQkyasx4YECBjx8TICAQ
AIDJkwYEAFgZEAA7)�reportlab.graphics.renderPMr�r�openr)r��bs  r,�
smallArrowr��s-��5���	�A��;���G�A�J�'�'r1c	���ddlm}tdd�}t�}|j	|dddd|���t�}|j	|ddd	d
|���|S)ztest shapes.Imager)�Imager4r5N)r�r{�width�heightr"i|�r��)�reportlab.graphics.shapesr�rBr�rC)r�r)�im0�im1s    r,�getDrawing14r��sV��/���S��A�
�,�C��E�E�%�!�a�d�$�C�
8�9�
�,�C��E�E�%�&�6��"�#�
>�?��Hr1c��g}tt�j��}|j�|D]$}|dddk(s�|s|dk7s�|j	|��&|S)z4Get a list of drawing function names from somewhere.rrY�
getDrawingr�)�list�globals�keys�sortr%)�doTTF�	funcNames�symbolsrHs    r,�getAllFunctionDrawingNamesr��sd���I��7�9�>�>�#�$�G��L�L�N��+���A�b�>�\�)���.�0�� � ��*�+�
�r1c���|�
t�}|�
t�}|j||j|d��}	|�}|j	|t|dd�|ddf�y#t|�}Y�2xYw)Nz.__doc__��)r��locals�getrKr%�getattr)r'r)�lr��funcr�s      r,�_evalFuncDrawingr��st���y�g�i�!��y�f�h�!��5�5��a�e�e�D��&�'�D�#��F���H�H�a���j��,�d�1�2�h�
7�8��#��T�"��s�A&�&
A5c�D�g}t|��D]}t||��|S)N)r�)r�r�)r�r)r+s   r,�getAllTestDrawingsr��s*��
�A�
'�e�
4�����1����Hr1c��tjjtjd�ddz}t|�}|j
tdd�|jddd�|j
tdd�d}d	}|D]�\}}}|d
kr|j�d}|dz
}|j
tdd�|jd|d
||fz�|j
tdd�|dz
}|jd|�}|j|�|j|�|j�}||jz
}|j|d|�|d	z}��|j!�t#d|z�y)z4Create and save a PDF file containing some drawings.rz.pdf� r8i�zReportLab Graphics-Shapes Testr`i�rhrNrmrcz%s (#%d)r�z	wrote %s N)r!r"�splitextr�argvr�setFontr/�
drawString�showPage�	beginText�	textLines�drawText�getYr��drawOn�save�print)	�drawings�pdfPath�cr{rn�drawing�	docstring�funcname�textObjs	         r,�writePDFr	�sb���g�g���s�x�x��{�+�A�.��7�G��w��A��I�I�f�Q�i����L�L��S�:�;��I�I�f�Q�i����A�	�A�*2��&��)�X��s�7�
�J�J�L��A�
��F��	�	�	�&��)�B��	���R��J�(�A��6�7�	�	�	�&��)�B��
��F���+�+�b�!�$�����)�$�	�
�
�7���L�L�N��
���������q�"�a� �
��E��!�$�F�F�H�	�+��
� r1c�"�eZdZdZd�Zd�Zd�Zy)�ShapesTestCasez$Test generating all kinds of shapes.c�0�t�|_g|_y)z+Prepare some things before the tests start.N)r�r�r��selfs r,�setUpzShapesTestCase.setUps��4�5�����
r1c�.�t|j�y)z0Do what has to be done after the tests are over.N)r	rr
s r,�tearDownzShapesTestCase.tearDown#s��	����r1c�d�|jD]!}|dddk(s�t||j��#y)zMake a list of drawings.rrYr�N)r�r�r)rr+s  r,�testAllDrawingszShapesTestCase.testAllDrawings-s5�����	2�A���2�w�,�&�!��4�=�=�1�		2r1N)�__name__�
__module__�__qualname__�__doc__rrr�r1r,rrs��*�� �2r1rc�b�tj�}|jtd��|S)z#Make a test suite for unit testing.r)�unittest�	TestSuite�addTestr)�suites r,�	makeSuiter7s)��
��� �E�	�M�M�.�!2�3�4��Lr1�__main__)rh)NN)4�__version__rr!r�ior�
reportlab.libr�reportlab.lib.unitsr�reportlab.lib.utilsrr�reportlab.pdfgen.canvasr�reportlab.pdfbase.pdfmetricsr	r�rr/r-r0�reportlab.rl_configr2rKrVr^rkrpr}r�r�r�r�r��*reportlab.graphics.widgets.signsandsymbolsr�r�r�r�r�r�r�r�r�r	�TestCaserrr�TextTestRunner�runrr1r,�<module>r,s����	���� �"�<�*�4�'��	3�� 
�D�/��z��
��
�6
�
�.
�0
�"
�("
�H'
�T.
�`
�>
�4B�
�6
� 
�.(�
�
�9�
�!�D2�X�&�&�2�<��z���H����!�!�)�+�.�r1

Zerion Mini Shell 1.0