File: g_box.c

package info (click to toggle)
plotutils 2.0-2
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 5,964 kB
  • ctags: 2,522
  • sloc: ansic: 38,416; sh: 1,853; yacc: 856; makefile: 181; lex: 144
file content (40 lines) | stat: -rw-r--r-- 880 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* This file contains the box method, which is a standard part of libplot.
   It draws an object: an upright rectangle with diagonal corners x0,y0 and
   x1,y1.

   In this generic version, we simply call fmove() and fcont() repeatedly,
   to draw the box. */

#include "sys-defines.h"
#include "plot.h"
#include "extern.h"

int
#ifdef _HAVE_PROTOS
_g_fbox (double x0, double y0, double x1, double y1)
#else
_g_fbox (x0, y0, x1, y1)
     double x0, y0, x1, y1;
#endif
{
  double xnew, ynew;

  if (!_plotter->open)
    {
      _plotter->error ("fbox: invalid operation");
      return -1;
    }

  _plotter->fmove (x0, y0);
  _plotter->fcont (x0, y1);
  _plotter->fcont (x1, y1);
  _plotter->fcont (x1, y0);
  _plotter->fcont (x0, y0);

  /* move to center (libplot convention) */
  xnew = 0.5 * (x0 + x1);
  ynew = 0.5 * (y0 + y1);
  _plotter->fmove (xnew, ynew);

  return 0;
}