-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
168 lines (168 loc) · 3.84 KB
/
main.cpp
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
#include "head.h"
int Modes = -1;
int Save = 0;
double width = 1;
/*分配堆空间,并将所有绘图信息保存于堆空间中*/
extern Draw_Modes* RMake = (Draw_Modes*)malloc(MAX * sizeof(Draw_Modes));
bool Undo_Or_Not = false;
int main()
{
initgraph(1536, 864, INIT_NOBORDER | INIT_RENDERMANUAL);
ege_enable_aa(true);
bool Funopen = false;
do
{
Funopen = FunOpen();
} while (Funopen == false);
setcolor(EGEACOLOR(0xFF,BLACK));
setfillcolor(EGEACOLOR(0xFF, BLACK));
setbkcolor(WHITE);
cleardevice();
/*初始化各个图标与全局变量*/
PIMAGE Option = newimage();
getimage(Option, TEXT("JPG"), MAKEINTRESOURCE(IMAGEOPTION));
putimage(0, 0, Option);
delimage(Option);
PIMAGE NewOption = newimage();
getimage(NewOption, TEXT("JPG"), MAKEINTRESOURCE(NEWOPTION));
PIMAGE Draw_Line = newimage();
getimage(Draw_Line, TEXT("JPG"), MAKEINTRESOURCE(DRAW_LINE));
PIMAGE Draw_Circle = newimage();
getimage(Draw_Circle, TEXT("JPG"), MAKEINTRESOURCE(DRAW_CIRCLE));
PIMAGE Draw_Pixel = newimage();
getimage(Draw_Pixel, TEXT("JPG"), MAKEINTRESOURCE(DRAW_PIXEL));
if (FileName[250] != 1)
ReadFromFile(FileName);
setcolor(EGEACOLOR(0xFF, BLACK));
setfillcolor(EGEACOLOR(0xFF, BLACK));
setbkcolor(WHITE);
flushmouse();
for (;is_run();delay_fps(FPS))
{
mouse_msg m = getmouse();
/*若鼠标在绘图区域,则进入绘图模式*/
if (m.y > (2 * BlockY))
{
m = StartDraw(m);
}
else
{
if (m.x < BlockDrawStart && m.is_left() && m.is_down())
{
if (m.y < BlockY)
{
if (m.x < BlockOption)
{
exit(1);
}
if (m.x < (2 * BlockOption))
{
Undo();
continue;
}
if (m.x < (3 * BlockOption))
{
/*清屏,并将清屏信息进行保存*/
ClearDevice();
Draw_Undo_Init();
Draw_Redo_Init(0);
RMake[Save - 1].Mode = CLEAR;
continue;
}
if (m.x < (4 * BlockOption))
{
/*设置当前绘图线宽*/
char buf[4] = {};
inputbox_getline("设置线宽", "请输入线宽", buf, 4);
width = atof(buf);
setlinewidth(float(width));
}
}
else
{
if (m.x < BlockOption)
{
SaveFile();
continue;
}
if (m.x < (2 * BlockOption))
{
Redo();
continue;
}
if (m.x < 3 * BlockOption)
{
Modes = MOUSE;
continue;
}
if (m.x < 4 * BlockOption)
{
flushmouse();
for (;is_run();delay_fps(FPS))
{
/*选取绘图区域的图形并保存*/
mouse_msg mou = getmouse();
if (mou.is_left() && mou.is_down())
{
/*若为绘图区域,则保存颜色并设置,否则直接退出*/
if (mou.y > 200)
{
setcolor(EGEACOLOR(0XFF, getpixel(mou.x, mou.y)));
setfillcolor(EGEACOLOR(0XFF, getpixel(mou.x, mou.y)));
break;
}
else
break;
}
}
continue;
}
}
}
else if (m.x < BlockColorStart)
{
if (m.is_down())
{
if (m.y < BlockY)
{
if (m.x < (BlockDrawStart + BlockDraw))
{
Modes = PIXEL;
putimage(BlockDrawStart, 0, NewOption);
putimage(BlockDrawStart, 0, Draw_Pixel);
continue;
}
if (m.x < (BlockDrawStart + 2 * BlockDraw))
{
Modes = CIRCLE;
putimage(BlockDrawStart, 0, NewOption);
putimage((BlockDrawStart + BlockDraw), 0, Draw_Circle);
continue;
}
}
else
{
if (m.x < (BlockDrawStart + BlockDraw))
{
Modes = LINE;
putimage(BlockDrawStart, 0, NewOption);
putimage(BlockDrawStart, 100, Draw_Line);
continue;
}
if (m.x < (BlockDrawStart + 2 * BlockDraw))
{
Modes = Homework_Polygon;
Draw_Homework_Polygon();
}
}
}
}
else if (m.is_down())
{
/*进入颜色设置模式*/
SetColor(m);
continue;
}
}
}
}