bg:dZddlZd dZd dZdZdZdZd ZdS) z+ Extension to create and manipulate shapes Nc#K|dkrtd|(|dz tjtj|z z }n'||dkrtdntddtjz|z }|}t |D]7}|tj|z|tj|zfV||z }8dS)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.Nrz+Argument `radius` has to be greater than 0.z,Argument `edge_length` or `radius` required.) ValueErrormathsinpirangecos) num_corners edge_lengthradiusrotationdeltaangle_s k/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/svgwrite/extensions/shapes.pyngonr sQKLLLq48DGk,A#B#BB   R<<JKK K GHHH K+ %E E ;  '$(5//)ABBBB c#,K|dkrtd|dkrtd|dkrtdt|||}t||tj|z |z}t ||D] \}}|V|VdS)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 rz+Argument `spikes` has to be greater than 2.rz'Argument `r1` has to be greater than 0.z'Argument `r2` has to be greater than 0.)rrN)rrrr zip)spikesr1r2rcorners1corners2s1s2s rstarr (s zzFGGG RxxBCCC RxxBCCCF2999HF2x0GHHHHh))Brc#2K|D]\}}||z||zfVdS)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)verticesdelta_xdelta_yxys r translater(FA))17{AK((((())rc#2K|D]\}}||z||zfVdS)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_xscale_yr&r's rscaler-Vr)rc#K|D]b\}}tj||}tj|||z}|tj|z|tj|zfVcdS)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)rhypotatan2r r )r#rr&r'rrs rrotater2fsz991 Jq!   1a  5(48E??"A$78888899rcPd\}}}|D]\}}||z }||z }|dz }||z ||z fS)z: Returns the centroid of a series of `vertices`. )rrrr")r#kc_xc_yr&r's rcentroidr8wsR KAsC1 q q Q 7C!G r)NNr)r)__doc__rrr r(r-r2r8r"rrr:s  >< ) ) ) ) ) ) 999"     r