Copyright | (c) 2013 Daniel Bergey |
---|---|
License | BSD-style (see LICENSE) |
Maintainer | bergey@alum.mit.edu |
Safe Haskell | None |
Language | Haskell2010 |
Define Diagrams Paths by specifying points and optionally directions and tension. Calculate control points to maintain smooth curvature at each point, following rules implemented in Donald Knuth's Metafont.
This module is intended to be imported qualified.
- module Diagrams.TwoD.Path.Metafont.Combinators
- fromString :: (TrailLike t, V t ~ V2, N t ~ n, Read n, RealFloat n) => Text -> Either ParseError t
- fromStrings :: (TrailLike t, V t ~ V2, N t ~ n, Read n, RealFloat n) => [Text] -> Either [ParseError] [t]
- fromPath :: (TrailLike t, V t ~ V2, N t ~ n, RealFloat n) => MFP n -> t
- flex :: (TrailLike t, V t ~ V2, N t ~ n, RealFloat n) => [P2 n] -> t
- metafont :: (TrailLike t, V t ~ V2, N t ~ n, RealFloat n) => MFPathData P n -> t
- metafontParser :: (Num n, Read n) => Parser (MFPath (Maybe (PathDir n)) (BasicJoin n) n)
Documentation
fromString :: (TrailLike t, V t ~ V2, N t ~ n, Read n, RealFloat n) => Text -> Either ParseError t Source
MF.fromString parses a Text value in MetaFont syntax, and attempts to return a TrailLike. Only a subset of Metafont is supported; see the tutorial for details.
fromStrings :: (TrailLike t, V t ~ V2, N t ~ n, Read n, RealFloat n) => [Text] -> Either [ParseError] [t] Source
fromStrings takes a list of MetaFont strings, and returns either
all errors, or, if there are no parsing errors, a TrailLike for
each string. fromStrings is provided as a convenience because the
MetaFont &-join is not supported. mconcat
(<>
) on the TrailLike is
equivalent, with clearer semantics.
fromPath :: (TrailLike t, V t ~ V2, N t ~ n, RealFloat n) => MFP n -> t Source
Should you wish to construct the MFPath in some other fashion, fromPath makes a TrailLike directly from the MFPath
flex :: (TrailLike t, V t ~ V2, N t ~ n, RealFloat n) => [P2 n] -> t Source
flex ps draws a Trail through the points ps, such that at every point p ∊ ps except the endpoints, the Trail is parallel to the line from the first to the last point. This is the same as the flex command defined in plain MetaFont.
metafont :: (TrailLike t, V t ~ V2, N t ~ n, RealFloat n) => MFPathData P n -> t Source
metafont converts a path defined in the Metafont combinator synax into a native Diagrams TrailLike.