2 * This file contains the source of a program used to demonstrate BTUI's 24-bit
3 * color support by printing a rapidfire rainbow.
11 btui_t *bt = btui_enable();
15 double a1 = 1.13, a2 = 1.23, a3 = 1.37;
18 setvbuf(bt->out, buf, _IOFBF, sizeof(buf));
19 btui_puts(bt, T_OFF(T_WRAP));
20 const char *title = " 24 BIT COLOR SUPPORT! ";
23 btui_move_cursor(bt, 0, y);
24 for (int x = 0; x < bt->width; x++) {
25 int r = (int)(255.0 * (0.5 + 0.5*sin(t*a1 + (double)(x) / 50.0)));
26 int g = (int)(255.0 * (0.5 + 0.5*sin(0.8 + t*a2 + (double)(x) / 50.0)));
27 int b = (int)(255.0 * (0.5 + 0.5*sin(1.3 + t*a3 + (double)(x) / 50.0)));
29 (r < 0 ? 0 : (r > 255 ? 255 : r)),
30 (g < 0 ? 0 : (g > 255 ? 255 : g)),
31 (b < 0 ? 0 : (b > 255 ? 255 : b)));
35 btui_move_cursor(bt, (bt->width - (int)strlen(title)) / 2, 0);
36 btui_set_attributes(bt, BTUI_NORMAL | BTUI_BOLD);
42 int mouse_x = -1, mouse_y = -1;
43 int key = btui_getkey(bt, 0, &mouse_x, &mouse_y);
45 case 'q': case KEY_CTRL_C: done = 1; break;