Module Vg.P
Paths.
Consult their semantics.
The |>
operator is used to build paths from the empty path. For this reason path combinators always take the path to use as the last argument.
Path areas
type cap
=[
|
`Butt
|
`Round
|
`Square
]
The type for path caps. Semantics.
type join
=[
|
`Bevel
|
`Miter
|
`Round
]
The type for segment jointures. Semantics.
type dashes
= float * float list
The type for dashes. Semantics.
type outline
=
{
width : float;
Outline width.
cap : cap;
Shape at the end points of open subpaths and dashes.
join : join;
Shape at segment jointures.
miter_angle : float;
Limit angle for miter joins (in [0;pi]).
dashes : dashes option;
Outline dashes.
}
The type for path outline area specifications. Semantics.
val o : outline
o
holds a default set of values.width
is1.
,cap
is`Butt
,join
is`Miter
,miter_angle
is11.5
degrees in radians anddashes
isNone
.
val pp_outline : Stdlib.Format.formatter -> outline -> unit
pp_outline ppf o
prints a textual representation ofo
onppf
.
val pp_area : Stdlib.Format.formatter -> area -> unit
pp_area ppf a
prints a textual representation ofa
onppf
Paths
type t
= path
The type for paths.
val empty : path
empty
is the empty path.
Subpaths and segments
If a path segment is directly added to a path p
which is empty
or whose last subpath is closed, a new subpath is automatically started with sub
P2.o p
.
In the functions below the default value of the optional argument rel
is false
. If true
, the points given to the function are expressed relative to the last point of the path or Gg
.P2.o if the path is empty
.
val sub : ?rel:bool -> Gg.p2 -> path -> path
sub pt p
isp
with a new subpath starting atpt
. Ifp
's last subpath had no segment it is automaticallyclose
d.
val line : ?rel:bool -> Gg.p2 -> path -> path
line pt p
isp
with a straight line fromp
's last point topt
.
val qcurve : ?rel:bool -> Gg.p2 -> Gg.p2 -> path -> path
qcurve c pt p
isp
with a quadratic bézier curve fromp
's last point topt
with control pointc
.
val ccurve : ?rel:bool -> Gg.p2 -> Gg.p2 -> Gg.p2 -> path -> path
ccurve c c' pt p
isp
with a cubic bézier curve fromp
's last point topt
with control pointsc
andc'
.
val earc : ?rel:bool -> ?large:bool -> ?cw:bool -> ?angle:float -> Gg.size2 -> Gg.p2 -> path -> path
earc large cw a r pt p
isp
with an elliptical arc fromp
's last point topt
. The ellipse is defined by the horizontal and vertical radiir
which are rotated bya
with respect to the current coordinate system. If the parameters do not define a valid ellipse (points coincident or too far apart, zero radius) the arc collapses to a line.In general the parameters define four possible arcs, thus
large
indicates if more than pi radians of the arc is to be traversed andcw
if the arc is to be traversed in the clockwise direction (both default tofalse
). In the following image, in red, the elliptical arc from the left point to the right one. The top row is~large:false
and the left column is~cw:false
:
val close : path -> path
close p
isp
with a straight line fromp
's last point top
's current subpath starting point, this ends the subpath.
Derived subpaths
The following convenience functions start and close a new subpath to the given path.
val circle : ?rel:bool -> Gg.p2 -> float -> path -> path
circle c r p
isp
with a circle subpath of centerc
and radiusr
.
val ellipse : ?rel:bool -> ?angle:float -> Gg.p2 -> Gg.size2 -> path -> path
ellipse c r p
isp
with an axis-aligned (unlessangle
is specified) ellipse subpath of centerc
and radiir
.
Functions
val last_pt : path -> Gg.p2
last_pt p
is the last point ofp
's last subpath.- raises Invalid_argument
if
p
isempty
.
Traversal
type fold
=[
]
The type for path folds.
val fold : ?rev:bool -> ('a -> fold -> 'a) -> 'a -> path -> 'a
fold ~rev f acc p
, appliesf
to each subpath and subpath segments with an accumulator. Subpaths are traversed in the order they were specified, always start with a`Sub
, but may not be`Close
d. Ifrev
istrue
(defaults tofalse
) the segments and subpaths are traversed in reverse order.
Predicates and comparisons
val is_empty : path -> bool
is_empty p
istrue
iffp
isempty
.
Printers
val to_string : path -> string
to_string p
is a textual representation ofp
.
val pp : Stdlib.Format.formatter -> path -> unit
pp ppf p
prints a textual representation ofp
onppf
.