1995-08-09 08:06:35 -07:00
|
|
|
/***********************************************************************/
|
|
|
|
/* */
|
1996-04-30 07:53:58 -07:00
|
|
|
/* Objective Caml */
|
1995-08-09 08:06:35 -07:00
|
|
|
/* */
|
|
|
|
/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
|
|
|
|
/* */
|
1996-04-30 07:53:58 -07:00
|
|
|
/* Copyright 1996 Institut National de Recherche en Informatique et */
|
1995-08-09 08:06:35 -07:00
|
|
|
/* Automatique. Distributed only by permission. */
|
|
|
|
/* */
|
|
|
|
/***********************************************************************/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
1995-05-08 10:04:35 -07:00
|
|
|
#include "libgraph.h"
|
|
|
|
#include <alloc.h>
|
|
|
|
|
1997-09-02 05:55:01 -07:00
|
|
|
value gr_plot(value vx, value vy)
|
1995-05-08 10:04:35 -07:00
|
|
|
{
|
|
|
|
int x = Int_val(vx);
|
|
|
|
int y = Int_val(vy);
|
1997-03-08 04:17:35 -08:00
|
|
|
gr_check_open();
|
1995-05-08 10:04:35 -07:00
|
|
|
XDrawPoint(grdisplay, grwindow.win, grwindow.gc, x, Wcvt(y));
|
|
|
|
XDrawPoint(grdisplay, grbstore.win, grbstore.gc, x, Bcvt(y));
|
|
|
|
XFlush(grdisplay);
|
|
|
|
return Val_unit;
|
|
|
|
}
|
|
|
|
|
1997-09-02 05:55:01 -07:00
|
|
|
value gr_moveto(value vx, value vy)
|
1995-05-08 10:04:35 -07:00
|
|
|
{
|
|
|
|
grx = Int_val(vx);
|
|
|
|
gry = Int_val(vy);
|
|
|
|
return Val_unit;
|
|
|
|
}
|
|
|
|
|
1997-09-02 05:55:01 -07:00
|
|
|
value gr_current_point(void)
|
1995-05-08 10:04:35 -07:00
|
|
|
{
|
|
|
|
value res;
|
|
|
|
res = alloc_tuple(2);
|
|
|
|
Field(res, 0) = Val_int(grx);
|
|
|
|
Field(res, 1) = Val_int(gry);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
1997-09-02 05:55:01 -07:00
|
|
|
value gr_lineto(value vx, value vy)
|
1995-05-08 10:04:35 -07:00
|
|
|
{
|
|
|
|
int x = Int_val(vx);
|
|
|
|
int y = Int_val(vy);
|
1997-03-08 04:17:35 -08:00
|
|
|
gr_check_open();
|
1995-05-08 10:04:35 -07:00
|
|
|
XDrawLine(grdisplay, grwindow.win, grwindow.gc,
|
|
|
|
grx, Wcvt(gry), x, Wcvt(y));
|
|
|
|
XDrawLine(grdisplay, grbstore.win, grbstore.gc,
|
|
|
|
grx, Bcvt(gry), x, Bcvt(y));
|
|
|
|
grx = x;
|
|
|
|
gry = y;
|
|
|
|
XFlush(grdisplay);
|
|
|
|
return Val_unit;
|
|
|
|
}
|
|
|
|
|
1997-09-02 05:55:01 -07:00
|
|
|
value gr_draw_arc_nat(value vx, value vy, value vrx, value vry, value va1, value va2)
|
1995-05-08 10:04:35 -07:00
|
|
|
{
|
1995-11-06 05:28:02 -08:00
|
|
|
int x = Int_val(vx);
|
|
|
|
int y = Int_val(vy);
|
|
|
|
int rx = Int_val(vrx);
|
|
|
|
int ry = Int_val(vry);
|
|
|
|
int a1 = Int_val(va1);
|
|
|
|
int a2 = Int_val(va2);
|
|
|
|
|
1997-03-08 04:17:35 -08:00
|
|
|
gr_check_open();
|
1995-05-08 10:04:35 -07:00
|
|
|
XDrawArc(grdisplay, grwindow.win, grwindow.gc,
|
|
|
|
x - rx, Wcvt(y) - ry, rx * 2, ry * 2, a1 * 64, (a2 - a1) * 64);
|
|
|
|
XDrawArc(grdisplay, grbstore.win, grbstore.gc,
|
|
|
|
x - rx, Bcvt(y) - ry, rx * 2, ry * 2, a1 * 64, (a2 - a1) * 64);
|
|
|
|
XFlush(grdisplay);
|
|
|
|
return Val_unit;
|
|
|
|
}
|
|
|
|
|
1997-09-02 05:55:01 -07:00
|
|
|
value gr_draw_arc(value *argv, int argc)
|
1995-11-06 05:28:02 -08:00
|
|
|
{
|
|
|
|
return gr_draw_arc_nat(argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]);
|
|
|
|
}
|
|
|
|
|
1997-09-02 05:55:01 -07:00
|
|
|
value gr_set_line_width(value vwidth)
|
1995-05-08 10:04:35 -07:00
|
|
|
{
|
|
|
|
int width = Int_val(vwidth);
|
1997-03-08 04:17:35 -08:00
|
|
|
gr_check_open();
|
1995-05-08 10:04:35 -07:00
|
|
|
XSetLineAttributes(grdisplay, grwindow.gc,
|
|
|
|
width, LineSolid, CapRound, JoinRound);
|
|
|
|
XSetLineAttributes(grdisplay, grbstore.gc,
|
|
|
|
width, LineSolid, CapRound, JoinRound);
|
|
|
|
return Val_unit;
|
|
|
|
}
|
|
|
|
|