a
    7Xhi                     @   s2   d Z dZddlmZ ddlmZ G dd dZdS )z3.3.0z
PDFPathObject is an efficient way to draw paths on a Canvas. Do not
instantiate directly, obtain one from the Canvas instead.

Progress Reports:
8.83, 2000-01-13, gmcm: created from pdfgen.py

    )pdfgeom)fp_strc                   @   s   e Zd ZdZd"ddZdd Zdd Zd	d
 Zdd Zdd Z	d#ddZ
d$ddZdd Zdd Zd%ddZdd Zdd Zd d! ZdS )&PDFPathObjecta:  Represents a graphic path.  There are certain 'modes' to PDF
    drawing, and making a separate object to expose Path operations
    ensures they are completed with no run-time overhead.  Ask
    the Canvas for a PDFPath with getNewPathObject(); moveto/lineto/
    curveto wherever you want; add whole shapes; and then add it back
    into the canvas with one of the relevant operators.

    Path objects are probably not long, so we pack onto one line

    the code argument allows a canvas to get the operations appended directly so
    avoiding the final getCode
    Nc                 C   s   |g f|d u  | _ | j| _d S )N)_code_init_code_append_code_append)selfcode r
   `/var/www/viveiro_mudafortebrasil/venv/lib/python3.9/site-packages/reportlab/pdfgen/pathobject.py__init__   s    zPDFPathObject.__init__c                 C   s>   | ds| dsJ d| jj}|d || || _d S )Nz mz rez%path must start with a moveto or rectn)endswithr   appendr   )r   cZcode_appendr
   r
   r   r   #   s
    zPDFPathObject._init_code_appendc                 C   s   d | jS )z#pack onto one line; used internally )joinr   r   r
   r
   r   getCode*   s    zPDFPathObject.getCodec                 C   s   |  dt||  d S )Nz%s mr   r   r   xyr
   r
   r   moveTo.   s    zPDFPathObject.moveToc                 C   s   |  dt||  d S )Nz%s lr   r   r
   r
   r   lineTo1   s    zPDFPathObject.lineToc              
   C   s    |  dt||||||  d S )Nz%s cr   )r   x1y1x2y2Zx3Zy3r
   r
   r   curveTo4   s    zPDFPathObject.curveTor   Z   c              
   C   s   |  t|||||| dS )a  Contributed to piddlePDF by Robert Kern, 28/7/99.
        Draw 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.

        The algorithm is an elliptical generalization of the formulae in
        Jim Fitzsimmon's TeX tutorial <URL: http://www.tinaja.com/bezarc1.pdf>.N_curvesr   Z	bezierArcr   r   r   r   r   ZstartAngZextentr
   r
   r   arc7   s    
zPDFPathObject.arcc              
   C   s    |  t||||||d dS )zmLike arc, but draws a line from the current point to
        the start if the start is not the current point.r   Nr!   r#   r
   r
   r   arcToC   s    zPDFPathObject.arcToc                 C   s   |  dt||||f  dS )zAdds a rectangle to the pathz%s reNr   r   r   r   widthheightr
   r
   r   rectH   s    zPDFPathObject.rectc              
   C   s&   |  t|||| || dd dS )zadds an ellipse to the pathr   ih  Nr!   r&   r
   r
   r   ellipseL   s    zPDFPathObject.ellipser   c                 C   s:   t | ||d d d   |D ]}| j|dd    qd S )Nr      )getattrr   )r   ZcurvesinitialZcurver
   r
   r   r"   P   s    zPDFPathObject._curvesc                 C   s0   || }|| }d|  }}|  |||| dS )zadds a circle to the pathr+   N)r*   )r   Zx_cenZy_cenrr   r   r'   r(   r
   r
   r   circleU   s    zPDFPathObject.circlec              
   C   s  d}||| f}t |t| }}||| f}	t |	t|	 }
}	t|ttfrdd |D }t|dk r|dt| dg 7 }| ||d  |
 | ||d  |
 |d dkr||d  }| || |
||
| ||
|d   | ||	|d   |d dkr6||d  }| ||	| || |	||d  |	 | ||d  |	 |d dkr||d  }| || |	||	| ||	|d   | ||
|d   |d dkr||d  }| ||
| || |
||d  |
 n|| }| || |
 | || |
 | || |
||
| ||
|  | ||	|  | ||	| || |	|| |	 | || |	 | || |	||	| ||	|  | ||
|  | ||
| || |
|| |
 | 	  d	S )
z{Draws a rectangle with rounded corners. The corners are
        approximately quadrants of a circle, with the given radius.gW[?c                 S   s   g | ]}t d |qS )r   )max).0r.   r
   r
   r   
<listcomp>h       z+PDFPathObject.roundRect.<locals>.<listcomp>   r   r+         N)
minr0   
isinstancelisttuplelenr   r   r   close)r   r   r   r'   r(   ZradiusmZxhiZxloZyhiZylor.   tr
   r
   r   	roundRect\   sH    "$$$&    zPDFPathObject.roundRectc                 C   s   |  d dS )z%draws a line back to where it startedhN)r   r   r
   r
   r   r<      s    zPDFPathObject.close)N)r   r    )r   r    )r   )__name__
__module____qualname____doc__r   r   r   r   r   r   r$   r%   r)   r*   r"   r/   r?   r<   r
   r
   r
   r   r      s   



-r   N)__version__rD   Zreportlab.pdfgenr   Zreportlab.lib.rl_accelr   r   r
   r
   r
   r   <module>   s   	