]>
git.ipfire.org Git - thirdparty/cups.git/blob - filter/hpgl-polygon.c
2 * "$Id: hpgl-polygon.c,v 1.9.2.3 2003/01/07 18:26:52 mike Exp $"
4 * HP-GL/2 polygon routines for the Common UNIX Printing System (CUPS).
6 * Copyright 1993-2003 by Easy Software Products.
8 * These coded instructions, statements, and computer programs are the
9 * property of Easy Software Products and are protected by Federal
10 * copyright law. Distribution and use rights are outlined in the file
11 * "LICENSE.txt" which should have been included with this file. If this
12 * file is missing or damaged please contact Easy Software Products
15 * Attn: CUPS Licensing Information
16 * Easy Software Products
17 * 44141 Airport View Drive, Suite 204
18 * Hollywood, Maryland 20636-3111 USA
20 * Voice: (301) 373-9603
21 * EMail: cups-info@cups.org
22 * WWW: http://www.cups.org
24 * This file is subject to the Apple OS-Developed Software exception.
28 * EA_edge_rect_absolute() - Draw a rectangle.
29 * EP_edge_polygon() - Stroke the edges of a polygon.
30 * ER_edge_rect_relative() - Draw a rectangle relative to the current
31 * EW_edge_wedge() - Draw a pie wedge.
32 * FP_fill_polygon() - Fill a polygon.
33 * PM_polygon_mode() - Set the polygon drawing mode.
34 * RA_fill_rect_absolute() - Fill a rectangle.
35 * RR_fill_rect_relative() - Fill a rectangle relative to the current
36 * WG_fill_wedge() - Fill a pie wedge.
40 * Include necessary headers...
47 * 'EA_edge_rect_absolute()' - Draw a rectangle.
51 EA_edge_rect_absolute(int num_params
, /* I - Number of parameters */
52 param_t
*params
) /* I - Parameters */
54 float x
, y
; /* Transformed coordinates */
60 x
= Transform
[0][0] * params
[0].value
.number
+
61 Transform
[0][1] * params
[1].value
.number
+
63 y
= Transform
[1][0] * params
[0].value
.number
+
64 Transform
[1][1] * params
[1].value
.number
+
70 Outputf("%.3f %.3f MO\n", PenPosition
[0], PenPosition
[1]);
71 Outputf("%.3f %.3f LI\n", PenPosition
[0], y
);
72 Outputf("%.3f %.3f LI\n", x
, y
);
73 Outputf("%.3f %.3f LI\n", x
, PenPosition
[1]);
82 * 'EP_edge_polygon()' - Stroke the edges of a polygon.
86 EP_edge_polygon(int num_params
, /* I - Number of parameters */
87 param_t
*params
) /* I - Parameters */
97 * 'ER_edge_rect_relative()' - Draw a rectangle relative to the current
102 ER_edge_rect_relative(int num_params
, /* I - Number of parameters */
103 param_t
*params
) /* I - Parameters */
105 float x
, y
; /* Transformed coordinates */
111 x
= Transform
[0][0] * params
[0].value
.number
+
112 Transform
[0][1] * params
[1].value
.number
+
114 y
= Transform
[1][0] * params
[0].value
.number
+
115 Transform
[1][1] * params
[1].value
.number
+
121 Outputf("%.3f %.3f MO\n", PenPosition
[0], PenPosition
[1]);
122 Outputf("%.3f %.3f LI\n", PenPosition
[0], y
);
123 Outputf("%.3f %.3f LI\n", x
, y
);
124 Outputf("%.3f %.3f LI\n", x
, PenPosition
[1]);
133 * 'EW_edge_wedge()' - Draw a pie wedge.
137 EW_edge_wedge(int num_params
, /* I - Number of parameters */
138 param_t
*params
) /* I - Parameters */
140 float x
, y
; /* Transformed coordinates */
141 float start
, end
, /* Start and end of arc */
142 theta
, /* Current angle */
143 dt
, /* Step between points */
144 radius
; /* Radius of arc */
150 radius
= params
[0].value
.number
;
151 start
= params
[1].value
.number
;
152 end
= start
+ params
[2].value
.number
;
155 dt
= (float)fabs(params
[3].value
.number
);
162 Outputf("%.3f %.3f MO\n", PenPosition
[0], PenPosition
[1]);
165 for (theta
= start
+ dt
; theta
< end
; theta
+= dt
)
167 x
= (float)(PenPosition
[0] +
168 radius
* cos(M_PI
* theta
/ 180.0) * Transform
[0][0] +
169 radius
* sin(M_PI
* theta
/ 180.0) * Transform
[0][1]);
170 y
= (float)(PenPosition
[1] +
171 radius
* cos(M_PI
* theta
/ 180.0) * Transform
[1][0] +
172 radius
* sin(M_PI
* theta
/ 180.0) * Transform
[1][1]);
174 Outputf("%.3f %.3f LI\n", x
, y
);
177 for (theta
= start
- dt
; theta
> end
; theta
-= dt
)
179 x
= (float)(PenPosition
[0] +
180 radius
* cos(M_PI
* theta
/ 180.0) * Transform
[0][0] +
181 radius
* sin(M_PI
* theta
/ 180.0) * Transform
[0][1]);
182 y
= (float)(PenPosition
[1] +
183 radius
* cos(M_PI
* theta
/ 180.0) * Transform
[1][0] +
184 radius
* sin(M_PI
* theta
/ 180.0) * Transform
[1][1]);
186 Outputf("%.3f %.3f LI\n", x
, y
);
189 x
= (float)(PenPosition
[0] +
190 radius
* cos(M_PI
* end
/ 180.0) * Transform
[0][0] +
191 radius
* sin(M_PI
* end
/ 180.0) * Transform
[0][1]);
192 y
= (float)(PenPosition
[1] +
193 radius
* cos(M_PI
* end
/ 180.0) * Transform
[1][0] +
194 radius
* sin(M_PI
* end
/ 180.0) * Transform
[1][1]);
195 Outputf("%.3f %.3f LI\n", x
, y
);
204 * 'FP_fill_polygon()' - Fill a polygon.
208 FP_fill_polygon(int num_params
, /* I - Number of parameters */
209 param_t
*params
) /* I - Parameters */
219 * 'PM_polygon_mode()' - Set the polygon drawing mode.
223 PM_polygon_mode(int num_params
, /* I - Number of parameters */
224 param_t
*params
) /* I - Parameters */
226 if (num_params
== 0 ||
227 params
[0].value
.number
== 0)
230 Outputf("%.3f %.3f MO\n", PenPosition
[0], PenPosition
[1]);
233 else if (params
[0].value
.number
== 2)
239 * 'RA_fill_rect_absolute()' - Fill a rectangle.
243 RA_fill_rect_absolute(int num_params
, /* I - Number of parameters */
244 param_t
*params
) /* I - Parameters */
246 float x
, y
; /* Transformed coordinates */
252 x
= Transform
[0][0] * params
[0].value
.number
+
253 Transform
[0][1] * params
[1].value
.number
+
255 y
= Transform
[1][0] * params
[0].value
.number
+
256 Transform
[1][1] * params
[1].value
.number
+
262 Outputf("%.3f %.3f MO\n", PenPosition
[0], PenPosition
[1]);
263 Outputf("%.3f %.3f LI\n", PenPosition
[0], y
);
264 Outputf("%.3f %.3f LI\n", x
, y
);
265 Outputf("%.3f %.3f LI\n", x
, PenPosition
[1]);
274 * 'RR_fill_rect_relative()' - Fill a rectangle relative to the current
279 RR_fill_rect_relative(int num_params
, /* I - Number of parameters */
280 param_t
*params
) /* I - Parameters */
282 float x
, y
; /* Transformed coordinates */
288 x
= Transform
[0][0] * params
[0].value
.number
+
289 Transform
[0][1] * params
[1].value
.number
+
291 y
= Transform
[1][0] * params
[0].value
.number
+
292 Transform
[1][1] * params
[1].value
.number
+
298 Outputf("%.3f %.3f MO\n", PenPosition
[0], PenPosition
[1]);
299 Outputf("%.3f %.3f LI\n", PenPosition
[0], y
);
300 Outputf("%.3f %.3f LI\n", x
, y
);
301 Outputf("%.3f %.3f LI\n", x
, PenPosition
[1]);
310 * 'WG_fill_wedge()' - Fill a pie wedge.
314 WG_fill_wedge(int num_params
, /* I - Number of parameters */
315 param_t
*params
) /* I - Parameters */
317 float x
, y
; /* Transformed coordinates */
318 float start
, end
, /* Start and end angles */
319 theta
, /* Current angle */
320 dt
, /* Step between points */
321 radius
; /* Radius of arc */
327 radius
= params
[0].value
.number
;
328 start
= params
[1].value
.number
;
329 end
= start
+ params
[2].value
.number
;
332 dt
= (float)fabs(params
[3].value
.number
);
339 Outputf("%.3f %.3f MO\n", PenPosition
[0], PenPosition
[1]);
342 for (theta
= start
+ dt
; theta
< end
; theta
+= dt
)
344 x
= (float)(PenPosition
[0] +
345 radius
* cos(M_PI
* theta
/ 180.0) * Transform
[0][0] +
346 radius
* sin(M_PI
* theta
/ 180.0) * Transform
[0][1]);
347 y
= (float)(PenPosition
[1] +
348 radius
* cos(M_PI
* theta
/ 180.0) * Transform
[1][0] +
349 radius
* sin(M_PI
* theta
/ 180.0) * Transform
[1][1]);
351 Outputf("%.3f %.3f LI\n", x
, y
);
354 for (theta
= start
- dt
; theta
> end
; theta
-= dt
)
356 x
= (float)(PenPosition
[0] +
357 radius
* cos(M_PI
* theta
/ 180.0) * Transform
[0][0] +
358 radius
* sin(M_PI
* theta
/ 180.0) * Transform
[0][1]);
359 y
= (float)(PenPosition
[1] +
360 radius
* cos(M_PI
* theta
/ 180.0) * Transform
[1][0] +
361 radius
* sin(M_PI
* theta
/ 180.0) * Transform
[1][1]);
363 Outputf("%.3f %.3f LI\n", x
, y
);
366 x
= (float)(PenPosition
[0] +
367 radius
* cos(M_PI
* end
/ 180.0) * Transform
[0][0] +
368 radius
* sin(M_PI
* end
/ 180.0) * Transform
[0][1]);
369 y
= (float)(PenPosition
[1] +
370 radius
* cos(M_PI
* end
/ 180.0) * Transform
[1][0] +
371 radius
* sin(M_PI
* end
/ 180.0) * Transform
[1][1]);
372 Outputf("%.3f %.3f LI\n", x
, y
);
381 * End of "$Id: hpgl-polygon.c,v 1.9.2.3 2003/01/07 18:26:52 mike Exp $".