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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
/***********************************************************************/
/* */
/* Objective Caml */
/* */
/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
/* */
/* Copyright 1996 Institut National de Recherche en Informatique et */
/* en Automatique. All rights reserved. This file is distributed */
/* under the terms of the GNU Library General Public License. */
/* */
/***********************************************************************/
/* $Id$ */
#include "libgraph.h"
#include <alloc.h>
value gr_plot(value vx, value vy)
{
int x = Int_val(vx);
int y = Int_val(vy);
gr_check_open();
XDrawPoint(grdisplay, grwindow.win, grwindow.gc, x, Wcvt(y));
XDrawPoint(grdisplay, grbstore.win, grbstore.gc, x, Bcvt(y));
XFlush(grdisplay);
return Val_unit;
}
value gr_moveto(value vx, value vy)
{
grx = Int_val(vx);
gry = Int_val(vy);
return Val_unit;
}
value gr_current_point(void)
{
value res;
res = alloc_small(2, 0);
Field(res, 0) = Val_int(grx);
Field(res, 1) = Val_int(gry);
return res;
}
value gr_lineto(value vx, value vy)
{
int x = Int_val(vx);
int y = Int_val(vy);
gr_check_open();
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;
}
value gr_draw_arc_nat(value vx, value vy, value vrx, value vry, value va1, value va2)
{
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);
gr_check_open();
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;
}
value gr_draw_arc(value *argv, int argc)
{
return gr_draw_arc_nat(argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]);
}
value gr_set_line_width(value vwidth)
{
int width = Int_val(vwidth);
gr_check_open();
XSetLineAttributes(grdisplay, grwindow.gc,
width, LineSolid, CapRound, JoinRound);
XSetLineAttributes(grdisplay, grbstore.gc,
width, LineSolid, CapRound, JoinRound);
return Val_unit;
}
|