module Path:sig..end
Fixed Paths
Paths are the objects used to describe lines, curves, and more generally almost everything that is drawn with Mlpost
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 directionval vec : Point.t -> direction
val curl : float -> direction
val noDir : 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 -> knotBuild a knot from a point; the optional arguments are the incoming directions. Warning they are going in the same direction.
val knotlist : (direction * Point.t * direction) list ->
knot list
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 pointsval 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 paths
In all the functions below :
val knot : ?l:direction ->
?r:direction ->
?scale:(float -> Num.t) -> float * float -> knotBuild a knot from a pair of floats
l : an incoming directionr : an outgoing directionscale : a scaling factor applied to the floatsval knotn : ?l:direction ->
?r:direction -> Num.t * Num.t -> knotBuild a knot from a Num.t pair; the optional arguments are as in
Path.knot
val path : ?style:joint ->
?cycle:joint ->
?scale:(float -> Num.t) -> (float * float) list -> tBuild a path from a list of pairs of floats
style : the joint style used for all joints in the pathcycle : if given, the path is closed using the given stylescale : permits to scale the whole pathval pathn : ?style:joint ->
?cycle:joint ->
(Num.t * Num.t) list -> tSame as path, but uses a Num.t list
val pathk : ?style:joint ->
?cycle:joint -> knot list -> tSame as path, but uses a knot list
val pathp : ?style:joint ->
?cycle:joint -> Point.t list -> tSame as path but uses a point list
val jointpathk : knot list -> joint list -> tBuild a path from n knots and n-1 joints
val jointpathp : Point.t list -> joint list -> tBuild a path 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 -> tBuild a path from n float_pairs and n-1 joints,
with default directions
val cycle : ?dir:direction ->
?style:joint -> t -> tClose a path using direction dir and style style
val concat : ?style:joint ->
t -> knot -> tAdd a knot at the end of a path
val start : knot -> tCreate a simple path with one knot
val append : ?style:joint -> t -> t -> tAppend a path to another using joint style
val length : t -> Num.tNumber of nodes in a path, minus one.
val point : float -> t -> Point.tpoint 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.
val pointn : Num.t -> t -> Point.tSame as point but for a Num.t.
val direction : float -> t -> Point.tdirection f p returns the direction of the tangent at point f p.
val directionn : Num.t -> t -> Point.tSame as direction but for a Num.t.
val subpath : float -> float -> t -> tsubpath start end path selects the subpath of path that lies
between start and end. start and end are given in
control points, as in Path.point.
val subpathn : Num.t -> Num.t -> t -> tSame as subpathn but using Num.t.
val transform : Transform.t -> t -> tApply 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 -> tShortcuts for transformations of Paths
val cut_after : t -> t -> tcut_after p1 p2 cuts p2 after the intersection with p1.
To memorize the order of the arguments,
you can read: "cut after p1"
val cut_before : t -> t -> tSame as Path.cut_after, but cuts before
val strip : Num.t -> t -> tstrip n p removes two segments of length n at each end of path p
val build_cycle : t list -> tBuild a cycle from a set of intersecting paths
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
typemetapath =MetaPath.t
Compute the control point of the path for a good looking result according to the constraint on the direction, tension, curve
val of_metapath : metapath -> t
val to_metapath : t -> metapathObtain a metapath from a path with exactly the same control point. p = of_metapath (of_path p) is true but not the opposite.
type orientation =
| |
Up |
| |
Down |
| |
Left |
| |
Right |
| |
Upn of |
| |
Downn of |
| |
Leftn of |
| |
Rightn of |
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.tDraw a path
brush : the brush used to draw the path; the next argument
redefined this onecolor : the color of the path; default is blackpen : the pen used to draw the path; default is
Brush.Pen.defaultdashed : if given, the path is drawn using that dash_style.val fill : ?color:Color.t -> t -> Command.tFill a contour given by a closed path
color : the color used to fill the area; default is black