folkertdev/one-true-path-experiment/1.0.0

NOTE: this package is not compatible with Elm 0.19.1

Curve

Linear

linear : List (Vec2 Float) -> Path

Draw straight lines between the data points.

linearClosed : List (Vec2 Float) -> Path

Draw a straigt line between the data points, connecting the ends.

Step

step : Float -> List (Vec2 Float) -> Path
stepBefore : List (Vec2 Float) -> Path
stepAfter : List (Vec2 Float) -> Path

Basis

basis : List (Vec2 Float) -> Path

Basis interpolation (also known as B-spline)

basisClosed : List (Vec2 Float) -> Path

Closed Basis interpolation (also known as B-spline)

basisOpen : List (Vec2 Float) -> Path
bundle : Float -> List (Vec2 Float) -> Path

Cardinal

cardinal : Float -> List (Vec2 Float) -> Path
cardinalClosed : Float -> List (Vec2 Float) -> Path
cardinalOpen : Float -> List (Vec2 Float) -> Path

Catmull-Rom

Catmull-Rom splines are a special case of cardinal splines. These curves are great for animation, because the data points are hit exactly and the curve is smooth.

catmullRom : Float -> List (Vec2 Float) -> Path
catmullRomClosed : Float -> List (Vec2 Float) -> Path
catmullRomOpen : Float -> List (Vec2 Float) -> Path

Monotone

The meaning of monotone is best illustrated:

Notice that around 0.45, the cubic interpolation dives below the y-coordinate of the next point, whereas the monotone interpolation does not.

More formally, a monotone curve between two points is either increasing (staying flat or becoming higher) or decreasing (staying flat or becoming lower). It cannot first go down and then go up.

monotoneX : List (Vec2 Float) -> Path

Draw a curve monotone in y

Note, does not deal well with coincident points

monotoneY : List (Vec2 Float) -> Path

Natural

natural : List (Vec2 Float) -> Path

Transformations

radial : Vec2 Float -> List (Vec2 Float) -> Path

Interpret a 2D vector as a (angle, radius) pair. The angle is in radians. The first argument is the center.

toPolarWithCenter : Vec2 Float -> List (Vec2 Float) -> List (Vec2 Float)

Convert (angle, radius) pairs to (x, y) coordinates, relative to the given vector.

This function is used by radial and can be used to use radial with different interpolations, for instance.

radialNatural  : Vec2 Float -> List (Vec2 Float) -> Path
radialNatural ( x, y ) =
    natural << toPolarWithCenter ( x, y )

WIP TEST

naturalControlPoints : List (Vec2 Float) -> List (Vec3 (Vec2 Float))

calculate the control points for natural spline interpolation