folkertdev/one-true-path-experiment/2.0.0

NOTE: this package is not compatible with Elm 0.19.1

SubPath

Types

type SubPath

Type representing a subpath

A subpath is one moveto command followed by an arbitrary number of drawto commands.

Construction

subpath : MoveTo -> List DrawTo -> SubPath

Construct a subpath

empty : SubPath

An empty subpath

parse : String -> Result Error SubPath

Parse a single subpath

This parser will fail if there are multiple subpaths, use the parser in Path instead if multiple subpaths in your input are possible.

Conversion

element : SubPath -> List (Attribute msg) -> Svg msg

Construct an svg path element from a Path with the given attributes

toString : SubPath -> String

Convert a subpath into SVG path notation

toSegments : SubPath -> List Segment
parse : String -> Result Error SubPath

Parse a single subpath

This parser will fail if there are multiple subpaths, use the parser in Path instead if multiple subpaths in your input are possible.

SubPath
-> Maybe
{ moveto : MoveTo
, drawtos : List DrawTo
}

deconstruct a subpath into its components

Composition

continue : SubPath -> SubPath -> SubPath

Start the second subpath where the first one ends

connect : SubPath -> SubPath -> SubPath

Join two subpaths, connecting them with a straight line

continueSmooth : SubPath -> SubPath -> SubPath

Start the second subpath where the first one ends, and rotate it to continue smoothly

close : SubPath -> SubPath

Append a ClosePath at the end of the subpath (if none is present)

Mapping

translate : Vec2 Float -> SubPath -> SubPath

Translate the subpath by a vector

rotate : Float -> SubPath -> SubPath

Rotate a subpath around its starting point by an angle (in radians).

scale : Vec2 Float -> SubPath -> SubPath

Scale the subpath in the x and y direction

For more complex scaling operations, define a transformation matrix and use mapCoordinate.

mapCoordinate : (Vec2 Float -> Vec2 Float) -> SubPath -> SubPath

Map over all the 2D coordinates in a subpath

mapWithCursorState : (CursorState -> DrawTo -> b) -> SubPath -> List b

Map over each drawto with the CursorState available.

The CursorState contains the subpath start position and the current cursor position at the current DrawTo