Module Mlpost.Path
Fixed Paths
type directionA
directionis used to put constraints on paths:vec pdefines a direction by a point (interpreted as a vector)curl fchanges the curling factor of the extremity of a path; higher curling factor means flatter curvesnoDirmeans no particular direction
type knotA
knotis 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 -> knotBuild a knot from a point; the optional arguments are the incoming directions. Warning they are going in the same direction.
type jointA joint is the connection between two knots in a path. It is either
jLinefor a straight linejCurvefor a spline curvejCurveNoInflexto avoid inflexion pointsjTension f1 f2to specify "tension" on the joint;jCurveuses a default tension of 1. Higher tension means less "wild" curvesjControls p1 p2to explicitely specify control points
val jLine : jointval jCurve : jointval jCurveNoInflex : jointval jTension : float -> float -> jointval jControls : Point.t -> Point.t -> joint
Labelled path constructors
val knot : ?l:direction -> ?r:direction -> ?scale:(float -> Num.t) -> (float * float) -> knotBuild 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) -> knotBuild 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 -> tBuild 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 -> tSame as
path, but uses aNum.tlist
val jointpathp : Point.t list -> joint list -> tBuild a path from
npoints andn-1joints, with default directions
Primitive path constructors
More complex constructions on paths
val point : float -> t -> Point.tpoint f preturns a certain point on the pathp;fis 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.tdirection f preturns the direction of the tangent atpoint f p.
val subpath : float -> float -> t -> tsubpath start end pathselects the subpath ofpaththat lies betweenstartandend.startandendare given in control points, as inpoint.
val transform : Transform.t -> t -> tApply a transformation to a path
val scale : Num.t -> t -> tval rotate : float -> t -> tval shift : Point.t -> t -> tval yscale : Num.t -> t -> tval xscale : Num.t -> t -> tShortcuts for transformations of Paths
Predefined values
val defaultjoint : jointThe default joint style (
JCurve)
val fullcircle : tA full circle of radius 1 and centered on the origin
val halfcircle : tThe upper half of
fullcircle
val quartercircle : tThe right half of
halfcircle
val unitsquare : tA full square of size 1 and centered on the origin
Conversions
type metapath= MetaPath.tCompute 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 -> tval draw : ?brush:Brush.t -> ?color:Color.t -> ?pen:Pen.t -> ?dashed:Dash.t -> t -> Command.tDraw 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.