Module Mlpost.MetaPath


module MetaPath: sig .. end
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).
type direction = Path.direction 
A direction is used to put constraints on metapaths:
val vec : Point.t -> direction
val curl : float -> direction
val noDir : direction
type knot = Path.knot 
A knot is the basic element of a metapath, and is simply a point with an incoming and outgoing direction constraint
val knotp : ?l:direction ->
?r:direction -> Point.t -> knot
Build a knot from a point; the optional arguments are the incoming directions
val knotlist : (direction * Point.t * direction) list ->
knot list
type joint = Path.joint 
A joint is the connection between two knots in a metapath. It is either
val jLine : joint
val jCurve : joint
val jCurveNoInflex : joint
val jTension : float -> float -> joint
val jControls : Point.t -> Point.t -> joint
type t 
The abstract type of metapaths
type path = Path.t 

In all the functions below :

Labelled metapath constructors


val knot : ?l:direction ->
?r:direction ->
?scale:(float -> Num.t) -> float * float -> knot
Build a knot from a pair of floats
l : an incoming direction
r : an outgoing direction
scale : a scaling factor applied to the floats
val knotn : ?l:direction ->
?r:direction ->
Num.t * Num.t -> knot
Build a knot from a Num.t pair; the optional arguments are as in MetaPath.knot
val path : ?style:joint ->
?scale:(float -> Num.t) -> (float * float) list -> t
Build a metapath from a list of pairs of floats
style : the joint style used for all joints in the metapath
scale : permits to scale the whole metapath
val pathn : ?style:joint ->
(Num.t * Num.t) list -> t
Same as metapath, but uses a Num.t list
val pathk : ?style:joint ->
knot list -> t
Same as metapath, but uses a knot list
val pathp : ?style:joint -> Point.t list -> t
Same as metapath but uses a point list
val jointpathk : knot list -> joint list -> t
Build a metapath from n knots and n-1 joints
val jointpathp : Point.t list -> joint list -> t
Build a metapath from n points and n-1 joints, with default directions
val jointpathn : (Num.t * Num.t) list ->
joint list -> t
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
val cycle : ?dir:direction ->
?style:joint -> t -> path
Close a metapath using direction dir and style style

Primitive metapath constructors


val concat : ?style:joint ->
t -> knot -> t
Add a knot at the end of a metapath
val start : knot -> t
Create a simple metapath with one knot
val append : ?style:joint ->
t -> t -> t
Append a metapath to another using joint style

Predefined values


val defaultjoint : joint
The default joint style (JCurve)

Conversions


val to_path : t -> path
Compute the control point of the path for a good looking result according to the constraint on the direction, tension, curve
val of_path : path -> t
Obtain a metapath from a path with exactly the same control point. p = of_metapath (of_path p) is true but not the opposite.