
    Kwgi                     8    d Z dZddlmZ ddlmZ  G d d      Zy)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                   l    e Zd ZdZddZd Zd Zd Zd Zd Z	dd	Z
dd
Zd Zd ZddZd Zd Zd Zy)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                 B    |g f|d u    | _         | j                  | _        y N)_code_init_code_append_code_append)selfcodes     R/var/www/horilla/myenv/lib/python3.12/site-packages/reportlab/pdfgen/pathobject.py__init__zPDFPathObject.__init__   s$    2Ytt|,
 22    c                     |j                  d      s|j                  d      sJ d       | j                  j                  } |d        ||       || _        y )Nz mz rez%path must start with a moveto or rectn)endswithr	   appendr   )r   ccode_appends      r   r
   zPDFPathObject._init_code_append#   sK    zz$1::e#4]6]]4jj''CA'r   c                 8    dj                  | j                        S )z#pack onto one line; used internally )joinr	   r   s    r   getCodezPDFPathObject.getCode*   s    xx

##r   c                 @    | j                  dt        ||      z         y )Nz%s mr   r   r   xys      r   moveTozPDFPathObject.moveTo.       &6!A;./r   c                 @    | j                  dt        ||      z         y )Nz%s lr   r   s      r   lineTozPDFPathObject.lineTo1   r"   r   c                 H    | j                  dt        ||||||      z         y )Nz%s cr   )r   x1y1x2y2x3y3s          r   curveTozPDFPathObject.curveTo4   s$    &6"b"b"b#AABr   c           
      V    | j                  t        j                  ||||||             y)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   	bezierArcr   r&   r'   r(   r)   startAngextents          r   arczPDFPathObject.arc7   s%     	W&&r"bXvFGr   c           
      X    | j                  t        j                  ||||||      d       y)zmLike arc, but draws a line from the current point to
        the start if the start is not the current point.r$   Nr.   r1   s          r   arcTozPDFPathObject.arcToC   s'     	W&&r"bXvFxPr   c           	      F    | j                  dt        ||||f      z         y)zAdds a rectangle to the pathz%s reNr   r   r   r    widthheights        r   rectzPDFPathObject.rectH   s#    'FAq%+@$AABr   c           
      b    | j                  t        j                  ||||z   ||z   dd             y)zadds an ellipse to the pathr   ih  Nr.   r8   s        r   ellipsezPDFPathObject.ellipseL   s+    W&&q!QYq6z1cJKr   c                 `     t        | |      |d   d d   |D ]  } | j                  |dd     y )Nr      )getattrr,   )r   curvesinitialcurves       r   r/   zPDFPathObject._curvesP   s@    Wvay!}- 	%EDLL%)$	%r   c                 N    ||z
  }||z
  }d|z  x}}| j                  ||||       y)zadds a circle to the pathr?   N)r=   )r   x_ceny_cenrr&   r'   r9   r:   s           r   circlezPDFPathObject.circleU   s4    QYQY1RUF+r   c           
         d}|||z   f}t        |      t        |      }}|||z   f}	t        |	      t        |	      }	}
t        |t        t        f      r|D cg c]  }t        d|       c}}t        |      dk  r|dt        |      z
  dgz  z  }| j                  ||d   z   |
       | j                  ||d   z
  |
       |d   dkD  r*||d   z  }| j                  ||z
  |
||
|z   ||
|d   z          | j                  ||	|d   z
         |d   dkD  r*||d   z  }| j                  ||	|z
  ||z
  |	||d   z
  |	       | j                  ||d   z   |	       |d   dkD  r*||d   z  }| j                  ||z   |	||	|z
  ||	|d   z
         | j                  ||
|d   z          |d   dkD  r||d   z  }| j                  ||
|z   ||z   |
||d   z   |
       n||z  }| j                  ||z   |
       | j                  ||z
  |
       | j                  ||z
  |
||
|z   ||
|z          | j                  ||	|z
         | j                  ||	|z
  ||z
  |	||z
  |	       | j                  ||z   |	       | j                  ||z   |	||	|z
  ||	|z
         | j                  ||
|z          | j                  ||
|z   ||z   |
||z   |
       | j                          yc c}w )z{Draws a rectangle with rounded corners. The corners are
        approximately quadrants of a circle, with the given radius.gW[?r      r?         N)
minmax
isinstancelisttuplelenr!   r$   r,   close)r   r   r    r9   r:   radiusmxhixloyhiylorG   ts                r   	roundRectzPDFPathObject.roundRect\   s    %is8SXS&js8SXSfd5\*#)*aQq*A1vaxqQx!n,KKad
C(KKad
C(tAvadFS1Wc3acAaDjIKKS1Q4Z(tAvadFS#'37CqtSIKKad
C(tAvadFS1Wc3acAaDjIKKS1Q4Z(tAvadFS#'37CqtSI F
AKKfc*KKfc*LLq#sC!GS#,GKKS6\*LLcAgsQwS6\3GKKfc*LLq#sC!GS#,GKKS6\*LLcAgsQwS6\3G

? +s   Kc                 &    | j                  d       y)z%draws a line back to where it startedhN)r   r   s    r   rS   zPDFPathObject.close   s    #r   r   )r   Z   )r!   )__name__
__module____qualname____doc__r   r
   r   r!   r$   r,   r4   r6   r;   r=   r/   rH   r[   rS    r   r   r   r      sS    3($00C
HQ
CL%
,+Zr   r   N)__version__rb   reportlab.pdfgenr   reportlab.lib.rl_accelr   r   rc   r   r   <module>rg      s'    	 % )y yr   