Module Mlpost.Path
Fixed Paths
type direction
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
type knot
A
knot
is the basic element of a path, 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. Warning they are going in the same direction.
type joint
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
val jControls : Point.t -> Point.t -> joint
Labelled path constructors
val knot : ?l:direction -> ?r:direction -> ?scale:(float -> Num.t) -> (float * float) -> knot
Build a knot from a pair of floats
- parameter l
an incoming direction
- parameter r
an outgoing direction
- parameter 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
knot
val path : ?style:joint -> ?cycle:joint -> ?scale:(float -> Num.t) -> (float * float) list -> t
Build a path from a list of pairs of floats
- parameter style
the joint style used for all joints in the path
- parameter cycle
if given, the path is closed using the given style
- parameter scale
permits to scale the whole path
val pathn : ?style:joint -> ?cycle:joint -> (Num.t * Num.t) list -> t
Same as
path
, but uses aNum.t
list
val jointpathp : Point.t list -> joint list -> t
Build a path from
n
points andn-1
joints, with default directions
Primitive path constructors
More complex constructions on paths
val point : float -> t -> Point.t
point f p
returns a certain point on the pathp
;f
is given "in control points":0.
means the first control point,1.
the second and so on; intermediate values are accepted.
val direction : float -> t -> Point.t
direction f p
returns the direction of the tangent atpoint f p
.
val subpath : float -> float -> t -> t
subpath start end path
selects the subpath ofpath
that lies betweenstart
andend
.start
andend
are given in control points, as inpoint
.
val transform : Transform.t -> t -> t
Apply a transformation to a path
val scale : Num.t -> t -> t
val rotate : float -> t -> t
val shift : Point.t -> t -> t
val yscale : Num.t -> t -> t
val xscale : Num.t -> t -> t
Shortcuts for transformations of Paths
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
Smart path
type orientation
=
|
Up
|
Down
|
Left
|
Right
|
Upn of Num.t
|
Downn of Num.t
|
Leftn of Num.t
|
Rightn of Num.t
val smart_path : ?style:joint -> orientation list -> Point.t -> Point.t -> t
val draw : ?brush:Brush.t -> ?color:Color.t -> ?pen:Pen.t -> ?dashed:Dash.t -> t -> Command.t
Draw a path
- parameter brush
the brush used to draw the path; the next argument redefined this one
- parameter color
the color of the path; default is black
- parameter pen
the pen used to draw the path; default is
Brush.Pen.default
- parameter dashed
if given, the path is drawn using that dash_style.