Set the two dimensional array Ipoly[] with distance in pixels, and counter clockwise rotational decimal values for the locations of the points in the design, [distance,angle] polar coordinates.
The polys() function can modifiy the Ipoly array and then call either the polyFill function or the polyLine function. Those functions require the canvas ID,the X location for Cartesian coordinate origin, and the Y location of the origin, line color, line width value, and rotional offset. Canvas ID and color values are string values. The rotational offset is added to the angle value within the function.
polyFill() and polyLine() in turn call the Ipolygon() function. polyfill(), polyline() and Ipolygon() are sub functions of polys().
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.
The polys() 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 drawing a line 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.

polys() function in .txt format
regular polygon function
unit circle