Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- commandsToPaths :: (RealFloat n, Show n) => [PathCommand n] -> [Path V2 n]
- splittedCommands :: RealFloat n => [PathCommand n] -> [[PathCommand n]]
- outline :: (RealFloat n, Show n) => [(Path V2 n, (n, n))] -> [PathCommand n] -> [(Path V2 n, (n, n))]
- nextSegment :: (RealFloat n, Show n) => ((n, n), (n, n), ClosedTrail [Trail' Line V2 n]) -> PathCommand n -> ((n, n), (n, n), ClosedTrail [Trail' Line V2 n])
- svgArc :: (RealFloat n, Show n) => (n, n) -> n -> n -> n -> (n, n) -> Trail' Line V2 n
- data PathCommand n
- parsePathCommand :: Fractional n => Parser Text (Maybe [PathCommand n])
- commands :: (RealFloat n, Show n) => Maybe Text -> [PathCommand n]
Converting Path Commands
commandsToPaths :: (RealFloat n, Show n) => [PathCommand n] -> [Path V2 n] Source #
Convert path commands into trails
splittedCommands :: RealFloat n => [PathCommand n] -> [[PathCommand n]] Source #
split list when there is a Z(closePath) and also when there is a (M)oveto command (keep the M) and merge repeated lists of single Ms into one M command
outline :: (RealFloat n, Show n) => [(Path V2 n, (n, n))] -> [PathCommand n] -> [(Path V2 n, (n, n))] Source #
Take the endpoint of the latest path, append another path that has been generated from the path commands and return this whole path
nextSegment :: (RealFloat n, Show n) => ((n, n), (n, n), ClosedTrail [Trail' Line V2 n]) -> PathCommand n -> ((n, n), (n, n), ClosedTrail [Trail' Line V2 n]) Source #
The last control point and end point of the last path are needed to calculate the next line to append endpoint -> (controlPoint, startPoint, line) ->
svgArc :: (RealFloat n, Show n) => (n, n) -> n -> n -> n -> (n, n) -> Trail' Line V2 n Source #
The arc command: see http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes To Do: scale if rx,ry,xAxisRot are such that there is no solution
Parsing (Generating Path Commands)
data PathCommand n Source #
M AbsRel !(n, n) | AbsRel (x,y): Establish a new current point (with absolute coords) |
Z | Close current subpath by drawing a straight line from current point to current subpath's initial point |
L AbsRel !(n, n) | AbsRel (X,Y): A line from the current point to Tup which becomes the new current point |
H AbsRel !n | AbsRel x: A horizontal line from the current point (cpx, cpy) to (x, cpy) |
V AbsRel !n | AbsRel y: A vertical line from the current point (cpx, cpy) to (cpx, y) |
C AbsRel !(n, n, n, n, n, n) | AbsRel (X1,Y1,X2,Y2,X,Y): Draws a cubic Bézier curve from the current point to (x,y) using (x1,y1) as the ^control point at the beginning of the curve and (x2,y2) as the control point at the end of the curve. |
S AbsRel !(n, n, n, n) | AbsRel (X2,Y2,X,Y): Draws a cubic Bézier curve from the current point to (x,y). The first control point is assumed to be the reflection of the second control point on the previous command relative to the current point. (If there is no previous command or if the previous command was not an C, c, S or s, assume the first control point is coincident with the current point.) (x2,y2) is the second control point (i.e., the control point at the end of the curve). |
Q AbsRel !(n, n, n, n) | AbsRel (X1,Y1,X,Y): A quadr. Bézier curve from the curr. point to (x,y) using (x1,y1) as the control point. Nearly the same as cubic, but with one point less |
T AbsRel !(n, n) | AbsRel (X,Y): T_Abs = Shorthand/smooth quadratic Bezier curveto |
A AbsRel !(n, n, n, n, n, n, n) | AbsRel (rx,ry,xAxisRot,fl0,fl1,x,y): Elliptic arc |
Instances
Show n => Show (PathCommand n) Source # | |
Defined in Diagrams.SVG.Path showsPrec :: Int -> PathCommand n -> ShowS # show :: PathCommand n -> String # showList :: [PathCommand n] -> ShowS # |
parsePathCommand :: Fractional n => Parser Text (Maybe [PathCommand n]) Source #
The parser to parse the lines and curves that make an outline