Ë
    œ…j¬0  ã                  ó  — U d Z ddlmZ ddlmZmZmZmZ ddlm	Z	m
Z
 er ddlmZ ddlmZmZmZmZmZ ddlmZ ddlmZ d	Zd
ed<   dZd
ed<    G d„ dee   «      Z G d„ de«      Z G d„ de«      Z G d„ de«      Z G d„ de«      Zy)z3Objects related to construction of freeform shapes.é    )Úannotations)ÚTYPE_CHECKINGÚIterableÚIteratorÚSequence)ÚEmuÚlazyproperty)Ú	TypeAlias)Ú	CT_Path2DÚCT_Path2DCloseÚCT_Path2DLineToÚCT_Path2DMoveToÚCT_Shape)Ú_BaseGroupShapes)ÚLengthz2CT_Path2DClose | CT_Path2DLineTo | CT_Path2DMoveTor
   ÚCT_DrawingOperationz_LineSegment | _MoveTo | _CloseÚDrawingOperationc                  ót  ‡ — e Zd ZdZ	 	 	 	 	 	 	 	 	 	 dˆ fd„Z	 	 	 	 dd„Zdd„Zd„ Ze	 	 	 	 	 	 	 	 	 	 dd„«       Z	ddd„Z
 ed«       ed«      fdd	„Zd d
„Zed!d„«       Zed!d„«       Zd„ Zdd„Zd"d„Zed#d„«       Zed!d„«       Zed!d„«       Zed„ «       Zed„ «       Zd$d„Zd%d„Zed„ «       Zed„ «       Zˆ xZS )&ÚFreeformBuilderaP  Allows a freeform shape to be specified and created.

    The initial pen position is provided on construction. From there, drawing proceeds using
    successive calls to draw line segments. The freeform shape may be closed by calling the
    :meth:`close` method.

    A shape may have more than one contour, in which case overlapping areas are "subtracted". A
    contour is a sequence of line segments beginning with a "move-to" operation. A move-to
    operation is automatically inserted in each new freeform; additional move-to ops can be
    inserted with the `.move_to()` method.
    c                óp   •— t         t        | �  «        || _        || _        || _        || _        || _        y ©N)Úsuperr   Ú__init__Ú_shapesÚ_start_xÚ_start_yÚ_x_scaleÚ_y_scale)ÚselfÚshapesÚstart_xÚstart_yÚx_scaleÚy_scaleÚ	__class__s         €úU/root/aria/tools/markitdown-venv/lib/python3.12/site-packages/pptx/shapes/freeform.pyr   zFreeformBuilder.__init__'   s5   ø€ ô 	Œo˜tÑ-Ô/ØˆŒØˆŒØˆŒØˆŒØˆ�ó    c                ó8   — | j                   j                  |«      S r   )Ú_drawing_operationsÚ__getitem__)r   Úidxs     r&   r*   zFreeformBuilder.__getitem__6   s   € ð ×'Ñ'×3Ñ3°CÓ8Ð8r'   c                ó6   — | j                   j                  «       S r   )r)   Ú__iter__©r   s    r&   r-   zFreeformBuilder.__iter__;   s   € Ø×'Ñ'×0Ñ0Ó2Ð2r'   c                ó6   — | j                   j                  «       S r   )r)   Ú__len__r.   s    r&   r0   zFreeformBuilder.__len__>   s   € Ø×'Ñ'×/Ñ/Ó1Ð1r'   c                ó†   —  | |t        t        t        |«      «      «      t        t        t        |«      «      «      ||«      S )z˜Return a new |FreeformBuilder| object.

        The initial pen location is specified (in local coordinates) by
        (`start_x`, `start_y`).
        ©r   ÚintÚround)Úclsr    r!   r"   r#   r$   s         r&   ÚnewzFreeformBuilder.newA   s4   € ñ �6œ3œs¤5¨£>Ó2Ó3´S¼¼UÀ7»^Ó9LÓ5MÈwÐX_Ó`Ð`r'   c                ób   — |D ]  \  }}| j                  ||«       Œ |r| j                  «        | S )a�  Add a straight line segment to each point in `vertices`.

        `vertices` must be an iterable of (x, y) pairs (2-tuples). Each x and y value is rounded
        to the nearest integer before use. The optional `close` parameter determines whether the
        resulting contour is `closed` or left `open`.

        Returns this |FreeformBuilder| object so it can be used in chained calls.
        )Ú_add_line_segmentÚ
_add_close)r   ÚverticesÚcloseÚxÚys        r&   Úadd_line_segmentsz!FreeformBuilder.add_line_segmentsQ   s9   € ð ò 	)‰DˆAˆqØ×"Ñ" 1 aÕ(ð	)áØ�O‰OÔØˆr'   r   c                ó®   — | j                  ||«      }| j                  |«      }| D ]  }|j                  |«       Œ | j                  j	                  |«      S )a�  Return new freeform shape positioned relative to specified offset.

        `origin_x` and `origin_y` locate the origin of the local coordinate system in slide
        coordinates (EMU), perhaps most conveniently by use of a |Length| object.

        Note that this method may be called more than once to add multiple shapes of the same
        geometry in different locations on the slide.
        )Ú_add_freeform_spÚ_start_pathÚapply_operation_tor   Ú_shape_factory)r   Úorigin_xÚorigin_yÚspÚpathÚdrawing_operations         r&   Úconvert_to_shapez FreeformBuilder.convert_to_shape`   sY   € ð ×"Ñ" 8¨XÓ6ˆØ×Ñ Ó#ˆØ!%ò 	7ÐØ×0Ñ0°Õ6ð	7à�|‰|×*Ñ*¨2Ó.Ð.r'   c                óf   — | j                   j                  t        j                  | ||«      «       | S )z˜Move pen to (x, y) (local coordinates) without drawing line.

        Returns this |FreeformBuilder| object so it can be used in chained calls.
        )r)   ÚappendÚ_MoveTor6   ©r   r<   r=   s      r&   Úmove_tozFreeformBuilder.move_too   s*   € ð
 	× Ñ ×'Ñ'¬¯©°D¸!¸QÓ(?Ô@Øˆr'   c                óŒ   — | j                   }| D ])  }t        |t        «      rŒt        ||j                  «      }Œ+ t        |«      S )a  Return x distance of shape origin from local coordinate origin.

        The returned integer represents the leftmost extent of the freeform shape, in local
        coordinates. Note that the bounding box of the shape need not start at the local origin.
        )r   Ú
isinstanceÚ_CloseÚminr<   r   )r   Úmin_xrH   s      r&   Úshape_offset_xzFreeformBuilder.shape_offset_xw   óJ   € ð —‘ˆØ!%ò 	4ÐÜÐ+¬VÔ4ØÜ˜Ð0×2Ñ2Ó3‰Eð	4ô �5‹zÐr'   c                óŒ   — | j                   }| D ])  }t        |t        «      rŒt        ||j                  «      }Œ+ t        |«      S )a  Return y distance of shape origin from local coordinate origin.

        The returned integer represents the topmost extent of the freeform shape, in local
        coordinates. Note that the bounding box of the shape need not start at the local origin.
        )r   rP   rQ   rR   r=   r   )r   Úmin_yrH   s      r&   Úshape_offset_yzFreeformBuilder.shape_offset_y…   rU   r'   c                ó^   — | j                   j                  t        j                  «       «       y)z7Add a close |_Close| operation to the drawing sequence.N)r)   rK   rQ   r6   r.   s    r&   r9   zFreeformBuilder._add_close“   s   € à× Ñ ×'Ñ'¬¯
©
«Õ5r'   c                ó²   — | j                   j                  }|j                  || j                  z   || j                  z   | j
                  | j                  «      S )zÚAdd a freeform `p:sp` element having no drawing elements.

        `origin_x` and `origin_y` are specified in slide coordinates, and represent the location
        of the local coordinates origin on the slide.
        )r   Ú_spTreeÚadd_freeform_spÚ_leftÚ_topÚ_widthÚ_height)r   rD   rE   ÚspTrees       r&   r@   z FreeformBuilder._add_freeform_sp—   sI   € ð —‘×%Ñ%ˆØ×%Ñ%Ø�t—z‘zÑ! 8¨d¯i©iÑ#7¸¿¹ÀdÇlÁló
ð 	
r'   c                ód   — | j                   j                  t        j                  | ||«      «       y)z7Add a |_LineSegment| operation to the drawing sequence.N)r)   rK   Ú_LineSegmentr6   rM   s      r&   r8   z!FreeformBuilder._add_line_segment¢   s%   € à× Ñ ×'Ñ'¬×(8Ñ(8¸¸qÀ!Ó(DÕEr'   c                ó   — g S )z>Return the sequence of drawing operation objects for freeform.© r.   s    r&   r)   z#FreeformBuilder._drawing_operations¦   s	   € ð ˆ	r'   c                óÂ   — | j                   x}}| D ]?  }t        |t        «      rŒt        ||j                  «      }t        ||j                  «      }ŒA t        ||z
  «      S )z1Return width of this shape's path in local units.)r   rP   rQ   rR   r<   Úmaxr   )r   rS   Úmax_xrH   s       r&   Ú_dxzFreeformBuilder._dx«   óg   € ð Ÿ™Ð%ˆ�Ø!%ò 	4ÐÜÐ+¬VÔ4ØÜ˜Ð0×2Ñ2Ó3ˆEÜ˜Ð0×2Ñ2Ó3‰Eð		4ô
 �5˜5‘=Ó!Ð!r'   c                óÂ   — | j                   x}}| D ]?  }t        |t        «      rŒt        ||j                  «      }t        ||j                  «      }ŒA t        ||z
  «      S )z:Return integer height of this shape's path in local units.)r   rP   rQ   rR   r=   rg   r   )r   rW   Úmax_yrH   s       r&   Ú_dyzFreeformBuilder._dy¶   rj   r'   c                óX   — t        t        | j                  | j                  z  «      «      S )z½Return vertical size of this shape's path in slide coordinates.

        This value is based on the actual extents of the shape and does not include any
        positioning offset.
        )r3   r4   rm   r   r.   s    r&   r`   zFreeformBuilder._heightÁ   ó!   € ô ”5˜Ÿ™ D§M¡MÑ1Ó2Ó3Ð3r'   c                óX   — t        t        | j                  | j                  z  «      «      S )zåReturn leftmost extent of this shape's path in slide coordinates.

        Note that this value does not include any positioning offset; it assumes the drawing
        (local) coordinate origin is at (0, 0) on the slide.
        )r3   r4   rT   r   r.   s    r&   r]   zFreeformBuilder._leftÊ   s#   € ô ”5˜×,Ñ,¨t¯}©}Ñ<Ó=Ó>Ð>r'   c                ób   — t        || j                  z
  «      t        || j                  z
  «      fS )a  Translate local coordinates point to shape coordinates.

        Shape coordinates have the same unit as local coordinates, but are offset such that the
        origin of the shape coordinate system (0, 0) is located at the top-left corner of the
        shape bounding box.
        )r   rT   rX   )r   Úlocal_xÚlocal_ys      r&   Ú_local_to_shapezFreeformBuilder._local_to_shapeÓ   s/   € ô �7˜T×0Ñ0Ñ0Ó1´3°wÀ×ATÑATÑ7TÓ3UÐUÐUr'   c                óº   — |j                  | j                  | j                  ¬«      } |j                  | j	                  | j
                  | j                  «      Ž  |S )zÁReturn a newly created `a:path` element added to `sp`.

        The returned `a:path` element has an `a:moveTo` element representing the shape starting
        point as its only child.
        )ÚwÚh)Úadd_pathri   rm   Ú
add_moveTort   r   r   )r   rF   rG   s      r&   rA   zFreeformBuilder._start_pathÜ   sF   € ð �{‰{˜TŸX™X¨¯©ˆ{Ó2ˆØˆ�‰˜×-Ñ-¨d¯m©m¸T¿]¹]ÓKÑLØˆr'   c                óX   — t        t        | j                  | j                  z  «      «      S )a  Return topmost extent of this shape's path in slide coordinates.

        Note that this value does not include any positioning offset; it assumes the drawing
        (local) coordinate origin is located at slide coordinates (0, 0) (top-left corner of
        slide).
        )r3   r4   rX   r   r.   s    r&   r^   zFreeformBuilder._topæ   s#   € ô ”5˜×,Ñ,¨t¯}©}Ñ<Ó=Ó>Ð>r'   c                óX   — t        t        | j                  | j                  z  «      «      S )zºReturn width of this shape's path in slide coordinates.

        This value is based on the actual extents of the shape path and does not include any
        positioning offset.
        )r3   r4   ri   r   r.   s    r&   r_   zFreeformBuilder._widthð   ro   r'   )
r    r   r!   r   r"   r   r#   Úfloatr$   r|   )r+   r3   Úreturnr   )r}   zIterator[DrawingOperation])
r    r   r!   r|   r"   r|   r#   r|   r$   r|   )T)r:   zIterable[tuple[float, float]]r;   Úbool)rD   r   rE   r   )r<   r|   r=   r|   ©r}   r   )r<   r|   r=   r|   r}   ÚNone)r}   zlist[DrawingOperation])rr   r   rs   r   r}   ztuple[Length, Length])rF   r   r}   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r*   r-   r0   Úclassmethodr6   r>   r   rI   rN   ÚpropertyrT   rX   r9   r@   r8   r	   r)   ri   rm   r`   r]   rt   rA   r^   r_   Ú__classcell__©r%   s   @r&   r   r      s•  ø„ ñ
ð à ð ð ð ð ð	 ð
 ð ð õ ð9Øð9à	ó9ó
3ò2ð ðaà ðað ðað ð	að
 ðað òaó ðaôñ 36°a³&ÉSÐQRËVô /óð òó ðð òó ðò6ó	
óFð òó ðð ò"ó ð"ð ò"ó ð"ð ñ4ó ð4ð ñ?ó ð?óVóð ñ?ó ð?ð ñ4ó ô4r'   r   c                  óP   ‡ — e Zd ZdZdˆ fd„Zdd„Zedd„«       Zedd„«       Zˆ xZ	S )	Ú_BaseDrawingOperationz€Base class for freeform drawing operations.

    A drawing operation has at least one location (x, y) in local coordinates.
    c                óT   •— t         t        | �  «        || _        || _        || _        y r   )r   rŠ   r   Ú_freeform_builderÚ_xÚ_y)r   Úfreeform_builderr<   r=   r%   s       €r&   r   z_BaseDrawingOperation.__init__   s'   ø€ ÜÔ# TÑ3Ô5Ø!1ˆÔØˆŒØˆ�r'   c                ó   — t        d«      ‚)zuAdd the XML element(s) implementing this operation to `path`.

        Must be implemented by each subclass.
        z$must be implemented by each subclass)ÚNotImplementedError©r   rG   s     r&   rB   z(_BaseDrawingOperation.apply_operation_to  s   € ô
 "Ð"HÓIÐIr'   c                ó   — | j                   S )z…Return the horizontal (x) target location of this operation.

        The returned value is an integer in local coordinates.
        )r�   r.   s    r&   r<   z_BaseDrawingOperation.x  ó   € ð �w‰wˆr'   c                ó   — | j                   S )zƒReturn the vertical (y) target location of this operation.

        The returned value is an integer in local coordinates.
        )rŽ   r.   s    r&   r=   z_BaseDrawingOperation.y  r”   r'   )r�   r   r<   r   r=   r   )rG   r   r}   r   r   )
r�   r‚   rƒ   r„   r   rB   r†   r<   r=   r‡   rˆ   s   @r&   rŠ   rŠ   ú   s;   ø„ ñõ
óJð òó ðð òó ôr'   rŠ   c                  ó*   — e Zd ZdZedd„«       Zdd„Zy)rQ   z?Specifies adding a `<a:close/>` element to the current contour.c                ó   —  | «       S )zReturn a new _Close object.re   )r5   s    r&   r6   z
_Close.new!  s   € ñ ‹uˆr'   c                ó"   — |j                  «       S )z Add `a:close` element to `path`.)Ú	add_closer’   s     r&   rB   z_Close.apply_operation_to&  s   € à�~‰~ÓÐr'   N)r}   rQ   )rG   r   r}   r   ©r�   r‚   rƒ   r„   r…   r6   rB   re   r'   r&   rQ   rQ     s   „ ÙIàòó ðô r'   rQ   c                  ó*   — e Zd ZdZedd„«       Zdd„Zy)rc   z@Specifies a straight line segment ending at the specified point.c                ó‚   —  | |t        t        t        |«      «      «      t        t        t        |«      «      «      «      S )zŒReturn a new _LineSegment object ending at point *(x, y)*.

        Both `x` and `y` are rounded to the nearest integer before use.
        r2   ©r5   r�   r<   r=   s       r&   r6   z_LineSegment.new.  ó.   € ñ Ð#¤S¬¬U°1«X«Ó%7¼¼SÄÀqÃ»]Ó9KÓLÐLr'   c                óÎ   — |j                  t        | j                  | j                  j                  z
  «      t        | j
                  | j                  j                  z
  «      «      S )z}Add `a:lnTo` element to `path` for this line segment.

        Returns the `a:lnTo` element newly added to the path.
        )Úadd_lnTor   r�   rŒ   rT   rŽ   rX   r’   s     r&   rB   z_LineSegment.apply_operation_to6  sO   € ð
 �}‰}Ü�—‘˜$×0Ñ0×?Ñ?Ñ?Ó@Ü�—‘˜$×0Ñ0×?Ñ?Ñ?Ó@ó
ð 	
r'   N)r�   r   r<   r|   r=   r|   r}   rc   )rG   r   r}   r   rš   re   r'   r&   rc   rc   +  s   „ ÙJàòMó ðMô
r'   rc   c                  ó*   — e Zd ZdZedd„«       Zdd„Zy)rL   zSpecifies a new pen position.c                ó‚   —  | |t        t        t        |«      «      «      t        t        t        |«      «      «      «      S )z‰Return a new _MoveTo object for move to point `(x, y)`.

        Both `x` and `y` are rounded to the nearest integer before use.
        r2   r�   s       r&   r6   z_MoveTo.newD  rž   r'   c                óÎ   — |j                  t        | j                  | j                  j                  z
  «      t        | j
                  | j                  j                  z
  «      «      S )z7Add `a:moveTo` element to `path` for this line segment.)ry   r   r�   rŒ   rT   rŽ   rX   r’   s     r&   rB   z_MoveTo.apply_operation_toL  sM   € à�‰Ü�—‘˜$×0Ñ0×?Ñ?Ñ?Ó@Ü�—‘˜$×0Ñ0×?Ñ?Ñ?Ó@ó
ð 	
r'   N)r�   r   r<   r|   r=   r|   r}   rL   )rG   r   r}   r   rš   re   r'   r&   rL   rL   A  s   „ Ù'àòMó ðMô
r'   rL   N)r„   Ú
__future__r   Útypingr   r   r   r   Ú	pptx.utilr   r	   Útyping_extensionsr
   Úpptx.oxml.shapes.autoshaper   r   r   r   r   Úpptx.shapes.shapetreer   r   r   Ú__annotations__r   r   ÚobjectrŠ   rQ   rc   rL   re   r'   r&   ú<module>r¬      sŠ   ðÚ 9å "ç >Ó >ç 'áÝ+÷õ õ 7Ý à!UÐ �YÓ UØ?Ð �)Ó ?ô]4�hÐ/Ñ0ô ]4ô@!˜Fô !ôH
 ˆVô 
 ô
Ð(ô 
ô,
Ð#õ 
r'   