MetaPaths: gradually build a path with constraints, get a real path at thxe end.
MetaPaths are the objects used to describe lines, curves, and more generally almost everything that is drawn with Mlpost. A path (Path.t
) is defined by points and control points. A metapath is defined by points (knots) and constraints on the links between the points. A metapath is an easy way to define a path gradually with only a few points, and apply heuristics afterwards to transform it into a real path (using of_metapath
).
A direction
is used to put constraints on metapaths:
vec p
defines a direction by a point (interpreted as a vector)curl f
changes the curling factor of the extremity of a metapath; higher curling factor means flatter curvesnoDir
means no particular directionA knot
is the basic element of a metapath, and is simply a point with an incoming and outgoing direction constraint
Build a knot from a point; the optional arguments are the incoming directions.Warning they are going in the same direction.
A joint is the connection between two knots in a metapath. It is either
jLine
for a straight linejCurve
for a spline curvejCurveNoInflex
to avoid inflexion pointsjTension f1 f2
to specify "tension" on the joint; jCurve
uses a default tension of 1. Higher tension means less "wild" curvesjControls p1 p2
to explicitely specify control pointsval jCurveNoInflex : joint
val jTension : float -> float -> joint
The abstract type of metapaths
In all the functions below :
noDir is the default direction jCurve is the default joint Build a knot from a pair of floats
Build a knot from a Num.t pair; the optional arguments are as in knot
val path : ?style :joint -> ?scale :(float -> Num.t ) -> (float * float) list -> t
Build a metapath from a list of pairs of floats
Same as metapath
, but uses a Num.t
list
Same as metapath
, but uses a knot list
Same as metapath
but uses a point list
Build a metapath from n
knots and n-1
joints
Build a metapath from n
points and n-1
joints, with default directions
val jointpath :
?scale :(float -> Num.t ) ->
(float * float) list ->
joint list ->
t
Build a metapath from n
float_pairs and n-1
joints, with default directions
Close a metapath using direction dir
and style style
Add a knot at the end of a metapath
Create a simple metapath with one knot
val append : ?style :joint -> t -> t -> t
Append a metapath to another using joint style
Predefined valuesThe default joint style (JCurve
)
ConversionsCompute the control point of the path for a good looking result according to the constraint on the direction, tension, curve
Obtain a metapath from a path with exactly the same control point. p = of_metapath (of_path p) is true but not the opposite.