forked from igal/bertrand
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgraphicsnull.c
52 lines (45 loc) · 1.18 KB
/
graphicsnull.c
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
/*********************************************************
*
* Null graphics routines.
*
* If you do not have the capabilities for graphics output
* you can use these routines to supply null stubs.
*
*********************************************************/
#include "def.h"
/* this variable is set to true when the graphics device has been opened */
int graphics = FALSE;
/* open graphics device */
void
graphics_init()
{
printf("null graphics device is open\n");
graphics = TRUE;
}
/* Assume numbers in Bertrand are in inches */
/* If other units are desired, simply use a different constant */
#define INCHES 100 /* resolution of the screen, in pixels per inch */
/* draw a line between two points */
void
draw_line(x1,y1,x2,y2)
double x1, y1, x2, y2;
{
if (!graphics) graphics_init();
printf("draw line from (%g,%g) to (%g,%g)\n", x1, y1, x2, y2);
}
/* paint a string, centered at a certain location */
void
draw_string(str,x,y)
char *str;
double x,y;
{
if (!graphics) graphics_init();
printf("draw string \"%s\" at (%g,%g)\n", str, x, y);
}
/* close the graphics device, only called if graphics == TRUE */
void
graphics_close()
{
printf("close graphics device\n");
graphics = FALSE;
}