module P:`sig`

..`end`

Paths.

Consult their semantics.

The composition operator `Vg.(>>)`

is used to build paths from
the empty path. For this reason path combinators always take the
path to use as the last argument.

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 : ` |
`(*` |
Outline width.
| `*)` |

` ` |
`cap : ` |
`(*` |
Shape at the end points of open subpaths
and dashes.
| `*)` |

` ` |
`join : ` |
`(*` |
Shape at segment jointures.
| `*)` |

` ` |
`miter_angle : ` |
`(*` |
Limit
angle for miter joins
(in [0;pi]). | `*)` |

` ` |
`dashes : ` |
`(*` |
Outline dashes.
| `*)` |

The type for path outline area specifications.
Semantics.

`val o : ``outline`

`o`

holds a default set of values. `width`

is `1.`

,
`cap`

is ``Butt`

, `join`

is ``Miter`

, `miter_angle`

is
`11.5`

degrees in radians and `dashes`

is `None`

.`val pp_outline : ``Format.formatter -> outline -> unit`

`pp_outline ppf o`

prints a textual representation of `o`

on `ppf`

.type`area =`

`[ `Aeo | `Anz | `O of outline ]`

The type for path area specifications.
Semantics.

`val pp_area : ``Format.formatter -> area -> unit`

`pp_area ppf a`

prints a textual representation of `a`

on `ppf`

type`t =`

`Vg.path`

The type for paths.

`val empty : ``Vg.path`

`empty`

is the empty path.
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 `Vg.P.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 -> Vg.path -> Vg.path`

`sub pt p`

is `p`

with a new subpath starting at `pt`

. If `p`

's last
subpath had no segment it is automatically `Vg.P.close`

d.`val line : ``?rel:bool -> Gg.p2 -> Vg.path -> Vg.path`

`line pt p`

is `p`

with a straight line from `p`

's last point to `pt`

.`val qcurve : ``?rel:bool -> Gg.p2 -> Gg.p2 -> Vg.path -> Vg.path`

`qcurve c pt p`

is `p`

with a quadratic bézier curve from
`p`

's last point to `pt`

with control point `c`

.`val ccurve : ``?rel:bool -> Gg.p2 -> Gg.p2 -> Gg.p2 -> Vg.path -> Vg.path`

`ccurve c c' pt p`

is `p`

with a cubic bézier curve from `p`

's
last point to `pt`

with control points `c`

and `c'`

.`val earc : ``?rel:bool ->`

?large:bool ->

?cw:bool -> ?angle:float -> Gg.size2 -> Gg.p2 -> Vg.path -> Vg.path

`earc large cw a r pt p`

is `p`

with an elliptical arc from
`p`

's last point to `pt`

. The ellipse is defined by the
horizontal and vertical radii `r`

which are rotated by `a`

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 and `cw`

if the arc is to be traversed in the
clockwise direction (both default to `false`

). 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 : ``Vg.path -> Vg.path`

`close p`

is `p`

with a straight line from `p`

's last point to
`p`

's current subpath starting point, this ends the subpath.
The following convenience functions start and close a new subpath
to the given path.

`val circle : ``?rel:bool -> Gg.p2 -> float -> Vg.path -> Vg.path`

`circle c r p`

is `p`

with a circle subpath of center `c`

and radius `r`

.`val ellipse : ``?rel:bool -> ?angle:float -> Gg.p2 -> Gg.size2 -> Vg.path -> Vg.path`

`ellipse c r p`

is `p`

with an axis-aligned (unless `angle`

is specified)
ellipse subpath of center `c`

and radii `r`

.`val rect : ``?rel:bool -> Gg.box2 -> Vg.path -> Vg.path`

`rect r p`

is `p`

with an axis-aligned rectangle subpath
`r`

. If `r`

is empty, `p`

is returned.`val rrect : ``?rel:bool -> Gg.box2 -> Gg.size2 -> Vg.path -> Vg.path`

`rrect r cr p`

is `p`

with an axis-aligned rectangle subpath
`r`

with round corners of radii `cr`

. If `r`

is empty, `p`

is returned.`val last_pt : ``Vg.path -> Gg.p2`

`last_pt p`

is the last point of `p`

's last subpath.`Invalid_argument`

if `p`

is `empty`

.`val append : ``Vg.path -> Vg.path -> Vg.path`

`append p' p`

appends `p'`

to `p`

. If `p`

's last subpath had no
segment it is closed.
**Warning.** To accomodate `Vg.(>>)`

the argument order is the opposite of
`List.append`

.

`val tr : ``Gg.m3 -> Vg.path -> Vg.path`

`tr m p`

is the affine transform in homogenous 2D space of the path
`p`

by `m`

.
**Bug.** Elliptical arcs transformation is currently broken if
`m`

doesn't scale uniformely or shears.

type`fold =`

`[ `Ccurve of Gg.p2 * Gg.p2 * Gg.p2`

| `Close

| `Earc of bool * bool * float * Gg.size2 * Gg.p2

| `Line of Gg.p2

| `Qcurve of Gg.p2 * Gg.p2

| `Sub of Gg.p2 ]

The type for path folds.

`val fold : ``?rev:bool -> ('a -> fold -> 'a) -> 'a -> Vg.path -> 'a`

`fold ~rev f acc p`

, applies `f`

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. If `rev`

is `true`

(defaults to `false`

) the segments
and subpaths are traversed in reverse order.`val is_empty : ``Vg.path -> bool`

`is_empty p`

is `true`

iff `p`

is `empty`

.`val equal : ``Vg.path -> Vg.path -> bool`

`equal p p'`

is `p = p'`

.`val equal_f : ``(float -> float -> bool) -> Vg.path -> Vg.path -> bool`

`val compare : ``Vg.path -> Vg.path -> int`

`compare p p'`

is `Pervasives.compare`

` p p'`

.`val compare_f : ``(float -> float -> int) -> Vg.path -> Vg.path -> int`

`val to_string : ``Vg.path -> string`

`to_string p`

is a textual representation of `p`

.`val pp : ``Format.formatter -> Vg.path -> unit`

`pp ppf p`

prints a textual representation of `p`

on `ppf`

.`val pp_f : ``(Format.formatter -> float -> unit) -> Format.formatter -> Vg.path -> unit`