
    h*                    |    S SK Jr  S SKJrJrJrJrJr  S SKrS SK	J
r
JrJr  S/r\(       a  S SK	Jr   " S S5      rg)    )annotations)IterableOptionalIteratorTYPE_CHECKINGoverloadN)Vec2UVecMatrix44Shape2d)BoundingBox2dc                     \ rS rSrSrSSS jjr\SS j5       r\SS j5       rSS jr	\	r
SS jrSSS	 jjrSS
 jrSSS jjrSSS jjrS S!S jjrSS jrS"S jr\S#S j5       r\S$S j5       rS%S jrS&S jrS'S jrSrg)(r      zConstruction 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                `    SSK Jn  S nUb  [        R                  " U5      nU" U5      U l        g )Nr   NumpyPoints2d)ezdxf.npshapesr   r	   generatenp_vertices)selfverticesr   _vec2s       B/var/www/html/env/lib/python3.13/site-packages/ezdxf/math/shape.py__init__Shape2d.__init__   s+    0'+MM(+E(/    c                6    U R                   R                  5       $ N)r   r   r   s    r   r   Shape2d.vertices"   s    ((**r   c                6    U R                   R                  5       $ )z&Returns the bounding box of the shape.)r   bboxr   s    r   bounding_boxShape2d.bounding_box&   s     $$&&r   c                d    U R                  5       nU R                  R                  5       Ul        U$ r   )	__class__r   clone)r   r'   s     r   copyShape2d.copy+   s*      ,,224r   c                    [        U5      nU R                  R                  [        R                  " UR
                  UR                  S5      5        g)zTranslate shape about `vector`.r   N)r	   r   transform_inplacer   	translatexy)r   vectoroffsets      r   r,   Shape2d.translate2   s7    f**8+=+=fhhRS+TUr   c                d    U R                   R                  [        R                  " XS5      5        g)z4Scale shape about `sx` in x-axis and `sy` in y-axis.   Nr   r+   r   scale)r   sxsys      r   r5   Shape2d.scale7   s!    **8>>"!+DEr   c                d    U R                   R                  [        R                  " XS5      5        g)z3Scale shape uniform about `scale` in x- and y-axis.r3   Nr4   )r   r5   s     r   scale_uniformShape2d.scale_uniform;   s!    **8>>%+JKr   c                P    U R                  [        R                  " U5      U5        g)z?Rotate shape around rotation `center` about `angle` in degrees.N)
rotate_radmathradians)r   anglecenters      r   rotateShape2d.rotate?   s    U+V4r   c                >   [         R                  " U5      nUbi  [        U5      n[         R                  " UR                  * UR
                  * S5      U-  [         R                  " UR                  UR
                  S5      -  nU R                  R                  U5        g)z?Rotate shape around rotation `center` about `angle` in radians.Nr   )r   z_rotater	   r,   r-   r.   r   r+   )r   r@   rA   mps        r   r=   Shape2d.rotate_radC   s    e$VA""ACC4!##q1$$QSS!##q12 
 	**1-r   c                j    SSK Jn  U R                  U" U R                  R	                  5       XS95      $ )ae  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)r0   closed)ezdxf.math.offset2drJ   r&   r   r   )r   r0   rK   rJ   s       r   r0   Shape2d.offsetO   s4     	;~~  ))+F
 	
r   c                l    SSK Jn  U R                  U" U R                  R	                  5       5      5      $ )z!Returns convex hull as new shape.r   )convex_hull_2d)ezdxf.math.construct2drO   r&   r   r   )r   rO   s     r   convex_hullShape2d.convex_hullb   s(    9~~nT-=-=-F-F-HIJJr   c                ,    [        U R                  5      $ )zReturns `count` of vertices.)lenr   r   s    r   __len__Shape2d.__len__i   s    4##$$r   c                    g r    r   items     r   __getitem__Shape2d.__getitem__m   s    .1r   c                    g r   rX   rY   s     r   r[   r\   o   s    69r   c                    U R                   R                  5       n[        U[        5      (       a  [        X!   5      $ [        R                  " X!   5      $ )z;Get vertex by index `item`, supports ``list`` like slicing.)r   
isinstanceintr	   list)r   rZ   r   s      r   r[   r\   q   sC    &&224dC  )**99[.//r   c                (    U R                  U45        g)zWAppend single `vertex`.

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

N)extend)r   vertexs     r   appendShape2d.appendy   s     	VIr   c                    SSK Jn  U R                  R                  5       [        R
                  " U5      -   nU" U5      U l        g)zlAppend multiple `vertices`.

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

r   r   N)r   r   r   r   r	   ra   )r   r   r   new_verticess       r   rc   Shape2d.extend   s6     	1''002TYYx5HH(6r   )r   r   )r   zOptional[Iterable[UVec]])return
list[Vec2])rj   r   )rj   r   )r/   r
   rj   None)      ?rm   )r6   floatr7   rn   rj   rl   )r5   rn   rj   rl   )r@   rn   rA   zOptional[UVec]rj   rl   )F)r0   rn   rK   boolrj   r   )rj   r`   )rZ   r`   rj   r	   )rZ   slicerj   rk   )rZ   zint | slicerj   zVec2 | list[Vec2])rd   r
   rj   rl   )r   zIterable[UVec]rj   rl   )__name__
__module____qualname____firstlineno____doc__r   propertyr   r#   r(   __copy__r,   r5   r:   rB   r=   r0   rQ   rU   r   r[   re   rc   __static_attributes__rX   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   r>   
ezdxf.mathr	   r
   r   __all__r   r   rX   r   r   <module>r}      s4    # H H  + + +(}7 }7r   