A low-level package for working with svg path strings
This package has two use cases
It is meant as a foundation: there is little type safety and convenience. It's just a literal translation of the SVG spec into elm data types.
Convert a list of subpaths to a string, with some extra formatting options
Formatting options
Set the maximum number of decimal places in the output string
myPath : List SubPath
myPath =
[ { moveto = MoveTo Relative ( 10, 20 )
, drawtos =
[ LineTo Absolute
[ ( 1 / 3, 1 / 3 )
, ( 1 / 7, 1 / 7 )
]
]
}
]
toStringWith [] myPath
--> "m10,20 L0.3333333333333333,0.3333333333333333 0.14285714285714285,0.14285714285714285"
toStringWith [ decimalPlaces 3 ] myPath
--> "m10,20 L0.333,0.333 0.143,0.143"A subpath is a MoveTo followed by a list of DrawTos
The mode of an instruction
Constructors for DrawTo instructions
Represent a point in 2D space with a tuple of floats
Determine which arc to draw
Determine which arc to draw
The arguments for an Arc
Turn the flags into numbers
case arcFlag of
LargestArc -> 1
SmallestArc -> 0
case direction of
Clockwise -> 0
CounterClockwise -> 1Try to decode two ints into flag values. Inverse of encodeFlags.
Convert a list of subpaths to svg path syntax