1
/* Copyright (C) 2001-2006 Artifex Software, Inc.
4
This software is provided AS-IS with no warranty, either express or
7
This software is distributed under license and may not be copied, modified
8
or distributed except as expressly authorized under the terms of that
9
license. Refer to licensing information at http://www.artifex.com/
10
or contact Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134,
11
San Rafael, CA 94903, U.S.A., +1(415)492-9861, for further information.
14
/* $Id: zpath.c 8250 2007-09-25 13:31:24Z giles $ */
15
/* Basic path operators */
24
/* Forward references */
25
static int common_to(i_ctx_t *,
26
int (*)(gs_state *, floatp, floatp));
27
static int common_curve(i_ctx_t *,
28
int (*)(gs_state *, floatp, floatp, floatp, floatp, floatp, floatp));
32
znewpath(i_ctx_t *i_ctx_p)
34
return gs_newpath(igs);
37
/* - currentpoint <x> <y> */
39
zcurrentpoint(i_ctx_t *i_ctx_p)
43
int code = gs_currentpoint(igs, &pt);
48
make_real(op - 1, pt.x);
53
/* <x> <y> moveto - */
55
zmoveto(i_ctx_t *i_ctx_p)
57
return common_to(i_ctx_p, gs_moveto);
60
/* <dx> <dy> rmoveto - */
62
zrmoveto(i_ctx_t *i_ctx_p)
64
return common_to(i_ctx_p, gs_rmoveto);
67
/* <x> <y> lineto - */
69
zlineto(i_ctx_t *i_ctx_p)
71
return common_to(i_ctx_p, gs_lineto);
74
/* <dx> <dy> rlineto - */
76
zrlineto(i_ctx_t *i_ctx_p)
78
return common_to(i_ctx_p, gs_rlineto);
81
/* Common code for [r](move/line)to */
83
common_to(i_ctx_t *i_ctx_p,
84
int (*add_proc)(gs_state *, floatp, floatp))
90
if ((code = num_params(op, 2, opxy)) < 0 ||
91
(code = (*add_proc)(igs, opxy[0], opxy[1])) < 0
98
/* <x1> <y1> <x2> <y2> <x3> <y3> curveto - */
100
zcurveto(i_ctx_t *i_ctx_p)
102
return common_curve(i_ctx_p, gs_curveto);
105
/* <dx1> <dy1> <dx2> <dy2> <dx3> <dy3> rcurveto - */
107
zrcurveto(i_ctx_t *i_ctx_p)
109
return common_curve(i_ctx_p, gs_rcurveto);
112
/* Common code for [r]curveto */
114
common_curve(i_ctx_t *i_ctx_p,
115
int (*add_proc)(gs_state *, floatp, floatp, floatp, floatp, floatp, floatp))
121
if ((code = num_params(op, 6, opxy)) < 0)
123
code = (*add_proc)(igs, opxy[0], opxy[1], opxy[2], opxy[3], opxy[4], opxy[5]);
131
zclosepath(i_ctx_t *i_ctx_p)
133
return gs_closepath(igs);
138
zinitclip(i_ctx_t *i_ctx_p)
140
return gs_initclip(igs);
145
zclip(i_ctx_t *i_ctx_p)
152
zeoclip(i_ctx_t *i_ctx_p)
154
return gs_eoclip(igs);
157
/* ------ Initialization procedure ------ */
159
const op_def zpath_op_defs[] =
162
{"0closepath", zclosepath},
163
{"0currentpoint", zcurrentpoint},
164
{"6curveto", zcurveto},
165
{"0eoclip", zeoclip},
166
{"0initclip", zinitclip},
167
{"2lineto", zlineto},
168
{"2moveto", zmoveto},
169
{"0newpath", znewpath},
170
{"6rcurveto", zrcurveto},
171
{"2rlineto", zrlineto},
172
{"2rmoveto", zrmoveto},