-
Notifications
You must be signed in to change notification settings - Fork 0
/
graphics.c
122 lines (103 loc) · 2.43 KB
/
graphics.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
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
#include <stdio.h>
#include "graphics.h"
void drawLine(int x1, int x2, int x3, int x4)
{
printf("DL %i %i %i %i\n", x1, x2, x3, x4);
}
void drawRect(int x1, int x2, int x3, int x4)
{
printf("DR %i %i %i %i\n", x1, x2, x3, x4);
}
void fillRect(int x1, int x2, int x3, int x4)
{
printf("FR %i %i %i %i\n", x1, x2, x3, x4);
}
void drawOval(int x, int y, int width, int height)
{
printf("DO %i %i %i %i\n",x,y,width,height);
}
void fillOval(int x, int y, int width, int height)
{
printf("FO %i %i %i %i\n",x,y,width,height);
}
void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle)
{
printf("DA %i %i %i %i %i %i\n",x,y,width,height, startAngle, arcAngle);
}
void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle)
{
printf("FA %i %i %i %i %i %i\n",x,y,width,height, startAngle, arcAngle);
}
void drawPolygon(int count, int x[], int y[])
{
printf("DP ");
printf("%d ", count);
for (int n = 0 ; n < count ; n++)
{
printf("%d %d ", x[n], y[n]);
}
printf("\n");
}
void fillPolygon(int count, int x[], int y[])
{
printf("FP ");
printf("%d ", count);
for (int n = 0 ; n < count ; n++)
{
printf("%d %d ", x[n], y[n]);
}
printf("\n");
}
void drawString(char* s, int x, int y)
{
printf("DS %i %i @%s\n",x,y,s);
}
void displayImage(char* fileName, int x, int y)
{
printf("DI %i %i @%s\n", x, y, fileName );
}
void setColour(colour c)
{
char* colourName;
switch(c)
{
case black : colourName = "black"; break;
case blue : colourName = "blue"; break;
case cyan : colourName = "cyan"; break;
case darkgray : colourName = "darkgray"; break;
case gray : colourName = "gray"; break;
case green : colourName = "green"; break;
case lightgray : colourName = "lightgray"; break;
case magenta : colourName = "magenta"; break;
case orange : colourName = "orange"; break;
case pink : colourName = "pink"; break;
case red : colourName = "red"; break;
case white : colourName = "white"; break;
case yellow : colourName = "yellow"; break;
}
printf("SC %s\n", colourName);
}
void setRGBColour(int red, int green, int blue)
{
printf("RG %i %i %i\n", red, green, blue);
}
void clear(void)
{
printf("CL\n");
}
void setWindowSize(int width, int height)
{
printf("SW %i %i\n", width, height);
}
void sleep(int time)
{
printf("SL %i\n", time);
}
void foreground(void)
{
printf("FG\n");
}
void background(void)
{
printf("BG\n");
}