-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction.Display.h
More file actions
48 lines (40 loc) · 1.37 KB
/
function.Display.h
File metadata and controls
48 lines (40 loc) · 1.37 KB
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
//-----------------------------------------------declaration------------------------------------------------------------------//
// functions for displaying
void goToXY(int x, int y);
void textColor(int color);
void fontSize(int x, int y);
void wait(clock_t time);
//----------------------------------------------------------------------------------------------------------------------------//
// move cusor to column x row y
void goToXY(int x, int y){
COORD coordinate = {x, y};
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coordinate);
}
// change text color
void textColor(int color){
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color);
}
// change font size
void fontSize(int x, int y){
CONSOLE_FONT_INFOEX info = {0};
info.cbSize = sizeof(info);
info.dwFontSize.X = x;
info.dwFontSize.Y = y;
info.FontWeight = FW_NORMAL;
wcscpy(info.FaceName, L"Consolas");
SetCurrentConsoleFontEx(GetStdHandle(STD_OUTPUT_HANDLE), TRUE, &info);
}
// set console screen size
void setConsoleSize(int width, int height){
RECT r;
GetWindowRect(GetConsoleWindow(), &r);
MoveWindow(GetConsoleWindow(), r.left, r.top, width, height, TRUE);
COORD coordinates = {120, 30};
SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), coordinates);
}
// wait for time/1000 seconds
void wait(clock_t time){
clock_t goal;
goal = time + clock();
while(goal > clock()) {}
}