mlpost
Library
Module
Module type
Parameter
Class
Class type
A direction
is used to put constraints on paths:
vec p
defines a direction by a point (interpreted as a vector)curl f
changes the curling factor of the extremity of a path; higher curling factor means flatter curvesnoDir
means no particular direction
val curl : float -> direction
val noDir : direction
A knot
is the basic element of a path, 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 path. 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 points
val jLine : joint
val jCurve : joint
val jCurveNoInflex : joint
val jTension : float -> float -> joint
In all the functions below :
- noDir is the default direction
- jCurve is the default joint
Labelled path constructors
Build a knot from a pair of floats
Build a knot from a Num.t pair; the optional arguments are as in knot
Build a path from a list of pairs of floats
Same as path
, but uses a Num.t
list
Build a path from n
points and n-1
joints, with default directions
Build a path from n
float_pairs and n-1
joints, with default directions
Close a path using direction dir
and style style
Primitive path constructors
More complex constructions on paths
point f p
returns a certain point on the path p
; f
is given "in control points": 0.
means the first control point, 1.
the second and so on; intermediate values are accepted.
direction f p
returns the direction of the tangent at point f p
.
subpath start end path
selects the subpath of path
that lies between start
and end
. start
and end
are given in control points, as in point
.
val transform : Transform.t -> t -> t
Apply a transformation to a path
cut_after p1 p2
cuts p2
after the intersection with p1
. To memorize the order of the arguments, you can read: "cut after p1
"
Predefined values
val defaultjoint : joint
The default joint style (JCurve
)
val fullcircle : t
A full circle of radius 1 and centered on the origin
val halfcircle : t
The upper half of fullcircle
val quartercircle : t
The right half of halfcircle
val unitsquare : t
A full square of size 1 and centered on the origin
Conversions
type metapath = MetaPath.t
Compute the control point of the path for a good looking result according to the constraint on the direction, tension, curve
Compute 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.
Smart path
val smart_path : ?style:joint -> orientation list -> Point.t -> Point.t -> t
Draw a path