-
Notifications
You must be signed in to change notification settings - Fork 5
/
graphics.h
127 lines (108 loc) · 2.62 KB
/
graphics.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
#ifndef GRAPHICS_H
#define GRAPHICS_H
enum SHAPE_TYPE {
Rectangle, Triangle, Quad, Ellipse, Polygon, PolygonOutline,
ThickPolygonOutline, Lines, ThickLines, Star, VGAPlane, Palette, None, EndCommandList
};
enum STAR_SIZE {
BigStar, TinyStar, MediumStar
};
class RGBCOLOR{
public:
unsigned char r,g,b;
RGBCOLOR(){
r=255;
g=0;
b=255;
}
RGBCOLOR(unsigned char r,unsigned char g,unsigned char b){
this->r=r;
this->g=g;
this->b=b;
}
};
int operator==(const RGBCOLOR &a, const RGBCOLOR &b);
class Point2D {
public:
int x,y;
Point2D (){
x=y=0;
}
Point2D (int x, int y){
this->x = x;
this->y = y;
}
};
class GraphicsCommand{
public:
SHAPE_TYPE shape;
Point2D points[4];
RGBCOLOR color;
int * point_list;
int point_count;
unsigned char * bitmap_plane;
GraphicsCommand(){
shape=None;
}
GraphicsCommand(SHAPE_TYPE shape){
this->shape = shape;
}
GraphicsCommand(SHAPE_TYPE shape,Point2D p1, Point2D p2, RGBCOLOR color){
this->shape=shape;
this->points[0]=p1;
this->points[1]=p2;
this->color=color;
}
GraphicsCommand(SHAPE_TYPE shape,Point2D p1, Point2D p2, Point2D p3, RGBCOLOR color){
this->shape=shape;
this->points[0]=p1;
this->points[1]=p2;
this->points[2]=p3;
this->color=color;
}
GraphicsCommand(SHAPE_TYPE shape,Point2D p1, Point2D p2, Point2D p3, Point2D p4, RGBCOLOR color){
this->shape=shape;
this->points[0]=p1;
this->points[1]=p2;
this->points[2]=p3;
this->points[3]=p4;
this->color=color;
}
// Variant specifically for ellipses, which smuggle xradius/yradius in the second point
GraphicsCommand(SHAPE_TYPE shape,Point2D p1, int x, int y, RGBCOLOR color){
this->shape=shape;
this->points[0]=p1;
this->points[1]=Point2D(x,y);
this->color=color;
this->point_list=NULL;
}
GraphicsCommand(SHAPE_TYPE shape,int far *pointlist, RGBCOLOR color);
GraphicsCommand(SHAPE_TYPE shape,Point2D p1, int size, RGBCOLOR color){
this->shape=shape;
this->points[0]=p1;
this->points[1]=Point2D(size,size);
this->color=color;
}
GraphicsCommand(SHAPE_TYPE shape, unsigned char *bitmap_plane, int plane){
this->shape=shape;
this->bitmap_plane = bitmap_plane;
this->points[0]=Point2D(plane,plane);
}
GraphicsCommand(SHAPE_TYPE shape, int palette_index, RGBCOLOR color){
this->shape=shape;
this->points[0]=Point2D(palette_index, palette_index);
this->color = color;
}
void render();
private:
void drawLines(int thickness);
};
#define MAX_COMMANDS 128
int operator==(const RGBCOLOR &a, const RGBCOLOR &b);
RGBCOLOR RGB(int r, int g, int b);
Point2D Point(int x, int y);
Point2D Left(int y);
Point2D Right(int y);
Point2D Top(int x);
Point2D Bottom(int x);
#endif