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

Create posibility to add more options to be passed to circleToPolygon #13

Closed johachi closed 3 years ago

johachi commented 4 years ago

Problem Description

Currently the only possible optional configuration of circleToPolygon is numberOfSegments. We want to expand the functionality of circleToPolygon to allow for more optional configurations like creating MultiPolygon (if needed) and to not follow the right-hand rule. We want to do this without increasing the number of parameters for circleToPlygon

Proposed solution

The reason that there should not be any error thrown if options is an object without the key numberOfSegements is that all options should be optional. The user might set different options depending on different conditions. We do not want the code to throw an error if one or both of x and y are false.

const options = {}

if (x) {
  options.numberOfSegments = 12;
}

if (y) {
  options.futureOption = futureOptionValue;
}

const polygonCircle = circleToPolygon(center, radius, options)

circleToPolygon's Current Parameters (for reference)

johachi commented 3 years ago

Closed by https://github.com/gabzim/circle-to-polygon/pull/29