
     h                     8    d Z ddlZd	dZd
dZd Zd Zd Zd Zy)z+
Extension to create and manipulate shapes
    Nc              #     K   | dk  rt        d      |-|dz  t        j                  t        j                  | z        z  }n||dk  rt        d      t        d      dt        j                  z  | z  }|}t	        |       D ]9  }|t        j
                  |      z  |t        j                  |      z  f ||z  }; yw)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          v/home/developers/rajanand/mypropertyqr-fmb-refixing-v2/venv/lib/python3.12/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   B=B?c              #     K   | dk  rt        d      |dk  rt        d      |dk  rt        d      t        | ||      }t        | |t        j                  | z  |z         }t	        ||      D ]  \  }}| |  yw)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F29HF2x0GHHh) Bs   A>B c              #   8   K   | D ]  \  }}||z   ||z   f  yw)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   .       )17{AK(()   c              #   8   K   | D ]  \  }}||z  ||z  f  yw)a  
    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              #      K   | D ]f  \  }}t        j                  ||      }t        j                  ||      |z   }|t        j                  |      z  |t        j                  |      z  f h yw)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   se       91JJq!

1a 5(488E?"A$7889s   A-A/c                 T    d\  }}}| D ]  \  }}||z  }||z  }|dz  } ||z  ||z  fS )z:
    Returns the centroid of a series of `vertices`.

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