diagrams-contrib-1.1.2: Collection of user contributions to diagrams EDSL

Copyright(c) 2013 Daniel Bergey
LicenseBSD-style (see LICENSE)
Safe HaskellNone



Solve equations due to John Hobby, as implemented in Donald Knuth's Metafont, to create (usually) smooth paths from specified points and directions.



solve :: MFP -> MFPath Dir BasicJoin Source

Run all the rules required to fully specify all segment directions, but do not replace the Joins with ControlJoin.

computeControls :: MetafontSegment Dir (Either TensionJoin ControlJoin) -> MetafontSegment () ControlJoin Source

Take a segment whose endpoint directions have been fully determined, and compute the control points to realize it as a cubic Bézier segment. If the segment already has control points specified, the directions are ignored (they are assumed to match). If the segment tensions are specified as TensionAtLeast, check whether the minimum tension will lead to an inflection point. If so, pick the maximum velocity (equivalent to minimum tension) that avoids the inflection point. Otherwise, calculate the velocity from the tension using hobbyF. Then calculate the control point positions from the direction and the velocity. Afterwards we can forget the direction information (since the control points are what we really want, and the directions can be recovered by subtracting the control points from the endpoints anyway).

locatedTrail :: MFPath () ControlJoin -> Located (Trail R2) Source

Convert a MetaFont path to a Diagrams Trail, using a Loop or Line as needed

mfPathToSegments :: MFPathData P -> MFP Source

Convert a path in combinator syntax to the internal representation used for solving.