~ubuntu-branches/ubuntu/jaunty/plotutils/jaunty

« back to all changes in this revision

Viewing changes to libplot/g_range.c

  • Committer: Bazaar Package Importer
  • Author(s): Floris Bruynooghe
  • Date: 2007-05-10 19:48:54 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070510194854-mrr3lgwzpxd8hovo
Tags: 2.5-2
Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of the GNU plotutils package.  Copyright (C) 1995,
 
2
   1996, 1997, 1998, 1999, 2000, 2005, Free Software Foundation, Inc.
 
3
 
 
4
   The GNU plotutils package is free software.  You may redistribute it
 
5
   and/or modify it under the terms of the GNU General Public License as
 
6
   published by the Free Software foundation; either version 2, or (at your
 
7
   option) any later version.
 
8
 
 
9
   The GNU plotutils package is distributed in the hope that it will be
 
10
   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
   General Public License for more details.
 
13
 
 
14
   You should have received a copy of the GNU General Public License along
 
15
   with the GNU plotutils package; see the file COPYING.  If not, write to
 
16
   the Free Software Foundation, Inc., 51 Franklin St., Fifth Floor,
 
17
   Boston, MA 02110-1301, USA. */
 
18
 
1
19
/* This file contains functions that update the bounding box information
2
20
   for a page whenever a new object (ellipse, line segment, or Bezier
3
21
   segment) is plotted.  Updating takes the line width into account, more
20
38
   by one-half of the line width.  This approximation is good unless the
21
39
   line width is large. */
22
40
void
23
 
#ifdef _HAVE_PROTOS
24
41
_set_ellipse_bbox (plOutbuf *bufp, double x, double y, double rx, double ry, double costheta, double sintheta, double linewidth, double m[6])
25
 
#else
26
 
_set_ellipse_bbox (bufp, x, y, rx, ry, costheta, sintheta, linewidth, m)
27
 
     plOutbuf *bufp;
28
 
     double x, y;
29
 
     double rx, ry;
30
 
     double costheta, sintheta;
31
 
     double linewidth;
32
 
     double m[6];
33
 
#endif
34
42
{
35
43
  double ux, uy, vx, vy;
36
44
  double mixing_angle;
101
109
 
102
110
/* update bounding box due to drawing of a line end (args are in user coors) */
103
111
void
104
 
#ifdef _HAVE_PROTOS
105
112
_set_line_end_bbox (plOutbuf *bufp, double x, double y, double xother, double yother, double linewidth, int capstyle, double m[6])
106
 
#else
107
 
_set_line_end_bbox (bufp, x, y, xother, yother, linewidth, capstyle, m)
108
 
     plOutbuf *bufp;
109
 
     double x, y, xother, yother, linewidth;
110
 
     int capstyle;
111
 
     double m[6];
112
 
#endif
113
113
{
114
114
  plVector v, vrot;
115
115
  double xs, ys;
117
117
 
118
118
  switch (capstyle)
119
119
    {
120
 
    case CAP_BUTT:
 
120
    case PL_CAP_BUTT:
121
121
    default:
122
122
      vrot.x = yother - y;
123
123
      vrot.y = x - xother;
129
129
      ys = y - vrot.y;
130
130
      _update_bbox (bufp, XD_INTERNAL(xs,ys,m), YD_INTERNAL(xs,ys,m));
131
131
      break;
132
 
    case CAP_PROJECT:
 
132
    case PL_CAP_PROJECT:
133
133
      v.x = xother - x;
134
134
      v.y = yother - y;
135
135
      _vscale (&v, halfwidth);
143
143
      ys = y - v.y - vrot.y;
144
144
      _update_bbox (bufp, XD_INTERNAL(xs,ys,m), YD_INTERNAL(xs,ys,m));
145
145
      break;
146
 
    case CAP_ROUND:
 
146
    case PL_CAP_ROUND:
147
147
      _set_ellipse_bbox (bufp, x, y, halfwidth, halfwidth, 1.0, 0.0, 0.0, m);
148
148
      break;
149
 
    case CAP_TRIANGULAR:
 
149
    case PL_CAP_TRIANGULAR:
150
150
      /* add projecting vertex */
151
151
      v.x = xother - x;
152
152
      v.y = yother - y;
170
170
 
171
171
/* update bounding box due to drawing of a line join (args are in user coors)*/
172
172
void
173
 
#ifdef _HAVE_PROTOS
174
173
_set_line_join_bbox (plOutbuf *bufp, double xleft, double yleft, double x, double y, double xright, double yright, double linewidth, int joinstyle, double miterlimit, double m[6])
175
 
#else
176
 
_set_line_join_bbox (bufp, xleft, yleft, x, y, xright, yright, linewidth, joinstyle, miterlimit, m)
177
 
     plOutbuf *bufp;
178
 
     double xleft, yleft, x, y, xright, yright, linewidth;
179
 
     int joinstyle;
180
 
     double miterlimit;
181
 
     double m[6];
182
 
#endif
183
174
{
184
175
  plVector v1, v2, vsum;
185
176
  double v1len, v2len;
188
179
 
189
180
  switch (joinstyle)
190
181
    {
191
 
    case JOIN_MITER:
 
182
    case PL_JOIN_MITER:
192
183
    default:
193
184
      v1.x = xleft - x;
194
185
      v1.y = yleft - y;
211
202
              || (cosphi > (1.0 - 2.0 / (miterlimit * miterlimit))))
212
203
            /* bevel rather than miter */
213
204
            {
214
 
              _set_line_end_bbox (bufp, x, y, xleft, yleft, linewidth, CAP_BUTT, m);
215
 
              _set_line_end_bbox (bufp,x, y, xright, yright, linewidth, CAP_BUTT, m);
 
205
              _set_line_end_bbox (bufp, x, y, xleft, yleft, linewidth, PL_CAP_BUTT, m);
 
206
              _set_line_end_bbox (bufp,x, y, xright, yright, linewidth, PL_CAP_BUTT, m);
216
207
            }
217
208
          else
218
209
            {
226
217
            }
227
218
        }
228
219
      break;
229
 
    case JOIN_TRIANGULAR:
 
220
    case PL_JOIN_TRIANGULAR:
230
221
      /* add a miter vertex, and same vertices as when bevelling */
231
222
      vsum.x = v1.x + v2.x;
232
223
      vsum.y = v1.y + v2.y;
235
226
      y -= vsum.y;
236
227
      _update_bbox (bufp, XD_INTERNAL(x,y,m), YD_INTERNAL(x,y,m));
237
228
      /* fall through */
238
 
    case JOIN_BEVEL:
239
 
      _set_line_end_bbox (bufp, x, y, xleft, yleft, linewidth, CAP_BUTT, m);
240
 
      _set_line_end_bbox (bufp, x, y, xright, yright, linewidth, CAP_BUTT, m);
 
229
    case PL_JOIN_BEVEL:
 
230
      _set_line_end_bbox (bufp, x, y, xleft, yleft, linewidth, PL_CAP_BUTT, m);
 
231
      _set_line_end_bbox (bufp, x, y, xright, yright, linewidth, PL_CAP_BUTT, m);
241
232
      break;
242
 
    case JOIN_ROUND:
 
233
    case PL_JOIN_ROUND:
243
234
      halfwidth = 0.5 * linewidth;
244
235
      _set_ellipse_bbox (bufp, x, y, halfwidth, halfwidth, 1.0, 0.0, 0.0, m);
245
236
      break;
257
248
#define QUAD_COOR(t,x0,x1,x2) (((x0)-2*(x1)+(x2))*t*t + 2*((x1)-(x2))*t + (x2))
258
249
 
259
250
void
260
 
#ifdef _HAVE_PROTOS
261
251
_set_bezier2_bbox (plOutbuf *bufp, double x0, double y0, double x1, double y1, double x2, double y2, double device_line_width, double m[6])
262
 
#else
263
 
_set_bezier2_bbox (bufp, x0, y0, x1, y1, x2, y2, device_line_width, m)
264
 
     plOutbuf *bufp;
265
 
     double x0, y0, x1, y1, x2, y2;
266
 
     double device_line_width;
267
 
     double m[6];
268
 
#endif
269
252
{
270
253
  double a_x, b_x, t_x;
271
254
  double a_y, b_y, t_y;  
316
299
#define CUBIC_COOR(t,x0,x1,x2,x3) (((x0)-3*(x1)+3*(x2)-(x3))*t*t*t + 3*((x1)-2*(x2)+(x3))*t*t + 3*((x2)-(x3))*t + (x3))
317
300
 
318
301
void
319
 
#ifdef _HAVE_PROTOS
320
302
_set_bezier3_bbox (plOutbuf *bufp, double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3, double device_line_width, double m[6])
321
 
#else
322
 
_set_bezier3_bbox (bufp, x0, y0, x1, y1, x2, y2, x3, y3, device_line_width, m)
323
 
     plOutbuf *bufp;
324
 
     double x0, y0, x1, y1, x2, y2, x3, y3;
325
 
     double device_line_width;
326
 
     double m[6];
327
 
#endif
328
303
{
329
304
  double a_x, b_x, c_x, s_x, t_x;
330
305
  double a_y, b_y, c_y, s_y, t_y;