Irregular and Regular SVG Polygons


Set the two dimensional array Ipoly[] with distance in svg pixels, and counter clockwise rotational decimal values for the locations of the points in the design, [distance,angle] polar coordinates.
The make_polys() function can modifiy the Ipoly array and then call svgPoly2() function. The svgPoly2() function requires the x and y locations needed to set up the virtual Cartesian system on the svg canvas, a rotational offset to tip the design, fill color, stroke color and stroke width.
The svgPoly2() function can create regular and irregular polygons, multi line designs and complex shapes. Use loops for special effects. Loops can be used to change color, size, location and rotational offset of the design.
The functions work by creating a svg polygon from the first point in the Ipoly array to the second point in the array, from the second to the third and so on. The order of points is important. It is the difference between a pentagon and a pentagram. The best way understand the function is to download the text file. Save the file as .html , experiment with the code and view the results in your browser.

functions in .txt format
regular svg polygon function
home unit circle