Rev 7147 | Rev 7150 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7147 | Rev 7148 | ||
---|---|---|---|
1 | struct _colors |
1 | struct _colors |
2 | { |
2 | { |
3 | int x,y; |
3 | int x,y,w,h; |
4 | unsigned rows, columns; |
4 | unsigned rows, columns; |
5 | unsigned cell_size; |
5 | unsigned cell_size; |
6 | dword mas[MAX_COLORS*MAX_COLORS]; |
6 | dword mas[MAX_COLORS*MAX_COLORS]; |
7 | dword image; |
7 | dword image; |
8 | void set_default_values(); |
8 | void set_default_values(); |
9 | void set_color(); |
9 | void set_color(); |
10 | dword get_color(); |
10 | dword get_color(); |
11 | dword get_image(); |
11 | dword get_image(); |
12 | void draw_cell(); |
12 | void draw_cell(); |
13 | void draw_all_cells(); |
13 | void draw_all_cells(); |
14 | void move(); |
14 | void move(); |
15 | } colors; |
15 | } colors; |
16 | 16 | ||
17 | void _colors::set_default_values() |
17 | void _colors::set_default_values() |
18 | { |
18 | { |
19 | columns = 2; |
- | |
20 | rows = 2; |
19 | int i; |
21 | cell_size = 20; |
- | |
22 | 20 | ||
- | 21 | columns = MAX_COLORS; |
|
- | 22 | rows = MAX_COLORS; |
|
23 | set_color(0,0, 0x66b2ff); |
23 | cell_size = 5; |
- | 24 | w = columns * cell_size; |
|
24 | set_color(0,1, 0x000066); |
- | |
25 | 25 | h = rows * cell_size; |
|
26 | set_color(1,0, 0x000066); |
26 | |
27 | set_color(1,1, 0x66b2ff); |
27 | for (i = 0; i < columns*rows; i++) mas[i]=0xBFCAD2; |
28 | } |
28 | } |
29 | 29 | ||
30 | void _colors::set_color(int _r, _c, _color) |
30 | void _colors::set_color(int _r, _c, _color) |
31 | { |
31 | { |
32 | mas[MAX_COLORS*_r + _c] = _color; |
32 | mas[MAX_COLORS*_r + _c] = _color; |
33 | } |
33 | } |
34 | 34 | ||
35 | dword _colors::get_color(int _r, _c) |
35 | dword _colors::get_color(int _r, _c) |
36 | { |
36 | { |
37 | return mas[MAX_COLORS*_r + _c]; |
37 | return mas[MAX_COLORS*_r + _c]; |
38 | } |
38 | } |
39 | 39 | ||
40 | dword _colors::get_image() |
40 | dword _colors::get_image() |
41 | { |
41 | { |
42 | int r=0, c=0; |
42 | int r=0, c=0; |
43 | dword i; |
43 | dword i; |
44 | 44 | ||
45 | free(image); |
45 | free(image); |
46 | i = image = malloc(rows*columns*3); |
46 | i = image = malloc(rows*columns*3); |
47 | 47 | ||
48 | for (r = 0; r < rows; r++) |
48 | for (r = 0; r < rows; r++) |
49 | { |
49 | { |
50 | for (c = 0; c < columns; c++) |
50 | for (c = 0; c < columns; c++) |
51 | { |
51 | { |
52 | rgb.DwordToRgb(get_color(r,c)); |
52 | rgb.DwordToRgb(get_color(r,c)); |
53 | ESBYTE[i] = rgb.b; |
53 | ESBYTE[i] = rgb.b; |
54 | ESBYTE[i+1] = rgb.g; |
54 | ESBYTE[i+1] = rgb.g; |
55 | ESBYTE[i+2] = rgb.r; |
55 | ESBYTE[i+2] = rgb.r; |
56 | i += 3; |
56 | i += 3; |
57 | } |
57 | } |
58 | } |
58 | } |
59 | return image; |
59 | return image; |
60 | } |
60 | } |
61 | 61 | ||
62 | void _colors::draw_cell(int _x, _y, _color) |
62 | void _colors::draw_cell(int _x, _y, _color) |
63 | { |
63 | { |
64 | //DrawRectangle(_x, _y, cell_size, cell_size, system.color.work_graph); |
64 | //DrawRectangle(_x, _y, cell_size, cell_size, system.color.work_graph); |
65 | //DrawBar(_x+1, _y+1, cell_size-1, cell_size-1, _color); |
65 | //DrawBar(_x+1, _y+1, cell_size-1, cell_size-1, _color); |
66 | DrawBar(_x, _y, cell_size, cell_size, _color); |
66 | DrawBar(_x, _y, cell_size, cell_size, _color); |
67 | } |
67 | } |
68 | 68 | ||
69 | void _colors::draw_all_cells() |
69 | void _colors::draw_all_cells() |
70 | { |
70 | { |
71 | int r, c, i; |
71 | int r, c, i; |
72 | for (i=300; i |
72 | for (i=300; i |
73 | for (r = 0; r < rows; r++) |
73 | for (r = 0; r < rows; r++) |
74 | { |
74 | { |
75 | for (c = 0; c < columns; c++) |
75 | for (c = 0; c < columns; c++) |
76 | { |
76 | { |
77 | draw_cell(c*cell_size + x, r*cell_size + y, get_color(r, c)); |
77 | draw_cell(c*cell_size + x, r*cell_size + y, get_color(r, c)); |
78 | DefineHiddenButton(c*cell_size + x, r*cell_size + y, cell_size, cell_size, r*columns+c+300+BT_NOFRAME); |
78 | //DefineHiddenButton(c*cell_size + x, r*cell_size + y, cell_size, cell_size, r*columns+c+300+BT_NOFRAME); |
79 | } |
79 | } |
80 | } |
80 | } |
81 | } |
81 | } |
82 | 82 | ||
83 | enum { |
83 | enum { |
84 | DIRECTION_LEFT, |
84 | DIRECTION_LEFT, |
85 | DIRECTION_RIGHT, |
85 | DIRECTION_RIGHT, |
86 | DIRECTION_UP, |
86 | DIRECTION_UP, |
87 | DIRECTION_DOWN |
87 | DIRECTION_DOWN |
88 | }; |
88 | }; |
89 | void _colors::move(int direction) |
89 | void _colors::move(int direction) |
90 | { |
90 | { |
91 | int r, c; |
91 | int r, c; |
92 | dword first_element_data; |
92 | dword first_element_data; |
93 | 93 | ||
94 | if (direction == DIRECTION_LEFT) |
94 | if (direction == DIRECTION_LEFT) |
95 | { |
95 | { |
96 | for (r = 0; r < rows; r++) |
96 | for (r = 0; r < rows; r++) |
97 | { |
97 | { |
98 | first_element_data = get_color(r, 0); |
98 | first_element_data = get_color(r, 0); |
99 | for (c = 0; c < columns-1; c++) set_color(r, c, get_color(r, c+1)); |
99 | for (c = 0; c < columns-1; c++) set_color(r, c, get_color(r, c+1)); |
100 | set_color(r, columns-1, first_element_data); |
100 | set_color(r, columns-1, first_element_data); |
101 | } |
101 | } |
102 | } |
102 | } |
103 | if (direction == DIRECTION_RIGHT) |
103 | if (direction == DIRECTION_RIGHT) |
104 | { |
104 | { |
105 | for (r = 0; r < rows; r++) |
105 | for (r = 0; r < rows; r++) |
106 | { |
106 | { |
107 | first_element_data = get_color(r, columns-1); |
107 | first_element_data = get_color(r, columns-1); |
108 | for (c = columns-1; c > 0; c--) set_color(r, c, get_color(r, c-1)); |
108 | for (c = columns-1; c > 0; c--) set_color(r, c, get_color(r, c-1)); |
109 | set_color(r, 0, first_element_data); |
109 | set_color(r, 0, first_element_data); |
110 | } |
110 | } |
111 | } |
111 | } |
112 | if (direction == DIRECTION_UP) |
112 | if (direction == DIRECTION_UP) |
113 | { |
113 | { |
114 | for (c = 0; c < columns; c++) |
114 | for (c = 0; c < columns; c++) |
115 | { |
115 | { |
116 | first_element_data = get_color(0, c); |
116 | first_element_data = get_color(0, c); |
117 | for (r = 0; r < rows-1; r++) set_color(r, c, get_color(r+1, c)); |
117 | for (r = 0; r < rows-1; r++) set_color(r, c, get_color(r+1, c)); |
118 | set_color(rows-1, c, first_element_data); |
118 | set_color(rows-1, c, first_element_data); |
119 | } |
119 | } |
120 | } |
120 | } |
121 | if (direction == DIRECTION_DOWN) |
121 | if (direction == DIRECTION_DOWN) |
122 | { |
122 | { |
123 | for (c = 0; c < columns; c++) |
123 | for (c = 0; c < columns; c++) |
124 | { |
124 | { |
125 | first_element_data = get_color(rows-1, c); |
125 | first_element_data = get_color(rows-1, c); |
126 | for (r = rows-1; r > 0; r--) set_color(r, c, get_color(r-1, c)); |
126 | for (r = rows-1; r > 0; r--) set_color(r, c, get_color(r-1, c)); |
127 | set_color(0, c, first_element_data); |
127 | set_color(0, c, first_element_data); |
128 | } |
128 | } |
129 | } |
129 | } |
130 | 130 | ||
131 | draw_all_cells(); |
131 | draw_all_cells(); |
132 | }>>>>>>>>>> |
132 | }>>>>>>>>>>> |