forked from ccfd/courses_graphics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwinbgi2.h
341 lines (292 loc) · 8.49 KB
/
winbgi2.h
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
//
// graphics.h -- One of the files required to run BGI graphics programs
//
// You don't need to edit this file, or print it out.
#ifndef __GRAPHICS2_H__
#define __GRAPHICS2_H__
#define _CRT_SECURE_NO_WARNINGS
#define far
#define huge
#define random(range) (rand() % (range))
enum colors {
BLACK, BLUE, GREEN, CYAN, RED, MAGENT, BROWN, LIGHTGRAY, DARKGRAY,
LIGHTBLUE, LIGHTGREEN, LIGHTCYAN, LIGHTRED, LIGHTMAGENTA, YELLOW, WHITE
};
enum write_modes {
COPY_PUT, XOR_PUT, OR_PUT, AND_PUT, NOT_PUT
};
enum line_styles {
SOLID_LINE, DOTTED_LINE, CENTER_LINE, DASHED_LINE, USERBIT_LINE
};
enum fill_styles {
EMPTY_FILL, SOLID_FILL, LINE_FILL, LTSLASH_FILL, SLASH_FILL, BKSLASH_FILL,
LTBKSLASH_FILL, HATCH_FILL, XHATCH_FILL, INTERLEAVE_FILL, WIDE_DOT_FILL,
CLOSE_DOT_FILL, USER_FILL
};
enum text_directions {
HORIZ_DIR, VERT_DIR
};
enum font_types {
DEFAULT_FONT, TRIPLEX_FONT, SMALL_FONT, SANSSERIF_FONT, GOTHIC_FONT
};
#define LEFT_TEXT 0
#define CENTER_TEXT 1
#define RIGHT_TEXT 2
#define BOTTOM_TEXT 0
#define TOP_TEXT 2
#define NORM_WIDTH 1
#define THICK_WIDTH 3
#define DOTTEDLINE_LENGTH 2
#define CENTRELINE_LENGTH 4
#define USER_CHAR_SIZE 0
#define MAXCOLORS 63
#define CLIP_ON 1
#define CLIP_OFF 0
#define TOP_ON 1
#define TOP_OFF 0
#define LEFT_BUTTON 0
#define RIGHT_BUTTON 1
enum graphics_errors {
grOk = 0,
grNoInitGraph = -1,
grNotDetected = -2,
grFileNotFound = -3,
grInvalidDriver = -4,
grNoLoadMem = -5,
grNoScanMem = -6,
grNoFloodMem = -7,
grFontNotFound = -8,
grNoFontMem = -9,
grInvalidMode = -10,
grError = -11,
grIOerror = -12,
grInvalidFont = -13,
grInvalidFontNum = -14,
grInvalidDeviceNum = -15,
grInvalidVersion = -18
};
/* Graphics drivers constants, includes X11 which is particular to XBGI. */
#define DETECT 0
#define CGA 1
#define MCGA 2
#define EGA 3
#define EGA64 4
#define EGAMONO 5
#define IBM8514 6
#define HERCMONO 7
#define ATT400 8
#define VGA 9
#define PC3270 10
/* Graphics modes constants. */
#define CGAC0 0
#define CGAC1 1
#define CGAC2 2
#define CGAC3 3
#define CGAHI 4
#define MCGAC0 0
#define MCGAC1 1
#define MCGAC2 2
#define MCGAC3 3
#define MCGAMED 4
#define MCGAHI 5
#define EGALO 0
#define EGAHI 1
#define EGA64LO 0
#define EGA64HI 1
#define EGAMONOHI 3
#define HERCMONOHI 0
#define ATT400C0 0
#define ATT400C1 1
#define ATT400C2 2
#define ATT400C3 3
#define ATT400MED 4
#define ATT400HI 5
#define VGALO 0
#define VGAMED 1
#define VGAHI 2
#define VGAMAX 3
#define PC3270HI 0
#define IBM8514LO 0
#define IBM8514HI 1
typedef struct arccoordstype {
int x;
int y;
int xstart;
int ystart;
int xend;
int yend;
} arccoordstype;
typedef char fillpatterntype[8];
typedef struct fillsettingstype {
int pattern;
int color;
} fillsettingstype;
typedef struct linesettingstype {
int linestyle;
unsigned int upattern;
int thickness;
} linesettingstype;
typedef struct palettetype {
unsigned char size;
signed char colors[64];
} palettetype;
typedef struct textsettingstype {
int font;
int direction;
int charsize;
int horiz;
int vert;
} textsettingstype;
typedef struct viewporttype {
int left;
int top;
int right;
int bottom;
int clip;
} viewporttype;
#ifndef NOT_USE_PROTOTYPES
#define PROTO(ARGS) ARGS
#else
#define PROTO(ARGS) ()
#endif
#if defined(__cplusplus)
extern "C" {
#endif
//
// Setting this variable to 0 increase speed of drawing but
// correct redraw is not possible. By default this variable is initialized by 1
//
extern int bgiemu_handle_redraw;
//
// Default mode choosed by WinBGI if DETECT value is specified for
// device parameter of initgraoh(). Default value is VGAMAX which
// cause creation of maximized window (resolution depends on display mode)
//
extern int bgiemu_default_mode;
void _graphfreemem PROTO((void *ptr, unsigned int size));
void* _graphgetmem PROTO((unsigned int size));
void arc PROTO((int, int, int, int, int));
void bar PROTO((int, int, int, int));
void bar3d PROTO((int, int, int, int, int, int));
void circle PROTO((double, double, int));
void circle_s PROTO((double, double, double, double));
void cleardevice PROTO((void));
void clearviewport PROTO((void));
void closegraph PROTO((void));
void detectgraph PROTO((int *, int *));
void drawpoly PROTO((int, int *));
void ellipse PROTO((int, int, int, int, int, int));
void fillellipse PROTO((int, int, int, int));
void fillpoly PROTO((int, int *));
void floodfill PROTO((int, int, int));
void getarccoords PROTO((arccoordstype *));
void getaspectratio PROTO((int *, int *));
int getbkcolor PROTO((void));
int getcolor PROTO((void));
palettetype* getdefaultpalette PROTO((void));
char* getdrivername PROTO((void));
void getfillpattern PROTO((char const *));
void getfillsettings PROTO((fillsettingstype *));
int getgraphmode PROTO((void));
void getimage PROTO((int, int, int, int, void *));
void getlinesettings PROTO((linesettingstype *));
int getmaxcolor PROTO((void));
int getmaxmode PROTO((void));
int getmaxx PROTO((void));
int getmaxy PROTO((void));
char* getmodename PROTO((int));
void getmoderange PROTO((int, int *, int *));
void getpalette PROTO((palettetype *));
int getpalettesize PROTO((void));
unsigned int getpixel PROTO((int, int));
void gettextsettings PROTO((textsettingstype *));
void getviewsettings PROTO((viewporttype *));
int getx PROTO((void));
int gety PROTO((void));
void graphdefaults PROTO((void));
char* grapherrormsg PROTO((int));
int graphresult PROTO((void));
unsigned int imagesize PROTO((int, int, int, int));
void initgraph PROTO((int *, int *, char const *,int , int));
int installuserdriver PROTO((char const *, int *));
int installuserfont PROTO((char const *));
void line PROTO((double, double, double, double));
void linerel PROTO((int, int));
void lineto_old PROTO((int, int));
void moverel PROTO((int, int));
void moveto PROTO((int, int));
void outtext PROTO((char const *));
void outtextxy PROTO((int, int, char const *));
void pieslice PROTO((int, int, int, int, int));
void putimage PROTO((int, int, void *, int));
void putpixel PROTO((int, int, int));
void point PROTO((double, double));
void rectangle PROTO((int, int, int, int));
int registerbgidriver PROTO((void *));
int registerbgifont PROTO((void *));
void restorecrtmode PROTO((void));
void sector PROTO((int, int, int, int, int, int));
void setactivepage PROTO((int));
void setallpalette PROTO((palettetype *));
void setaspectratio PROTO((int, int));
void setbkcolor PROTO((int));
void setcolor PROTO((double));
void setgray PROTO((double));
void setfillpattern PROTO((char const *, int));
void setfillstyle PROTO((int, int));
unsigned int setgraphbufsize PROTO((unsigned int));
void setgraphmode PROTO((int));
void setlinestyle PROTO((int, unsigned int, int));
void setpalette PROTO((int, int));
void setrgbpalette PROTO((int, int, int, int));
void settextjustify PROTO((int, int));
void settextstyle PROTO((int, int, int));
void setusercharsize PROTO((int, int, int, int));
void setviewport PROTO((int, int, int, int, int));
void setvisualpage PROTO((int));
void setwritemode PROTO((int));
int textheight PROTO((char const *));
int textwidth PROTO((char const *));
int getch PROTO((void));
int kbhit PROTO((void));
void delay PROTO((unsigned msec));
void restorecrtmode PROTO((void));
bool mouseup();
bool mousedown();
void clearmouse();
int mouseclickx();
int mouseclicky();
int mousecurrentx();
int mousecurrenty();
int whichmousebutton();
int getkey();
/* ---------------- DODATKI --------------- */
inline void graphics(int sx, int sy)
{
int GraphDriver=0,GraphMode=0;
initgraph( &GraphDriver, &GraphMode, "", sx, sy ); // otwarcie okna grafiki
setviewport(0, 0, sx, sy, 0); // zmiana obszaru rysowania
}
inline int clear() {
clearviewport();
return 0;
}
void startdelay(unsigned msec);
void stopdelay();
int animate(int fps);
inline int wait() {
while (animate(-1));
return 0;
}
void scale (double, double, double, double);
void log_scale (double, double, double, double);
void title PROTO((char *, char *, char *));
void chart PROTO((double * x, double * y, int n, char * xlab, char * ylab, char * main_title));
void lineto(double x0, double y0);
void reset();
void polygon(double x[], double y[], int n);
/* ---------------------------------------- */
#if defined(__cplusplus)
};
#endif
#endif