-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_changeAt.cpp
More file actions
94 lines (73 loc) · 2.67 KB
/
test_changeAt.cpp
File metadata and controls
94 lines (73 loc) · 2.67 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
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
//
// Created by Hà Tường Nguyên on 5/28/24.
//
#include "test_changeAt.h"
namespace testcase {
void all_change_at() {
change_at0();
change_at1();
change_at2();
change_at3();
}
void change_at0(int w, int h) {
std::cout << color::YELLOW << "testcase::change_at 0" << color::RESET << std::endl;
graphic::Screen scr(w, h);
int width, height;
scr.shape(width, height);
for (int y = 0; y < height; ++y) {
for (int x = 0; x < width; ++x) {
scr.changeAt(255 - x, 255 - 2 * x - y, 255 - y, x, y);
}
}
std::cout << "------------------" << std::endl;
std::cout << scr;
std::cout << "------------------" << std::endl;
}
void change_at1(int w, int h) {
std::cout << color::YELLOW << "testcase::change_at 1" << color::RESET << std::endl;
graphic::Screen scr(w, h);
int width, height;
scr.shape(width, height);
for (int y = 0; y < height; ++y) {
for (int x = 0; x < width; ++x) {
uint8_t red = (255 * x) / (scr.getWidth() - 1);
uint8_t green = (255 * y) / (scr.getHeight() - 1);
uint8_t blue = (255 * (x + y)) / (scr.getWidth() + scr.getHeight() - 2);
scr.changeAt(red, green, blue, x, y);
}
}
std::cout << "------------------" << std::endl;
std::cout << scr;
std::cout << "------------------" << std::endl;
}
void change_at2(int w, int h) {
std::cout << color::YELLOW << "testcase::change_at 2" << color::RESET << std::endl;
graphic::Screen scr(w, h);
int width, height;
scr.shape(width, height);
int x = width - 1;
for (int y = 0; y < height; ++y) {
scr.changeAt(255, 0, 255, x--, y);
scr.changeAt(255, 255, 0, x, y);
scr.changeAt(0, 255, 255, --x, y);
}
std::cout << "------------------" << std::endl;
std::cout << scr;
std::cout << "------------------" << std::endl;
}
void change_at3(int w, int h) {
std::cout << color::YELLOW << "testcase::change_at 3" << color::RESET << std::endl;
graphic::Screen scr(w, h);
std::string move_cursor = cursor::preline(h);
std::cout << "------------------" << std::endl;
for (int i = h - 1; i > -1; --i) {
for (int j = w - 1; j > -1; --j) {
std::cout << scr;
std::cout << move_cursor;
scr.changeAt(200 - j, 200 - i, 255 - (i + j), j, i);
}
}
std::cout << "\033[0K";
std::cout << scr;
}
}