Creation

A reference to a new empty path can be created using fz_new_path:


\begin{lstlisting}
/*
fz_new_path: Create an empty path, and return
a referenc...
... failure to allocate.
*/
fz_path *fz_new_path(fz_context *ctx);
\end{lstlisting}

Once a path exists, commands can be added to it. The first command must always be a `move'.


\begin{lstlisting}
/*
fz_moveto: Append a 'moveto' command to a path.
\par
path...
...id fz_moveto(fz_context *ctx, fz_path *path, float x, float y);
\end{lstlisting}

Once we have moved to a point, subsequent commands can be added, such as lines, quads (quadratic beziers) and curves (cubic beziers).


\begin{lstlisting}
/*
fz_lineto: Append a 'lineto' command to a path.
\par
path...
...h, float x0, float y0, float x1, float y1, float x2, float y2);
\end{lstlisting}

In addition, we have 2 functions for adding curves (cubic beziers) where one of the control points is coincident with the neighbouring endpoints. These functions mirror the usage in PDF, but offer no benefits other than convenience as such curves are detected automatically as part of an fz_curveto call.


\begin{lstlisting}
/*
fz_curvetov: Append a 'curvetov' command to a path. (For ...
...t *ctx, fz_path *path, float x0, float y0, float x2, float y2);
\end{lstlisting}

At any point after the initial move, we can close the path using fz_closepath:


\begin{lstlisting}
/*
fz_closepath: Close the current subpath.
\par
path: The p...
...h closes.
*/
void fz_closepath(fz_context *ctx, fz_path *path);
\end{lstlisting}

After a path has been closed, the only acceptable next command is a move. A path need not be closed before a second or subsequent move is sent.

For details of exactly what each of these path segment types means, see “The PDF Reference Manual” or “The Postscript Language Reference Manual”.

Finally, we have one additional path construction function, fz_rectto. This appends a rectangle to the current path. This rectangle is equivalent to a move, 3 lines and a closepath, and so is the one exception to the rule that paths must begin with a move (as one is implicit within the rectangle command).


\begin{lstlisting}
/*
fz_rectto: Append a 'rectto' command to a path.
\par
The ...
...t *ctx, fz_path *path, float x0, float y0, float x1, float y1);
\end{lstlisting}

Finally, during path construction, the coordinate at which the notional path cursor has reached can be read using the fz_currentpoint function.


\begin{lstlisting}
/*
fz_currentpoint: Return the current point that a path has...
...f.
*/
fz_point fz_currentpoint(fz_context *ctx, fz_path *path);
\end{lstlisting}