Ë
    £èh¶  ã                  ór   — d dl mZ d dlmZmZmZmZmZ d dlZd dl	m
Z
mZmZ dgZerd dl	mZ  G d„ d«      Zy)é    )Úannotations)ÚIterableÚOptionalÚIteratorÚTYPE_CHECKINGÚoverloadN)ÚVec2ÚUVecÚMatrix44ÚShape2d)ÚBoundingBox2dc                  óÎ   — e Zd ZdZddd„Zedd„«       Zedd„«       Zdd„ZeZ	dd„Z
ddd„Zdd	„Zddd
„Zddd„Zddd„Zdd„Zd d„Zed!d„«       Zed"d„«       Zd#d„Zd$d„Zd%d„Zy)&r   zÝConstruction tools for 2D shapes.

    A 2D geometry object as list of :class:`Vec2` objects, vertices can be
    moved, rotated and scaled.

    Args:
        vertices: iterable of :class:`Vec2` compatible objects.

    Nc                ó\   — ddl m} d }|�t        j                  |«      } ||«      | _        y )Nr   ©ÚNumpyPoints2d)Úezdxf.npshapesr   r	   ÚgenerateÚnp_vertices)ÚselfÚverticesr   Ú_vec2s       ú0lib/python3.12/site-packages/ezdxf/math/shape.pyÚ__init__zShape2d.__init__   s+   € Ý0à'+ˆØÐÜ—M‘M (Ó+ˆEÙ(¨Ó/ˆÕó    c                ó6   — | j                   j                  «       S ©N)r   r   ©r   s    r   r   zShape2d.vertices"   s   € à×Ñ×(Ñ(Ó*Ð*r   c                ó6   — | j                   j                  «       S )z&Returns the bounding box of the shape.)r   Úbboxr   s    r   Úbounding_boxzShape2d.bounding_box&   s   € ð ×Ñ×$Ñ$Ó&Ð&r   c                ód   — | j                  «       }| j                  j                  «       |_        |S r   )Ú	__class__r   Úclone)r   r#   s     r   ÚcopyzShape2d.copy+   s*   € Ø—‘Ó ˆØ ×,Ñ,×2Ñ2Ó4ˆÔØˆr   c                ó¢   — t        |«      }| j                  j                  t        j                  |j
                  |j                  d«      «       y)zTranslate shape about `vector`.r   N)r	   r   Útransform_inplacer   Ú	translateÚxÚy)r   ÚvectorÚoffsets      r   r'   zShape2d.translate2   s7   € ä�f“ˆØ×Ñ×*Ñ*¬8×+=Ñ+=¸f¿h¹hÈÏÉÐRSÓ+TÕUr   c                ód   — | j                   j                  t        j                  ||d«      «       y)z4Scale shape about `sx` in x-axis and `sy` in y-axis.é   N©r   r&   r   Úscale)r   ÚsxÚsys      r   r/   zShape2d.scale7   s#   € à×Ñ×*Ñ*¬8¯>©>¸"¸bÀ!Ó+DÕEr   c                ód   — | j                   j                  t        j                  ||d«      «       y)z3Scale shape uniform about `scale` in x- and y-axis.r-   Nr.   )r   r/   s     r   Úscale_uniformzShape2d.scale_uniform;   s#   € à×Ñ×*Ñ*¬8¯>©>¸%ÀÈÓ+JÕKr   c                óN   — | j                  t        j                  |«      |«       y)z?Rotate shape around rotation `center` about `angle` in degrees.N)Ú
rotate_radÚmathÚradians)r   ÚangleÚcenters      r   ÚrotatezShape2d.rotate?   s   € à�‰œŸ™ UÓ+¨VÕ4r   c                ó6  — t        j                  |«      }|�gt        |«      }t        j                  |j                   |j
                   d«      |z  t        j                  |j                  |j
                  d«      z  }| j                  j                  |«       y)z?Rotate shape around rotation `center` about `angle` in radians.Nr   )r   Úz_rotater	   r'   r(   r)   r   r&   )r   r8   r9   ÚmÚps        r   r5   zShape2d.rotate_radC   s�   € ä×Ñ˜eÓ$ˆØÐÜ�V“ˆAä×"Ñ" A§C¡C 4¨!¯#©#¨¨qÓ1Øñä×$Ñ$ Q§S¡S¨!¯#©#¨qÓ1ñ2ð ð
 	×Ñ×*Ñ*¨1Õ-r   c                ór   — ddl m} | j                   || j                  j	                  «       ||¬«      «      S )a�  Returns a new offset shape, for more information see also
        :func:`ezdxf.math.offset_vertices_2d` function.

        Args:
            offset: line offset perpendicular to direction of shape segments
                defined by vertices order, offset > ``0`` is 'left' of line
                segment, offset < ``0`` is 'right' of line segment
            closed: ``True`` to handle as closed shape

        r   )Úoffset_vertices_2d)r+   Úclosed)Úezdxf.math.offset2dr@   r"   r   r   )r   r+   rA   r@   s       r   r+   zShape2d.offsetO   s6   € õ 	;à�~‰~ÙØ× Ñ ×)Ñ)Ó+°FÀ6ôó
ð 	
r   c                ól   — ddl m} | j                   || j                  j	                  «       «      «      S )z!Returns convex hull as new shape.r   )Úconvex_hull_2d)Úezdxf.math.construct2drD   r"   r   r   )r   rD   s     r   Úconvex_hullzShape2d.convex_hullb   s(   € å9à�~‰~™n¨T×-=Ñ-=×-FÑ-FÓ-HÓIÓJÐJr   c                ó,   — t        | j                  «      S )zReturns `count` of vertices.)Úlenr   r   s    r   Ú__len__zShape2d.__len__i   s   € ä�4×#Ñ#Ó$Ð$r   c                 ó   — y r   © ©r   Úitems     r   Ú__getitem__zShape2d.__getitem__m   s   € Ø.1r   c                 ó   — y r   rK   rL   s     r   rN   zShape2d.__getitem__o   s   € Ø69r   c                ó¢   — | j                   j                  «       }t        |t        «      rt        ||   «      S t        j                  ||   «      S )z;Get vertex by index `item`, supports ``list`` like slicing.)r   Ú
isinstanceÚintr	   Úlist)r   rM   r   s      r   rN   zShape2d.__getitem__q   sD   € à×&Ñ&×2Ñ2Ó4ˆÜ�dœCÔ Ü˜ DÑ)Ó*Ð*ä—9‘9˜[¨Ñ.Ó/Ð/r   c                ó(   — | j                  |f«       y)zoAppend single `vertex`.

        Args:
             vertex: vertex as :class:`Vec2` compatible object

        N)Úextend)r   Úvertexs     r   ÚappendzShape2d.appendy   s   € ð 	�‰�V�IÕr   c                óŠ   — ddl m} | j                  j                  «       t	        j
                  |«      z   } ||«      | _        y)z„Append multiple `vertices`.

        Args:
             vertices: iterable of vertices as :class:`Vec2` compatible objects

        r   r   N)r   r   r   r   r	   rS   )r   r   r   Únew_verticess       r   rU   zShape2d.extend‚   s6   € õ 	1à×'Ñ'×0Ñ0Ó2´T·Y±Y¸xÓ5HÑHˆÙ(¨Ó6ˆÕr   r   )r   zOptional[Iterable[UVec]])Úreturnú
list[Vec2])rZ   r   )rZ   r   )r*   r
   rZ   ÚNone)ç      ð?r]   )r0   Úfloatr1   r^   rZ   r\   )r/   r^   rZ   r\   )r8   r^   r9   zOptional[UVec]rZ   r\   )F)r+   r^   rA   ÚboolrZ   r   )rZ   rR   )rM   rR   rZ   r	   )rM   ÚslicerZ   r[   )rM   zint | slicerZ   zVec2 | list[Vec2])rV   r
   rZ   r\   )r   zIterable[UVec]rZ   r\   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úpropertyr   r    r$   Ú__copy__r'   r/   r3   r:   r5   r+   rF   rI   r   rN   rW   rU   rK   r   r   r   r      s™   „ ñô0ð ò+ó ð+ð ò'ó ð'óð
 €HóVô
FóLô5ô
.ô
ó&Kó%ð Ú1ó Ø1ØÚ9ó Ø9ó0óô
7r   )Ú
__future__r   Útypingr   r   r   r   r   r6   Ú
ezdxf.mathr	   r
   r   Ú__all__r   r   rK   r   r   Ú<module>rk      s4   ðõ #ß HÕ HÛ ß +Ñ +ð ˆ+€áÝ(÷}7ò }7r   