alexbol99 / flatten-js

Javascript library for 2d geometry
MIT License
551 stars 58 forks source link

feature request: construct Arc from the parameters used in SVG #147

Closed ensconced closed 1 year ago

ensconced commented 1 year ago

In an SVG path an arc is defined from these parameters:

rx ry x-axis-rotation large-arc-flag sweep-flag x y

(and the start position is implicit from the preceding element of the path)

It would be nice to be able to construct an Arc in flatten-js using this same set of parameters. I think in flatten-js we would only need one radius parameter, and x-axis-rotation would not be relevant since Arc is always circular. i.e. we could have something like this:

arcFromSVGParameters(startPoint, endPoint, radius, largeArcFlag, sweepFlag)

alexbol99 commented 1 year ago

Hi, @ensconced , Arc class has undocumented method arcSE(center, start, end, counterClockwise) It constructs arc by center, start and end points Maybe this method is what you are looking for?

ensconced commented 1 year ago

ah brilliant, that works perfectly for my use-case! thank you

alexbol99 commented 1 year ago

Issue closed