Home | History | Annotate | Line # | Download | only in testpat
testpat.c revision 1.1
      1  1.1  nat /* $NetBSD: testpat.c,v 1.1 2021/01/02 03:21:39 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.1  nat 
     29  1.1  nat #include <curses.h>
     30  1.1  nat #include <err.h>
     31  1.1  nat #include <errno.h>
     32  1.1  nat #include <math.h>
     33  1.1  nat #include <stdio.h>
     34  1.1  nat #include <stdlib.h>
     35  1.1  nat #include <string.h>
     36  1.1  nat #include <time.h>
     37  1.1  nat #include <sys/time.h>
     38  1.1  nat #include <sys/types.h>
     39  1.1  nat 
     40  1.1  nat int main(int argc, char *argv[]) {
     41  1.1  nat 	int i, col, colour, line, x_limit, y_limit, colourOK, spacing;
     42  1.1  nat 	int xpos, ypos, spacing_residual, spacing_start, spacing_end;
     43  1.1  nat 	int grid_x, grid_y;
     44  1.1  nat 	float grid_unit;
     45  1.1  nat 
     46  1.1  nat 	char title[255] = "NetBSD";
     47  1.1  nat 	int numcolours = 6;
     48  1.1  nat 
     49  1.1  nat 	int colour_list[6] = {
     50  1.1  nat 		COLOR_YELLOW,
     51  1.1  nat 		COLOR_CYAN,
     52  1.1  nat 		COLOR_GREEN,
     53  1.1  nat 		COLOR_MAGENTA,
     54  1.1  nat 		COLOR_RED,
     55  1.1  nat 		COLOR_BLUE,
     56  1.1  nat 	};
     57  1.1  nat 
     58  1.1  nat 	float coord_x, circle_int;
     59  1.1  nat 	float a_axis, b_axis;
     60  1.1  nat 
     61  1.1  nat 	if (!(initscr())) {
     62  1.1  nat 		printf("\nUnknown terminal type.");
     63  1.1  nat 		printf("\n");
     64  1.1  nat 		return EXIT_FAILURE;
     65  1.1  nat 	}
     66  1.1  nat 
     67  1.1  nat 	if (argc > 2) {
     68  1.1  nat 		endwin();
     69  1.1  nat 		errx(EINVAL, "usage: testpat [title]");
     70  1.1  nat 	}
     71  1.1  nat 
     72  1.1  nat 	if (argc == 2 && strlen(argv[1]) < (size_t)COLS)
     73  1.1  nat 		snprintf(title, sizeof(title), "%s", argv[1]);
     74  1.1  nat 	else if (argc == 2 && (int)strlen(argv[1]) > COLS) {
     75  1.1  nat 		endwin();
     76  1.1  nat 		errx(EINVAL, "title string must be less than display columns");
     77  1.1  nat 	}
     78  1.1  nat 
     79  1.1  nat 	colourOK = has_colors();
     80  1.1  nat 
     81  1.1  nat 	if (COLS < 13 || LINES < 13) {
     82  1.1  nat 		endwin();
     83  1.1  nat 		printf("\nTerminal size must be at least 72x25.");
     84  1.1  nat 		printf("\n");
     85  1.1  nat 		return EXIT_FAILURE;
     86  1.1  nat 	}
     87  1.1  nat 
     88  1.1  nat 	if (colourOK) {
     89  1.1  nat 		start_color();
     90  1.1  nat 
     91  1.1  nat 	    	init_pair( 0, COLOR_WHITE, COLOR_BLACK );
     92  1.1  nat 	    	init_pair( 1, COLOR_WHITE, COLOR_RED );
     93  1.1  nat 	    	init_pair( 2, COLOR_WHITE, COLOR_GREEN );
     94  1.1  nat 	    	init_pair( 3, COLOR_WHITE, COLOR_YELLOW );
     95  1.1  nat 	    	init_pair( 4, COLOR_WHITE, COLOR_BLUE );
     96  1.1  nat 	    	init_pair( 5, COLOR_WHITE, COLOR_MAGENTA );
     97  1.1  nat 	    	init_pair( 6, COLOR_WHITE, COLOR_CYAN );
     98  1.1  nat 	    	init_pair( 7, COLOR_BLACK, COLOR_WHITE );
     99  1.1  nat 
    100  1.1  nat 		attrset(COLOR_PAIR(0));
    101  1.1  nat 	}
    102  1.1  nat 
    103  1.1  nat 	x_limit = (COLS - 1) / 2;
    104  1.1  nat 	x_limit = x_limit * 2;
    105  1.1  nat 	y_limit = (LINES - 2) / 2;
    106  1.1  nat 	y_limit = y_limit * 2;
    107  1.1  nat 	spacing = 2 * y_limit / numcolours;
    108  1.1  nat 	spacing_residual = ((2 * y_limit) % numcolours) / 2;
    109  1.1  nat 	a_axis = y_limit / 2;
    110  1.1  nat 	b_axis = y_limit;
    111  1.1  nat 	grid_unit = b_axis / 13;
    112  1.1  nat 	grid_y = grid_unit;
    113  1.1  nat 	grid_x = grid_unit * 2;
    114  1.1  nat 
    115  1.1  nat 	int circle_pos[y_limit][2];
    116  1.1  nat 	memset(circle_pos, -1, sizeof(circle_pos));
    117  1.1  nat 
    118  1.1  nat 	for (i = 0; i < y_limit; i++) {
    119  1.1  nat 		/* Draw an elipse (looks more circular.) */
    120  1.1  nat 		circle_int = (i - a_axis) / a_axis;
    121  1.1  nat 		circle_int = 1 - powf(circle_int, 2);
    122  1.1  nat 		circle_int = circle_int * powf(b_axis, 2);
    123  1.1  nat #if 0
    124  1.1  nat 		/* Draw a circle, commented out as elipse looks better.*/
    125  1.1  nat 		circle_int = powf(a_axis, 2) - powf(i - a_axis, 2);
    126  1.1  nat #endif
    127  1.1  nat 		coord_x = sqrtf(circle_int);
    128  1.1  nat 		circle_pos[i][0] = (-coord_x + ((float)x_limit / 2));
    129  1.1  nat 		circle_pos[i][1] = (coord_x + ((float)x_limit / 2));
    130  1.1  nat 	}
    131  1.1  nat 
    132  1.1  nat 	clear();
    133  1.1  nat 
    134  1.1  nat 	attron(A_ALTCHARSET);
    135  1.1  nat 	move(0, 0);
    136  1.1  nat 
    137  1.1  nat 	/* Draw a grid. */
    138  1.1  nat 	for (line = 1; line < y_limit; line += grid_y) {
    139  1.1  nat 		for (col = 1; col < x_limit; col = col + grid_x) {
    140  1.1  nat 			xpos = col;
    141  1.1  nat 			while ((xpos < col + grid_x - 1) && (xpos <
    142  1.1  nat 			    x_limit)) {
    143  1.1  nat 				mvaddch(line + grid_y - 1, xpos, 113 |
    144  1.1  nat 				    A_ALTCHARSET);
    145  1.1  nat 				xpos++;
    146  1.1  nat 			}
    147  1.1  nat 			if (xpos < x_limit)
    148  1.1  nat 				mvaddch(line + grid_y - 1, xpos, 110 |
    149  1.1  nat 				    A_ALTCHARSET);
    150  1.1  nat 		}
    151  1.1  nat 		ypos = line;
    152  1.1  nat 		while (ypos < line + grid_y - 1) {
    153  1.1  nat 			for (col = grid_x - 1; col < x_limit; col += grid_x) {
    154  1.1  nat 				mvaddch(ypos, col + 1, 120 | A_ALTCHARSET);
    155  1.1  nat 			}
    156  1.1  nat 			ypos++;
    157  1.1  nat 		}
    158  1.1  nat 	}
    159  1.1  nat 
    160  1.1  nat 	for (line = 1; line < y_limit; line += grid_y) {
    161  1.1  nat 		mvaddch(line + grid_y - 1, 0, 116 | A_ALTCHARSET);
    162  1.1  nat 		mvaddch(line + grid_y - 1, x_limit, 117 | 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 			mvaddch(ypos, 0, 120 | A_ALTCHARSET);
    167  1.1  nat 			mvaddch(ypos, x_limit, 120 | A_ALTCHARSET);
    168  1.1  nat 			ypos++;
    169  1.1  nat 		}
    170  1.1  nat 	}
    171  1.1  nat 
    172  1.1  nat 	for (col = 1; col < x_limit; col += grid_x) {
    173  1.1  nat 		mvaddch(0, col + grid_x - 1, 119 | A_ALTCHARSET);
    174  1.1  nat 		mvaddch(y_limit, col + grid_x - 1, 118 | A_ALTCHARSET);
    175  1.1  nat 
    176  1.1  nat 		xpos = col;
    177  1.1  nat 		while ((xpos < col + grid_x - 1) && (xpos < x_limit)) {
    178  1.1  nat 			mvaddch(0, xpos, 113 | A_ALTCHARSET);
    179  1.1  nat 			mvaddch(y_limit, xpos, 113 | A_ALTCHARSET);
    180  1.1  nat 			xpos++;
    181  1.1  nat 		}
    182  1.1  nat 	}
    183  1.1  nat 
    184  1.1  nat 	mvaddch(0, 0, 108 | A_ALTCHARSET);
    185  1.1  nat 	mvaddch(0, x_limit, 107 | A_ALTCHARSET);
    186  1.1  nat 	mvaddch(y_limit, 0, 109 | A_ALTCHARSET);
    187  1.1  nat 	mvaddch(y_limit, x_limit, 106 | A_ALTCHARSET);
    188  1.1  nat 
    189  1.1  nat 	/* Draw a white circle. */
    190  1.1  nat 	for (i = 1; i < y_limit; i++) {
    191  1.1  nat 		for (col = circle_pos[i][0]; col <= circle_pos[i][1]; col++) {
    192  1.1  nat 			mvaddch(i, col, 32 | A_REVERSE);
    193  1.1  nat 		}
    194  1.1  nat 	}
    195  1.1  nat 
    196  1.1  nat 	/* Add title segment. */
    197  1.1  nat 	for (i = roundf(1 * grid_unit); i < roundf(2 * grid_unit); i++) {
    198  1.1  nat 		if (colourOK)
    199  1.1  nat     			attrset(COLOR_PAIR(COLOR_BLACK));
    200  1.1  nat 
    201  1.1  nat 		for (col = roundf((4 * grid_unit * 2) +
    202  1.1  nat 		    circle_pos[y_limit /2][0]); col <= roundf((9 * grid_unit
    203  1.1  nat 		    * 2) + circle_pos[y_limit /2][0]); col++)
    204  1.1  nat 			mvaddch(i, col, ' ');
    205  1.1  nat 	}
    206  1.1  nat 
    207  1.1  nat 	i = roundf(1.4 * grid_unit);
    208  1.1  nat 
    209  1.1  nat 	col = y_limit - (strlen(title) / 2) + circle_pos[y_limit / 2][0];
    210  1.1  nat 		mvprintw(i, col, "%s", title);
    211  1.1  nat 
    212  1.1  nat 	/* Add black segments at top. */
    213  1.1  nat 	for (line = roundf(2 * grid_unit); line < 4 * grid_unit; line++) {
    214  1.1  nat 		if (colourOK)
    215  1.1  nat     			attrset(COLOR_PAIR(COLOR_BLACK));
    216  1.1  nat 
    217  1.1  nat 		for (col = 0; col <= roundf((3.5 * grid_unit * 2)); col++) {
    218  1.1  nat 				xpos = col + circle_pos[y_limit / 2][0];
    219  1.1  nat 				if (xpos >= circle_pos[line][0] &&
    220  1.1  nat 				    xpos <= circle_pos[line][1])
    221  1.1  nat 					mvaddch(line, xpos, ' ');
    222  1.1  nat 		}
    223  1.1  nat 
    224  1.1  nat 		for (col = roundf((9.5 * grid_unit * 2)); col <
    225  1.1  nat 		    roundf((13 * grid_unit * 2)); col++) {
    226  1.1  nat 				xpos = col + circle_pos[y_limit / 2][0];
    227  1.1  nat 				if (xpos >= circle_pos[line][0] &&
    228  1.1  nat 				    xpos <= circle_pos[line][1])
    229  1.1  nat 					mvaddch(line, xpos, ' ');
    230  1.1  nat 		}
    231  1.1  nat 	}
    232  1.1  nat 
    233  1.1  nat 	/* Add black and white squares close to top. */
    234  1.1  nat 	int gap = (circle_pos[(int)(5 * grid_unit)][1] -
    235  1.1  nat 	    circle_pos[(int)(5 * grid_unit)][0]) / 13;
    236  1.1  nat 
    237  1.1  nat 	for (i = roundf(3 * grid_unit); i < roundf(4 * grid_unit); i++) {
    238  1.1  nat 		for (xpos = 0; xpos <= x_limit; xpos += 2 * gap) {
    239  1.1  nat 			if (colourOK)
    240  1.1  nat     				attrset(COLOR_PAIR(COLOR_BLACK));
    241  1.1  nat 
    242  1.1  nat 			for (col = xpos; col < xpos + gap; col++) {
    243  1.1  nat 				if (col >= circle_pos[i][0] &&
    244  1.1  nat 				    col <= circle_pos[i][1])
    245  1.1  nat 					mvaddch(i, col, ' ');
    246  1.1  nat 			}
    247  1.1  nat 
    248  1.1  nat 			if (colourOK)
    249  1.1  nat     				attrset(COLOR_PAIR(COLOR_WHITE));
    250  1.1  nat 
    251  1.1  nat 			for (col = xpos + gap ; col < xpos + (2 * gap);
    252  1.1  nat 			    col++) {
    253  1.1  nat 				if (col >= circle_pos[i][0] &&
    254  1.1  nat 				    col <= circle_pos[i][1])
    255  1.1  nat 					mvaddch(i, col, ' ');
    256  1.1  nat 			}
    257  1.1  nat 		}
    258  1.1  nat 	}
    259  1.1  nat 
    260  1.1  nat 	/* Add colour bars. */
    261  1.1  nat 	for (i = 0; i < numcolours; i++) {
    262  1.1  nat 		colour = colour_list[i];
    263  1.1  nat 		if (colourOK)
    264  1.1  nat 	    		attrset(COLOR_PAIR(colour));
    265  1.1  nat 
    266  1.1  nat 		if (i == 0)
    267  1.1  nat 			spacing_start = 0;
    268  1.1  nat 		else
    269  1.1  nat 			spacing_start = (spacing * i) + spacing_residual;
    270  1.1  nat 
    271  1.1  nat 		if (i == numcolours - 1)
    272  1.1  nat 			spacing_end = circle_pos[y_limit / 2][1];
    273  1.1  nat 		else
    274  1.1  nat 			spacing_end = (spacing * (i + 1)) + spacing_residual;
    275  1.1  nat 
    276  1.1  nat 	    	for (line = roundf(4 * grid_unit); line < (y_limit / 2);
    277  1.1  nat 		    line++) {
    278  1.1  nat 			for (col = spacing_start; col < spacing_end; col++) {
    279  1.1  nat 				xpos = col + circle_pos[y_limit / 2][0];
    280  1.1  nat 				if (xpos >= circle_pos[line][0] &&
    281  1.1  nat 				    xpos <= circle_pos[line][1])
    282  1.1  nat 	    				mvprintw(line, xpos, " ");
    283  1.1  nat 			}
    284  1.1  nat 	    	}
    285  1.1  nat 	}
    286  1.1  nat 
    287  1.1  nat 	/* Add black segment under centre line. */
    288  1.1  nat 	for (line = y_limit / 2; line < (9.5 * grid_unit); line++) {
    289  1.1  nat 		if (colourOK)
    290  1.1  nat     			attrset(COLOR_PAIR(COLOR_BLACK));
    291  1.1  nat 
    292  1.1  nat 		for (col = circle_pos[line][0]; col <= circle_pos[line][1];
    293  1.1  nat 		    col++)
    294  1.1  nat 			mvaddch(line, col, ' ');
    295  1.1  nat 
    296  1.1  nat 		for (col = roundf((1.5 * grid_unit * 2)); col <
    297  1.1  nat 		    roundf((4.3 * grid_unit * 2)); col++) {
    298  1.1  nat 				xpos = col + circle_pos[y_limit / 2][0];
    299  1.1  nat 				if (xpos >= circle_pos[line][0] &&
    300  1.1  nat 				    xpos < circle_pos[line][1])
    301  1.1  nat 					mvaddch(line, xpos, 120 | A_ALTCHARSET);
    302  1.1  nat 		}
    303  1.1  nat 
    304  1.1  nat 		for (col = roundf((4.3 * grid_unit * 2)); col <
    305  1.1  nat 		    roundf((7.6 * grid_unit * 2)); col++) {
    306  1.1  nat 				xpos = col + circle_pos[y_limit / 2][0];
    307  1.1  nat 				if (xpos >= circle_pos[line][0] &&
    308  1.1  nat 				    xpos < circle_pos[line][1])
    309  1.1  nat 					mvaddch(line, xpos, '|');
    310  1.1  nat 		}
    311  1.1  nat 
    312  1.1  nat 		for (col = roundf((7.6 * grid_unit * 2)); col <
    313  1.1  nat 		    roundf((11.5 * grid_unit * 2)); col++) {
    314  1.1  nat 				xpos = col + circle_pos[y_limit / 2][0];
    315  1.1  nat 				if (xpos >= circle_pos[line][0] &&
    316  1.1  nat 				    xpos < circle_pos[line][1])
    317  1.1  nat 					mvaddch(line, xpos, 97 | A_ALTCHARSET);
    318  1.1  nat 		}
    319  1.1  nat 	}
    320  1.1  nat 
    321  1.1  nat 	/* Add black segment close to bottom. */
    322  1.1  nat 	for (line = roundf(9.5 * grid_unit); line <= (10.5 * grid_unit);
    323  1.1  nat 	    line++) {
    324  1.1  nat 		if (colourOK)
    325  1.1  nat     			attrset(COLOR_PAIR(COLOR_BLACK));
    326  1.1  nat 
    327  1.1  nat 		for (col = roundf((0 * grid_unit * 2)); col <
    328  1.1  nat 		    roundf((4 * grid_unit * 2)); col++) {
    329  1.1  nat 				xpos = col + circle_pos[y_limit / 2][0];
    330  1.1  nat 				if (xpos >= circle_pos[line][0] &&
    331  1.1  nat 				    xpos < circle_pos[line][1])
    332  1.1  nat 					mvaddch(line, xpos, ' ');
    333  1.1  nat 		}
    334  1.1  nat 
    335  1.1  nat 		for (col = roundf((4 * grid_unit * 2)); col <
    336  1.1  nat 		    roundf((6.5 * grid_unit * 2)); col++) {
    337  1.1  nat 				xpos = col + circle_pos[y_limit / 2][0];
    338  1.1  nat 				if (xpos >= circle_pos[line][0] &&
    339  1.1  nat 				    xpos < circle_pos[line][1])
    340  1.1  nat 					mvaddch(line, xpos, 97 | A_ALTCHARSET);
    341  1.1  nat 		}
    342  1.1  nat 
    343  1.1  nat 		if (colourOK)
    344  1.1  nat     			attrset(COLOR_PAIR(COLOR_WHITE));
    345  1.1  nat 
    346  1.1  nat 		for (col = roundf((6.5 * grid_unit * 2)); col <
    347  1.1  nat 		    roundf((9 * grid_unit * 2)); col++) {
    348  1.1  nat 				xpos = col + circle_pos[y_limit / 2][0];
    349  1.1  nat 				if (xpos >= circle_pos[line][0] &&
    350  1.1  nat 				    xpos < circle_pos[line][1])
    351  1.1  nat 					mvaddch(line, xpos, 97 | A_ALTCHARSET);
    352  1.1  nat 		}
    353  1.1  nat 
    354  1.1  nat 		for (col = roundf((9 * grid_unit * 2)); col <
    355  1.1  nat 		    roundf((13 * grid_unit * 2)); col++) {
    356  1.1  nat 				xpos = col + circle_pos[y_limit / 2][0];
    357  1.1  nat 				if (xpos >= circle_pos[line][0] &&
    358  1.1  nat 				    xpos < circle_pos[line][1])
    359  1.1  nat 					mvaddch(line, xpos, ' ');
    360  1.1  nat 		}
    361  1.1  nat 	}
    362  1.1  nat 
    363  1.1  nat 	/* Add name segment close to bottom. */
    364  1.1  nat 	for (line = roundf(10.5 * grid_unit); line < (12 * grid_unit);
    365  1.1  nat 	    line++) {
    366  1.1  nat 		if (colourOK)
    367  1.1  nat     			attrset(COLOR_PAIR(COLOR_BLACK));
    368  1.1  nat 
    369  1.1  nat 		for (col = roundf(3.5 * grid_unit * 2); col <= roundf(9.5 *
    370  1.1  nat 		    grid_unit * 2); col++) {
    371  1.1  nat 			xpos = col + circle_pos[y_limit / 2][0];
    372  1.1  nat 			if (xpos >= circle_pos[line][0] &&
    373  1.1  nat 			    xpos < circle_pos[line][1])
    374  1.1  nat 				mvaddch(line, xpos, ' ');
    375  1.1  nat 		}
    376  1.1  nat 
    377  1.1  nat 		if (colourOK)
    378  1.1  nat     			attrset(COLOR_PAIR(COLOR_WHITE));
    379  1.1  nat 
    380  1.1  nat 		for (col = roundf(0 * grid_unit * 2); col <= roundf(3.5 *
    381  1.1  nat 		    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, ' ');
    386  1.1  nat 		}
    387  1.1  nat 
    388  1.1  nat 		for (col = roundf(9.5 * grid_unit * 2); col <= roundf(13 *
    389  1.1  nat 		    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 yellow segment at bottom. */
    398  1.1  nat 	for (line = 12 * grid_unit; line < y_limit; line++) {
    399  1.1  nat 		if (colourOK)
    400  1.1  nat     			attrset(COLOR_PAIR(COLOR_YELLOW));
    401  1.1  nat 
    402  1.1  nat 		for (col = circle_pos[line][0]; col <= circle_pos[line][1];
    403  1.1  nat 		    col++)
    404  1.1  nat 			mvaddch(line, col, ' ');
    405  1.1  nat 
    406  1.1  nat 		if (colourOK)
    407  1.1  nat     			attrset(COLOR_PAIR(COLOR_RED));
    408  1.1  nat 
    409  1.1  nat 		for (col = roundf((6 * grid_unit * 2)); col <
    410  1.1  nat 		    roundf((7 * grid_unit * 2)); col++) {
    411  1.1  nat 				xpos = col + circle_pos[y_limit / 2][0];
    412  1.1  nat 				if (xpos >= circle_pos[line][0] &&
    413  1.1  nat 				    xpos < circle_pos[line][1])
    414  1.1  nat 					mvaddch(line, xpos, ' ');
    415  1.1  nat 		}
    416  1.1  nat 	}
    417  1.1  nat 
    418  1.1  nat 	if (colourOK)
    419  1.1  nat     		attrset(COLOR_PAIR(COLOR_BLACK));
    420  1.1  nat 
    421  1.1  nat 	for (line = 6 * grid_unit; line <= (7 * grid_unit) + 1; line++) {
    422  1.1  nat 		if (colourOK)
    423  1.1  nat     			attrset(COLOR_PAIR(COLOR_BLACK));
    424  1.1  nat 
    425  1.1  nat 		col = x_limit / 2;
    426  1.1  nat 		if (line != a_axis) {
    427  1.1  nat 			mvaddch(line, col - 1, ' ');
    428  1.1  nat 			mvaddch(line, col, 120 | A_ALTCHARSET);
    429  1.1  nat 			mvaddch(line, col + 1, ' ');
    430  1.1  nat 		}
    431  1.1  nat 	}
    432  1.1  nat 
    433  1.1  nat 	line = y_limit / 2;
    434  1.1  nat 	for (col = 1; col < x_limit; col = col + grid_x) {
    435  1.1  nat 		xpos = col;
    436  1.1  nat 		while (xpos < col + grid_x - 1) {
    437  1.1  nat 			if (xpos >= circle_pos[line][0] && xpos < circle_pos[line][1])
    438  1.1  nat 				mvaddch(line, xpos, 113 | A_ALTCHARSET);
    439  1.1  nat 			xpos++;
    440  1.1  nat 		}
    441  1.1  nat 		if (xpos >= circle_pos[line][0] && xpos < circle_pos[line][1])
    442  1.1  nat 			mvaddch(line, xpos, 110 | A_ALTCHARSET);
    443  1.1  nat 	}
    444  1.1  nat 
    445  1.1  nat 	line = y_limit / 2;
    446  1.1  nat 	col = x_limit / 2;
    447  1.1  nat 	mvaddch(line, col, 110 | A_ALTCHARSET);
    448  1.1  nat 	mvaddch(line, col - 1, 113 | A_ALTCHARSET);
    449  1.1  nat 	mvaddch(line, col + 1, 113 | A_ALTCHARSET);
    450  1.1  nat 
    451  1.1  nat 	refresh();
    452  1.1  nat 
    453  1.1  nat 	getch();
    454  1.1  nat 
    455  1.1  nat 	endwin();
    456  1.1  nat 
    457  1.1  nat 	return EXIT_SUCCESS;
    458  1.1  nat }
    459  1.1  nat 
    460