folkertdev/one-true-path-experiment/2.0.0

NOTE: this package is not compatible with Elm 0.19.1

LowLevel.Command

Low-level access to absolute svg drawing commands.

As the name implies, this is a low-level module that you probably shouldn't deal with.

Threading State

type alias CursorState =
{ start : Vec2 Float
, cursor : Vec2 Float
}

Contains the start of the current subpath and the current cursor position.

updateCursorState : DrawTo -> CursorState -> CursorState

Simulate the effect of a drawto command on the cursor position

Moving the cursor

type MoveTo
= MoveTo (Vec2 Float)

Constructors for MoveTo instructions

moveTo : Vec2 Float -> MoveTo

Move to a position on the canvas without drawing.

Drawing on the canvas

Type

type DrawTo
= LineTo (List (Vec2 Float))
| Horizontal (List Float)
| Vertical (List Float)
| CurveTo (List ( Vec2 Float, Vec2 Float, Vec2 Float ))
| SmoothCurveTo (List ( Vec2 Float, Vec2 Float ))
| QuadraticBezierCurveTo (List ( Vec2 Float, Vec2 Float ))
| SmoothQuadraticBezierCurveTo (List (Vec2 Float))
| EllipticalArc (List EllipticalArcArgument)
| ClosePath

Constructors for DrawTo instructions

Straight lines

lineTo : List (Vec2 Float) -> DrawTo

Draw a series of line segments to absolute positions. The L instruction.

horizontalTo : List Float -> DrawTo

Specific version of lineTo that only moves horizontally. The H instruction.

verticalTo : List Float -> DrawTo

Specific version of lineTo that only moves vertically. The V instruction

Close Path

closePath : DrawTo

Draw a straight line from the cursor position to the starting position of the path. The Z instruction.

Quadratic Beziers

quadraticCurveTo : List ( Vec2 Float, Vec2 Float ) -> DrawTo

A quadratic bezier. The Q instruction.

quadraticCurveExtendTo : List (Vec2 Float) -> DrawTo

A smooth extension to a quadratic bezier segment. The T instruction.

Cubic Beziers

cubicCurveTo : List ( Vec2 Float, Vec2 Float, Vec2 Float ) -> DrawTo

A cubic bezier. The C instruction.

cubicCurveExtendTo : List ( Vec2 Float, Vec2 Float ) -> DrawTo

A smooth extension to a cubic bezier segment. The S instruction.

Arcs

arcTo : List EllipticalArcArgument -> DrawTo

An elliptical arc. The A instruction.

{ radii : ( Float, Float )
, xAxisRotate : Float
, arcFlag : ArcFlag
, direction : Direction
, target : Vec2 Float
}

The arguments for an Arc

clockwise : Direction

Corresponds to a sweep flag of 1

counterClockwise : Direction

Corresponds to a sweep flag of 0

largestArc : ArcFlag

Corresponds to an arc flag of 1

smallestArc : ArcFlag

Corresponds to an arc flag of 0

type alias ArcFlag =
ArcFlag

Determine which arc to draw

type alias Direction =
Direction

Determine which arc to draw