testpat.c revision 1.6 1 1.6 nat /* $NetBSD: testpat.c,v 1.6 2021/11/13 20:59:13 nat Exp $ */
2 1.1 nat
3 1.1 nat /*-
4 1.1 nat * Copyright (c) 2016 Nathanial Sloss <nathanialsloss (at) yahoo.com.au>
5 1.1 nat * All rights reserved.
6 1.1 nat *
7 1.1 nat * Redistribution and use in source and binary forms, with or without
8 1.1 nat * modification, are permitted provided that the following conditions
9 1.1 nat * are met:
10 1.1 nat * 1. Redistributions of source code must retain the above copyright
11 1.1 nat * notice, this list of conditions and the following disclaimer.
12 1.1 nat * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 nat * notice, this list of conditions and the following disclaimer in the
14 1.1 nat * documentation and/or other materials provided with the distribution.
15 1.1 nat *
16 1.1 nat * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17 1.1 nat * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 1.1 nat * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 1.1 nat * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 1.1 nat * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 1.1 nat * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 1.1 nat * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 1.1 nat * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 1.1 nat * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 1.1 nat * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 1.1 nat * POSSIBILITY OF SUCH DAMAGE.
27 1.1 nat */
28 1.4 christos #include <sys/cdefs.h>
29 1.6 nat __RCSID("$NetBSD: testpat.c,v 1.6 2021/11/13 20:59:13 nat Exp $");
30 1.4 christos
31 1.4 christos #include <sys/types.h>
32 1.4 christos #include <sys/time.h>
33 1.1 nat
34 1.1 nat #include <curses.h>
35 1.1 nat #include <err.h>
36 1.1 nat #include <errno.h>
37 1.1 nat #include <math.h>
38 1.1 nat #include <stdio.h>
39 1.1 nat #include <stdlib.h>
40 1.1 nat #include <string.h>
41 1.1 nat #include <time.h>
42 1.4 christos
43 1.4 christos static int colour_list[6] = {
44 1.4 christos COLOR_YELLOW,
45 1.4 christos COLOR_CYAN,
46 1.4 christos COLOR_GREEN,
47 1.4 christos COLOR_MAGENTA,
48 1.4 christos COLOR_RED,
49 1.4 christos COLOR_BLUE,
50 1.4 christos };
51 1.4 christos static int numcolours = (int)__arraycount(colour_list);
52 1.1 nat
53 1.1 nat int main(int argc, char *argv[]) {
54 1.1 nat int i, col, colour, line, x_limit, y_limit, colourOK, spacing;
55 1.1 nat int xpos, ypos, spacing_residual, spacing_start, spacing_end;
56 1.4 christos int grid_x, grid_y, **circle_pos;
57 1.4 christos size_t ncpos;
58 1.1 nat float grid_unit;
59 1.4 christos const char *title = "NetBSD";
60 1.1 nat float coord_x, circle_int;
61 1.1 nat float a_axis, b_axis;
62 1.1 nat
63 1.4 christos if (!initscr()) {
64 1.4 christos errx(EXIT_FAILURE, "Unknown terminal type");
65 1.1 nat }
66 1.4 christos
67 1.3 jmcneill curs_set(0);
68 1.1 nat
69 1.1 nat if (argc > 2) {
70 1.1 nat endwin();
71 1.4 christos fprintf(stderr, "Usage: %s <title>", getprogname());
72 1.4 christos return EXIT_FAILURE;
73 1.1 nat }
74 1.2 jmcneill
75 1.4 christos if (argc == 2) {
76 1.4 christos title = argv[1];
77 1.4 christos if (strlen(title) >= (size_t)COLS) {
78 1.4 christos endwin();
79 1.4 christos errx(EXIT_FAILURE,
80 1.4 christos "Title string is longer than display cols");
81 1.4 christos }
82 1.1 nat }
83 1.1 nat
84 1.1 nat colourOK = has_colors();
85 1.1 nat
86 1.1 nat if (COLS < 13 || LINES < 13) {
87 1.1 nat endwin();
88 1.4 christos errx(EXIT_FAILURE, "Terminal size must be at least 72x25.");
89 1.1 nat }
90 1.1 nat
91 1.1 nat if (colourOK) {
92 1.1 nat start_color();
93 1.2 jmcneill
94 1.4 christos init_pair(0, COLOR_WHITE, COLOR_BLACK);
95 1.4 christos init_pair(1, COLOR_WHITE, COLOR_RED);
96 1.4 christos init_pair(2, COLOR_WHITE, COLOR_GREEN);
97 1.4 christos init_pair(3, COLOR_WHITE, COLOR_YELLOW);
98 1.4 christos init_pair(4, COLOR_WHITE, COLOR_BLUE);
99 1.4 christos init_pair(5, COLOR_WHITE, COLOR_MAGENTA);
100 1.4 christos init_pair(6, COLOR_WHITE, COLOR_CYAN);
101 1.4 christos init_pair(7, COLOR_BLACK, COLOR_WHITE);
102 1.1 nat
103 1.1 nat attrset(COLOR_PAIR(0));
104 1.1 nat }
105 1.1 nat
106 1.1 nat x_limit = (COLS - 1) / 2;
107 1.1 nat x_limit = x_limit * 2;
108 1.1 nat y_limit = (LINES - 2) / 2;
109 1.1 nat y_limit = y_limit * 2;
110 1.1 nat spacing = 2 * y_limit / numcolours;
111 1.1 nat spacing_residual = ((2 * y_limit) % numcolours) / 2;
112 1.1 nat a_axis = y_limit / 2;
113 1.1 nat b_axis = y_limit;
114 1.1 nat grid_unit = b_axis / 13;
115 1.1 nat grid_y = grid_unit;
116 1.1 nat grid_x = grid_unit * 2;
117 1.1 nat
118 1.5 rillig
119 1.4 christos ncpos = y_limit * sizeof(*circle_pos)
120 1.4 christos + y_limit * 2 * sizeof(**circle_pos);
121 1.4 christos circle_pos = malloc(ncpos);
122 1.4 christos if (circle_pos == NULL) {
123 1.4 christos endwin();
124 1.4 christos errx(EXIT_FAILURE, "Can't allocate circle positions");
125 1.4 christos }
126 1.4 christos for (i = 0; i < y_limit; i++) {
127 1.4 christos circle_pos[i] = (void *)&circle_pos[y_limit + i * 2];
128 1.4 christos circle_pos[i][0] = circle_pos[i][1] = -1;
129 1.4 christos }
130 1.1 nat
131 1.1 nat for (i = 0; i < y_limit; i++) {
132 1.4 christos /* Draw an ellipse (looks more circular.) */
133 1.1 nat circle_int = (i - a_axis) / a_axis;
134 1.1 nat circle_int = 1 - powf(circle_int, 2);
135 1.1 nat circle_int = circle_int * powf(b_axis, 2);
136 1.1 nat #if 0
137 1.1 nat /* Draw a circle, commented out as elipse looks better.*/
138 1.1 nat circle_int = powf(a_axis, 2) - powf(i - a_axis, 2);
139 1.1 nat #endif
140 1.1 nat coord_x = sqrtf(circle_int);
141 1.1 nat circle_pos[i][0] = (-coord_x + ((float)x_limit / 2));
142 1.1 nat circle_pos[i][1] = (coord_x + ((float)x_limit / 2));
143 1.1 nat }
144 1.1 nat
145 1.1 nat clear();
146 1.1 nat
147 1.1 nat attron(A_ALTCHARSET);
148 1.1 nat move(0, 0);
149 1.1 nat
150 1.1 nat /* Draw a grid. */
151 1.1 nat for (line = 1; line < y_limit; line += grid_y) {
152 1.1 nat for (col = 1; col < x_limit; col = col + grid_x) {
153 1.1 nat xpos = col;
154 1.1 nat while ((xpos < col + grid_x - 1) && (xpos <
155 1.1 nat x_limit)) {
156 1.1 nat mvaddch(line + grid_y - 1, xpos, 113 |
157 1.1 nat A_ALTCHARSET);
158 1.1 nat xpos++;
159 1.1 nat }
160 1.1 nat if (xpos < x_limit)
161 1.1 nat mvaddch(line + grid_y - 1, xpos, 110 |
162 1.1 nat A_ALTCHARSET);
163 1.1 nat }
164 1.1 nat ypos = line;
165 1.1 nat while (ypos < line + grid_y - 1) {
166 1.1 nat for (col = grid_x - 1; col < x_limit; col += grid_x) {
167 1.1 nat mvaddch(ypos, col + 1, 120 | A_ALTCHARSET);
168 1.1 nat }
169 1.1 nat ypos++;
170 1.1 nat }
171 1.1 nat }
172 1.1 nat
173 1.1 nat for (line = 1; line < y_limit; line += grid_y) {
174 1.1 nat mvaddch(line + grid_y - 1, 0, 116 | A_ALTCHARSET);
175 1.1 nat mvaddch(line + grid_y - 1, x_limit, 117 | A_ALTCHARSET);
176 1.1 nat
177 1.1 nat ypos = line;
178 1.1 nat while (ypos < line + grid_y - 1) {
179 1.1 nat mvaddch(ypos, 0, 120 | A_ALTCHARSET);
180 1.1 nat mvaddch(ypos, x_limit, 120 | A_ALTCHARSET);
181 1.1 nat ypos++;
182 1.1 nat }
183 1.1 nat }
184 1.1 nat
185 1.1 nat for (col = 1; col < x_limit; col += grid_x) {
186 1.1 nat mvaddch(0, col + grid_x - 1, 119 | A_ALTCHARSET);
187 1.1 nat mvaddch(y_limit, col + grid_x - 1, 118 | A_ALTCHARSET);
188 1.1 nat
189 1.1 nat xpos = col;
190 1.1 nat while ((xpos < col + grid_x - 1) && (xpos < x_limit)) {
191 1.1 nat mvaddch(0, xpos, 113 | A_ALTCHARSET);
192 1.1 nat mvaddch(y_limit, xpos, 113 | A_ALTCHARSET);
193 1.1 nat xpos++;
194 1.1 nat }
195 1.1 nat }
196 1.1 nat
197 1.1 nat mvaddch(0, 0, 108 | A_ALTCHARSET);
198 1.1 nat mvaddch(0, x_limit, 107 | A_ALTCHARSET);
199 1.1 nat mvaddch(y_limit, 0, 109 | A_ALTCHARSET);
200 1.1 nat mvaddch(y_limit, x_limit, 106 | A_ALTCHARSET);
201 1.1 nat
202 1.1 nat /* Draw a white circle. */
203 1.1 nat for (i = 1; i < y_limit; i++) {
204 1.1 nat for (col = circle_pos[i][0]; col <= circle_pos[i][1]; col++) {
205 1.1 nat mvaddch(i, col, 32 | A_REVERSE);
206 1.1 nat }
207 1.1 nat }
208 1.2 jmcneill
209 1.1 nat /* Add title segment. */
210 1.1 nat for (i = roundf(1 * grid_unit); i < roundf(2 * grid_unit); i++) {
211 1.1 nat if (colourOK)
212 1.1 nat attrset(COLOR_PAIR(COLOR_BLACK));
213 1.6 nat else
214 1.6 nat attrset(A_NORMAL);
215 1.1 nat
216 1.1 nat for (col = roundf((4 * grid_unit * 2) +
217 1.4 christos circle_pos[y_limit / 2][0]); col <= roundf((9 * grid_unit
218 1.4 christos * 2) + circle_pos[y_limit / 2][0]); col++)
219 1.1 nat mvaddch(i, col, ' ');
220 1.1 nat }
221 1.1 nat
222 1.2 jmcneill i = roundf(1.4 * grid_unit);
223 1.1 nat
224 1.6 nat if (!colourOK)
225 1.6 nat attrset(A_NORMAL);
226 1.6 nat
227 1.1 nat col = y_limit - (strlen(title) / 2) + circle_pos[y_limit / 2][0];
228 1.1 nat mvprintw(i, col, "%s", title);
229 1.1 nat
230 1.1 nat /* Add black segments at top. */
231 1.1 nat for (line = roundf(2 * grid_unit); line < 4 * grid_unit; line++) {
232 1.1 nat if (colourOK)
233 1.1 nat attrset(COLOR_PAIR(COLOR_BLACK));
234 1.6 nat else
235 1.6 nat attrset(A_NORMAL);
236 1.1 nat
237 1.1 nat for (col = 0; col <= roundf((3.5 * grid_unit * 2)); col++) {
238 1.1 nat xpos = col + circle_pos[y_limit / 2][0];
239 1.1 nat if (xpos >= circle_pos[line][0] &&
240 1.1 nat xpos <= circle_pos[line][1])
241 1.1 nat mvaddch(line, xpos, ' ');
242 1.1 nat }
243 1.1 nat
244 1.2 jmcneill for (col = roundf((9.5 * grid_unit * 2)); col <
245 1.1 nat roundf((13 * grid_unit * 2)); col++) {
246 1.1 nat xpos = col + circle_pos[y_limit / 2][0];
247 1.1 nat if (xpos >= circle_pos[line][0] &&
248 1.1 nat xpos <= circle_pos[line][1])
249 1.1 nat mvaddch(line, xpos, ' ');
250 1.1 nat }
251 1.1 nat }
252 1.1 nat
253 1.1 nat /* Add black and white squares close to top. */
254 1.1 nat int gap = (circle_pos[(int)(5 * grid_unit)][1] -
255 1.1 nat circle_pos[(int)(5 * grid_unit)][0]) / 13;
256 1.1 nat
257 1.1 nat for (i = roundf(3 * grid_unit); i < roundf(4 * grid_unit); i++) {
258 1.1 nat for (xpos = 0; xpos <= x_limit; xpos += 2 * gap) {
259 1.1 nat if (colourOK)
260 1.1 nat attrset(COLOR_PAIR(COLOR_BLACK));
261 1.6 nat else
262 1.6 nat attrset(A_NORMAL);
263 1.1 nat
264 1.1 nat for (col = xpos; col < xpos + gap; col++) {
265 1.1 nat if (col >= circle_pos[i][0] &&
266 1.1 nat col <= circle_pos[i][1])
267 1.1 nat mvaddch(i, col, ' ');
268 1.1 nat }
269 1.1 nat
270 1.1 nat if (colourOK)
271 1.1 nat attrset(COLOR_PAIR(COLOR_WHITE));
272 1.6 nat else
273 1.6 nat attrset(A_REVERSE);
274 1.1 nat
275 1.1 nat for (col = xpos + gap ; col < xpos + (2 * gap);
276 1.1 nat col++) {
277 1.1 nat if (col >= circle_pos[i][0] &&
278 1.1 nat col <= circle_pos[i][1])
279 1.1 nat mvaddch(i, col, ' ');
280 1.1 nat }
281 1.1 nat }
282 1.1 nat }
283 1.1 nat
284 1.1 nat /* Add colour bars. */
285 1.1 nat for (i = 0; i < numcolours; i++) {
286 1.1 nat colour = colour_list[i];
287 1.1 nat if (colourOK)
288 1.1 nat attrset(COLOR_PAIR(colour));
289 1.6 nat else if (i & 1)
290 1.6 nat attrset(A_NORMAL);
291 1.6 nat else
292 1.6 nat attrset(A_REVERSE);
293 1.1 nat
294 1.2 jmcneill if (i == 0)
295 1.1 nat spacing_start = 0;
296 1.1 nat else
297 1.1 nat spacing_start = (spacing * i) + spacing_residual;
298 1.1 nat
299 1.1 nat if (i == numcolours - 1)
300 1.1 nat spacing_end = circle_pos[y_limit / 2][1];
301 1.1 nat else
302 1.1 nat spacing_end = (spacing * (i + 1)) + spacing_residual;
303 1.1 nat
304 1.1 nat for (line = roundf(4 * grid_unit); line < (y_limit / 2);
305 1.1 nat line++) {
306 1.1 nat for (col = spacing_start; col < spacing_end; col++) {
307 1.1 nat xpos = col + circle_pos[y_limit / 2][0];
308 1.1 nat if (xpos >= circle_pos[line][0] &&
309 1.1 nat xpos <= circle_pos[line][1])
310 1.1 nat mvprintw(line, xpos, " ");
311 1.1 nat }
312 1.1 nat }
313 1.1 nat }
314 1.1 nat
315 1.1 nat /* Add black segment under centre line. */
316 1.1 nat for (line = y_limit / 2; line < (9.5 * grid_unit); line++) {
317 1.1 nat if (colourOK)
318 1.1 nat attrset(COLOR_PAIR(COLOR_BLACK));
319 1.6 nat else
320 1.6 nat attrset(A_NORMAL);
321 1.1 nat
322 1.1 nat for (col = circle_pos[line][0]; col <= circle_pos[line][1];
323 1.1 nat col++)
324 1.1 nat mvaddch(line, col, ' ');
325 1.1 nat
326 1.2 jmcneill for (col = roundf((1.5 * grid_unit * 2)); col <
327 1.1 nat roundf((4.3 * grid_unit * 2)); col++) {
328 1.1 nat xpos = col + circle_pos[y_limit / 2][0];
329 1.1 nat if (xpos >= circle_pos[line][0] &&
330 1.1 nat xpos < circle_pos[line][1])
331 1.1 nat mvaddch(line, xpos, 120 | A_ALTCHARSET);
332 1.1 nat }
333 1.1 nat
334 1.2 jmcneill for (col = roundf((4.3 * grid_unit * 2)); col <
335 1.1 nat roundf((7.6 * grid_unit * 2)); col++) {
336 1.1 nat xpos = col + circle_pos[y_limit / 2][0];
337 1.1 nat if (xpos >= circle_pos[line][0] &&
338 1.1 nat xpos < circle_pos[line][1])
339 1.1 nat mvaddch(line, xpos, '|');
340 1.1 nat }
341 1.1 nat
342 1.2 jmcneill for (col = roundf((7.6 * grid_unit * 2)); col <
343 1.1 nat roundf((11.5 * grid_unit * 2)); col++) {
344 1.1 nat xpos = col + circle_pos[y_limit / 2][0];
345 1.1 nat if (xpos >= circle_pos[line][0] &&
346 1.1 nat xpos < circle_pos[line][1])
347 1.1 nat mvaddch(line, xpos, 97 | A_ALTCHARSET);
348 1.1 nat }
349 1.1 nat }
350 1.1 nat
351 1.1 nat /* Add black segment close to bottom. */
352 1.1 nat for (line = roundf(9.5 * grid_unit); line <= (10.5 * grid_unit);
353 1.1 nat line++) {
354 1.1 nat if (colourOK)
355 1.1 nat attrset(COLOR_PAIR(COLOR_BLACK));
356 1.6 nat else
357 1.6 nat attrset(A_NORMAL);
358 1.1 nat
359 1.2 jmcneill for (col = roundf((0 * grid_unit * 2)); col <
360 1.1 nat roundf((4 * grid_unit * 2)); col++) {
361 1.1 nat xpos = col + circle_pos[y_limit / 2][0];
362 1.1 nat if (xpos >= circle_pos[line][0] &&
363 1.1 nat xpos < circle_pos[line][1])
364 1.1 nat mvaddch(line, xpos, ' ');
365 1.1 nat }
366 1.1 nat
367 1.2 jmcneill for (col = roundf((4 * grid_unit * 2)); col <
368 1.1 nat roundf((6.5 * grid_unit * 2)); col++) {
369 1.1 nat xpos = col + circle_pos[y_limit / 2][0];
370 1.1 nat if (xpos >= circle_pos[line][0] &&
371 1.1 nat xpos < circle_pos[line][1])
372 1.1 nat mvaddch(line, xpos, 97 | A_ALTCHARSET);
373 1.1 nat }
374 1.1 nat
375 1.1 nat if (colourOK)
376 1.1 nat attrset(COLOR_PAIR(COLOR_WHITE));
377 1.6 nat else
378 1.6 nat attrset(A_REVERSE);
379 1.1 nat
380 1.2 jmcneill for (col = roundf((6.5 * grid_unit * 2)); col <
381 1.1 nat roundf((9 * grid_unit * 2)); col++) {
382 1.1 nat xpos = col + circle_pos[y_limit / 2][0];
383 1.1 nat if (xpos >= circle_pos[line][0] &&
384 1.1 nat xpos < circle_pos[line][1])
385 1.1 nat mvaddch(line, xpos, 97 | A_ALTCHARSET);
386 1.1 nat }
387 1.1 nat
388 1.2 jmcneill for (col = roundf((9 * grid_unit * 2)); col <
389 1.1 nat roundf((13 * grid_unit * 2)); col++) {
390 1.1 nat xpos = col + circle_pos[y_limit / 2][0];
391 1.1 nat if (xpos >= circle_pos[line][0] &&
392 1.1 nat xpos < circle_pos[line][1])
393 1.1 nat mvaddch(line, xpos, ' ');
394 1.1 nat }
395 1.1 nat }
396 1.1 nat
397 1.1 nat /* Add name segment close to bottom. */
398 1.1 nat for (line = roundf(10.5 * grid_unit); line < (12 * grid_unit);
399 1.1 nat line++) {
400 1.1 nat if (colourOK)
401 1.1 nat attrset(COLOR_PAIR(COLOR_BLACK));
402 1.6 nat else
403 1.6 nat attrset(A_NORMAL);
404 1.1 nat
405 1.1 nat for (col = roundf(3.5 * grid_unit * 2); col <= roundf(9.5 *
406 1.1 nat grid_unit * 2); col++) {
407 1.1 nat xpos = col + circle_pos[y_limit / 2][0];
408 1.1 nat if (xpos >= circle_pos[line][0] &&
409 1.1 nat xpos < circle_pos[line][1])
410 1.1 nat mvaddch(line, xpos, ' ');
411 1.1 nat }
412 1.1 nat
413 1.1 nat if (colourOK)
414 1.1 nat attrset(COLOR_PAIR(COLOR_WHITE));
415 1.6 nat else
416 1.6 nat attrset(A_REVERSE);
417 1.1 nat
418 1.1 nat for (col = roundf(0 * grid_unit * 2); col <= roundf(3.5 *
419 1.1 nat grid_unit * 2); col++) {
420 1.1 nat xpos = col + circle_pos[y_limit / 2][0];
421 1.1 nat if (xpos >= circle_pos[line][0] &&
422 1.1 nat xpos < circle_pos[line][1])
423 1.1 nat mvaddch(line, xpos, ' ');
424 1.1 nat }
425 1.1 nat
426 1.1 nat for (col = roundf(9.5 * grid_unit * 2); col <= roundf(13 *
427 1.1 nat grid_unit * 2); col++) {
428 1.1 nat xpos = col + circle_pos[y_limit / 2][0];
429 1.1 nat if (xpos >= circle_pos[line][0] &&
430 1.1 nat xpos < circle_pos[line][1])
431 1.1 nat mvaddch(line, xpos, ' ');
432 1.1 nat }
433 1.1 nat }
434 1.1 nat
435 1.1 nat /* Add yellow segment at bottom. */
436 1.1 nat for (line = 12 * grid_unit; line < y_limit; line++) {
437 1.1 nat if (colourOK)
438 1.1 nat attrset(COLOR_PAIR(COLOR_YELLOW));
439 1.6 nat else
440 1.6 nat attrset(A_REVERSE);
441 1.6 nat
442 1.1 nat
443 1.1 nat for (col = circle_pos[line][0]; col <= circle_pos[line][1];
444 1.1 nat col++)
445 1.1 nat mvaddch(line, col, ' ');
446 1.1 nat
447 1.1 nat if (colourOK)
448 1.1 nat attrset(COLOR_PAIR(COLOR_RED));
449 1.6 nat else
450 1.6 nat attrset(A_NORMAL);
451 1.1 nat
452 1.2 jmcneill for (col = roundf((6 * grid_unit * 2)); col <
453 1.1 nat roundf((7 * grid_unit * 2)); col++) {
454 1.1 nat xpos = col + circle_pos[y_limit / 2][0];
455 1.1 nat if (xpos >= circle_pos[line][0] &&
456 1.1 nat xpos < circle_pos[line][1])
457 1.1 nat mvaddch(line, xpos, ' ');
458 1.1 nat }
459 1.1 nat }
460 1.1 nat
461 1.1 nat if (colourOK)
462 1.1 nat attrset(COLOR_PAIR(COLOR_BLACK));
463 1.6 nat else
464 1.6 nat attrset(A_NORMAL);
465 1.2 jmcneill
466 1.1 nat for (line = 6 * grid_unit; line <= (7 * grid_unit) + 1; line++) {
467 1.1 nat if (colourOK)
468 1.1 nat attrset(COLOR_PAIR(COLOR_BLACK));
469 1.6 nat else
470 1.6 nat attrset(A_NORMAL);
471 1.1 nat
472 1.1 nat col = x_limit / 2;
473 1.1 nat if (line != a_axis) {
474 1.1 nat mvaddch(line, col - 1, ' ');
475 1.1 nat mvaddch(line, col, 120 | A_ALTCHARSET);
476 1.1 nat mvaddch(line, col + 1, ' ');
477 1.1 nat }
478 1.1 nat }
479 1.1 nat
480 1.1 nat line = y_limit / 2;
481 1.1 nat for (col = 1; col < x_limit; col = col + grid_x) {
482 1.1 nat xpos = col;
483 1.1 nat while (xpos < col + grid_x - 1) {
484 1.4 christos if (xpos >= circle_pos[line][0]
485 1.4 christos && xpos < circle_pos[line][1])
486 1.1 nat mvaddch(line, xpos, 113 | A_ALTCHARSET);
487 1.1 nat xpos++;
488 1.1 nat }
489 1.1 nat if (xpos >= circle_pos[line][0] && xpos < circle_pos[line][1])
490 1.1 nat mvaddch(line, xpos, 110 | A_ALTCHARSET);
491 1.1 nat }
492 1.1 nat
493 1.1 nat line = y_limit / 2;
494 1.1 nat col = x_limit / 2;
495 1.1 nat mvaddch(line, col, 110 | A_ALTCHARSET);
496 1.1 nat mvaddch(line, col - 1, 113 | A_ALTCHARSET);
497 1.1 nat mvaddch(line, col + 1, 113 | A_ALTCHARSET);
498 1.1 nat
499 1.1 nat refresh();
500 1.1 nat
501 1.1 nat getch();
502 1.1 nat
503 1.1 nat endwin();
504 1.1 nat
505 1.1 nat return EXIT_SUCCESS;
506 1.1 nat }
507 1.1 nat
508