
    Og*                    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   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                \    ddl m} d }|t        j                  |      } ||      | _        y )Nr   NumpyPoints2d)ezdxf.npshapesr   r	   generatenp_vertices)selfverticesr   _vec2s       U/var/www/html/public_html/myphp/venv/lib/python3.12/site-packages/ezdxf/math/shape.py__init__zShape2d.__init__   s+    0'+MM(+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+=+=fhh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""ACC4!##q1$$QSS!##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     	;~~  ))+F6
 	
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~~nT-=-=-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dC D)**99[.//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     	VIr   c                    ddl m} | j                  j                         t	        j
                  |      z   } ||      | _        y)zAppend 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2TYYx5H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   