Module for layering SubPaths into Paths.
Most of the interesting stuff happens in the SubPath and Curve modules.
Path is simply for combining multiple subpaths into one string or element.
Parse a path string into a Path
import Curve
import SubPath exposing (SubPath)
expected : SubPath
expected =
Curve.linear [ (0,0), (42, 73) ]
parse "M0,0 l42,73"
--> Ok [expected]Only accepts valid complete subpaths (a sequences of a move followed by zero or more draws). Relative instructions are converted to absolute ones. Short-hand curve extensions are converted to explicit curve instructions.
The parser uses elm-tools/parser.
The error type is Parser.Error.
Construct an svg path element from a Path with the given attributes
Turn a Path into a String. The result is ready to be used with the d attribute.
import Curve
import SubPath exposing (SubPath)
myPath : SubPath
myPath =
Curve.linear [ (0,0), (42, 73) ]
Path.toString [ myPath ]
--> "M0,0 L42,73"
-- forms a cycle (almost isomorphism) with parse
arc : String
arc = "M80,230 A45,45 90 0 1 125,275"
arc
|> parse
|> Result.map Path.toString
--> Ok arcConverting a svg-path-lowlevel subpath into a one-true-path subpath. Used in parsing
Convert a path to a svg-path-lowlevel list of subpaths
A path is a list of
SubPaths.