folkertdev/one-true-path-experiment/1.0.0

NOTE: this package is not compatible with Elm 0.19.1

Segment

An alternative interpretation of paths that is convenient for mathematical operations.

Here, a path is viewed as a list of segments with a start and end point.

type Segment
= LineSegment Coordinate Coordinate
| Quadratic Coordinate Coordinate Coordinate
| Cubic Coordinate Coordinate Coordinate Coordinate
| Arc
{ start : Coordinate
, end : Coordinate
, radii : ( Float, Float )
, xAxisRotate : Float
, arcFlag : ArcFlag
, direction : Direction
}

The four types of segments.

For segments, the xAxisRotate field is in radians.

fromPath : Path -> List Segment

Create segments from a path

toPath : List Segment -> Path

Convert a list of segments to a path

It is assumed that for every two adjacent segments in the list, the first segment's end point is the second segment's starting point

Operations

at : Float -> Segment -> ( Float, Float )

Get the location at a point on the curve, only defined in the range [0, 1].

length : Segment -> Float

The approximate length of a segment

{ minDepth : Int
, error : Float
}
-> Segment
-> Float

Supply the options for the approximation

  • minDepth: Minimum recursion depth for calculating the length of arc segments. Default is 10.
  • error: Minimal amount of progress that an recursive step must make. Default is 1.0e-12.