
    p"h                     <    S r SSKrS	S jrS
S jrS rS rS rS rg)z+
Extension to create and manipulate shapes
    Nc              #     #    U S:  a  [        S5      eUb.  US-  [        R                  " [        R                  U -  5      -  nO Ub  US::  a  [        S5      eO[        S5      eS[        R                  -  U -  nUn[	        U 5       H;  nU[        R
                  " U5      -  U[        R                  " U5      -  4v   XT-  nM=     g7f)a  
Returns the corners of a regular polygon as iterable of (x, y) tuples. The polygon size is determined by the
`edge_length` or the `radius` argument. If both are given `edge_length` will be taken.

Args:
    num_corners: count of polygon corners
    edge_length: length of polygon side
    radius: circum radius
    rotation: rotation angle in radians

Returns: iterable of (x, y) tuples

   z0Argument `num_corners` has to be greater than 2.N           z+Argument `radius` has to be greater than 0.z,Argument `edge_length` or `radius` required.)
ValueErrormathsinpirangecos)num_cornersedge_lengthradiusrotationdeltaangle_s          L/var/www/html/env/lib/python3.13/site-packages/svgwrite/extensions/shapes.pyngonr   	   s      QKLLq488DGGk,A#BB		R<JKK  GHHK+%EE;'$((5/)ABB  s   CCc              #      #    U S:  a  [        S5      eUS::  a  [        S5      eUS::  a  [        S5      e[        XUS9n[        X[        R                  U -  U-   S9n[	        XE5       H  u  pgUv   Uv   M     g7f)a  
Create a star shape as iterable of (x, y) vertices.

Argument `spikes` defines the count of star spikes, `r1` defines the radius of the "outer" vertices and `r2`
defines the radius of the "inner" vertices, but this does not mean that `r1` has to greater than `r2`.

Args:
    spikes: spike count
    r1: radius 1
    r2: radius 2
    rotation: rotation angle in radians

Returns: iterable of (x, y) tuples

r   z+Argument `spikes` has to be greater than 2.r   z'Argument `r1` has to be greater than 0.z'Argument `r2` has to be greater than 0.)r   r   N)r   r   r   r
   zip)spikesr1r2r   corners1corners2s1s2s           r   starr   (   s       zFGG	RxBCC	RxBCCF9HFx0GHHh) *s   A9A;c              #   6   #    U  H  u  p4X1-   XB-   4v   M     g7f)z
Translates `vertices` about `delta_x` and `delta_y`

Args:
     vertices: iterable of (x, y) tuples
     delta_x: translation in x axis
     delta_y: translation in y axis

Returns: iterable of (x, y) tuples

N )verticesdelta_xdelta_yxys        r   	translater'   F   "      {AK((    c              #   6   #    U  H  u  p4X1-  XB-  4v   M     g7f)z
Scales `vertices` about `scale_x` and `scale_y`

Args:
     vertices: iterable of (x, y) tuples
     scale_x: scaling factor in x axis direction
     scale_y: scaling factor in y axis direction

Returns: iterable of (x, y) tuples

Nr!   )r"   scale_xscale_yr%   r&   s        r   scaler-   V   r(   r)   c              #      #    U  Hh  u  p#[         R                  " X#5      n[         R                  " X25      U-   nU[         R                  " U5      -  U[         R                  " U5      -  4v   Mj     g7f)z
Rotates `vertices` about `delta` degrees around the origin (0, 0).

Args:
     vertices: iterable of (x, y) tuples
     delta: rotation angle in radians

Returns: iterable of (x, y) tuples

N)r   hypotatan2r   r	   )r"   r   r%   r&   rr   s         r   rotater2   f   sY      JJq

1 5(488E?"A$788 s   A0A2c                 L    Su  pnU  H  u  pEX$-  nX5-  nUS-  nM     X!-  X1-  4$ )z2
Returns the centroid of a series of `vertices`.

)r   r   r      r!   )r"   kc_xc_yr%   r&   s         r   centroidr8   w   sA    
 KAC	Q  7CG    )NNr   )r   )__doc__r   r   r   r'   r-   r2   r8   r!   r9   r   <module>r;      s-   
 ><) ) 9"
r9   