| Safe Haskell | Safe-Inferred | 
|---|---|
| Language | GHC2021 | 
Data.Path.Parser
Contents
Description
Conversions to and from an SVG path to a PathData
Synopsis
- parsePath :: ByteString -> Maybe [PathCommand]
 - pathParser :: Parser e [PathCommand]
 - command :: Parser e PathCommand
 - manyComma :: Parser e a -> Parser e [a]
 - svgToPathData :: ByteString -> [PathData Double]
 - pathDataToSvg :: [PathData Double] -> ByteString
 - data PathCommand
- = MoveTo !Origin ![Point Double]
 - | LineTo !Origin ![Point Double]
 - | HorizontalTo !Origin ![Double]
 - | VerticalTo !Origin ![Double]
 - | CurveTo !Origin ![(Point Double, Point Double, Point Double)]
 - | SmoothCurveTo !Origin ![(Point Double, Point Double)]
 - | QuadraticBezier !Origin ![(Point Double, Point Double)]
 - | SmoothQuadraticBezierCurveTo !Origin ![Point Double]
 - | EllipticalArc !Origin ![(Double, Double, Double, Bool, Bool, Point Double)]
 - | EndPath
 
 - data Origin
 - toPathDatas :: [PathCommand] -> [PathData Double]
 
Parsing
parsePath :: ByteString -> Maybe [PathCommand] Source #
Parse a raw path string.
:set -XOverloadedStrings let outerseg1 = "M-1.0,0.5 A0.5 0.5 0.0 1 1 0.0,-1.2320508075688774 1.0 1.0 0.0 0 0 -0.5,-0.3660254037844387 1.0 1.0 0.0 0 0 -1.0,0.5 Z" parsePath outerseg1
Just [MoveTo OriginAbsolute [Point (-1.0) 0.5],EllipticalArc OriginAbsolute [(0.5,0.5,0.0,True,True,Point 0.0 (-1.2320508075688774)),(1.0,1.0,0.0,False,False,Point (-0.5) (-0.3660254037844387)),(1.0,1.0,0.0,False,False,Point (-1.0) 0.5)],EndPath]
pathParser :: Parser e [PathCommand] Source #
Parser for PathCommands
command :: Parser e PathCommand Source #
Parser for a PathCommand
manyComma :: Parser e a -> Parser e [a] Source #
Items separated by a comma and one or more whitespace tokens either side.
svgToPathData :: ByteString -> [PathData Double] Source #
pathDataToSvg :: [PathData Double] -> ByteString Source #
data PathCommand Source #
Path command definition (ripped from reanimate-svg).
Constructors
| MoveTo !Origin ![Point Double] | M or m command  | 
| LineTo !Origin ![Point Double] | Line to, L or l Svg path command.  | 
| HorizontalTo !Origin ![Double] | Equivalent to the H or h svg path command.  | 
| VerticalTo !Origin ![Double] | Equivalent to the V or v svg path command.  | 
| CurveTo !Origin ![(Point Double, Point Double, Point Double)] | Cubic bezier, C or c command  | 
| SmoothCurveTo !Origin ![(Point Double, Point Double)] | Smooth cubic bezier, equivalent to S or s command  | 
| QuadraticBezier !Origin ![(Point Double, Point Double)] | Quadratic bezier, Q or q command  | 
| SmoothQuadraticBezierCurveTo !Origin ![Point Double] | Quadratic bezier, T or t command  | 
| EllipticalArc !Origin ![(Double, Double, Double, Bool, Bool, Point Double)] | Elliptical arc, A or a command.  | 
| EndPath | Close the path, Z or z svg path command.  | 
Instances
Tell if a path command is absolute (in the current user coordiante) or relative to the previous point.
Constructors
| OriginAbsolute | Next point in absolute coordinate  | 
| OriginRelative | Next point relative to the previous  | 
toPathDatas :: [PathCommand] -> [PathData Double] Source #
Convert from a path command list to a PathA specification