gabzim / circle-to-polygon

Receives a Coordinate, a Radius and a Number of edges and aproximates a circle by creating a polygon that fills its area
ISC License
113 stars 29 forks source link

Issue 13 possibility to add more options #16

Closed johachi closed 4 years ago

johachi commented 4 years ago

This PR makes it possible to pass either an object or a number to numberOfSegements. When passed as an object, the value of the key numberOfSegments will be used. Identical polygons will be returned when passing a number or passing an object.

This will close #13 and opens up for the possibility to add more options for the creation of the polygon.

TODO: Check if error should be thrown when numberOfSegemnts is an array, or if it should keep current behavior ( see this post https://github.com/gabzim/circle-to-polygon/issues/9#issuecomment-583929409 )

If error should be thrown, then add that functionallity. If error should not be thrown, add && !Array.isArray to else if (typeof options === "object") condition for getNumberOfSegments().