spmenu/libs/schemes.c

53 lines
1.4 KiB
C
Raw Normal View History

2023-05-14 00:21:16 +02:00
/* See LICENSE file for copyright and license details. */
char sixd_to_8bit(int x) {
2023-05-08 23:00:45 +02:00
return x == 0 ? 0 : 0x37 + 0x28 * x;
}
void init_appearance(void) {
2023-05-08 18:15:20 +02:00
int i = 0;
char cbuf[8];
for (i = 0; i < LENGTH(textcolors) && i < LENGTH(txtcols); i++) {
txtcols[i] = textcolors[i];
}
if (i == 0) {
txtcols[i] = "#000000";
}
2023-05-08 23:00:45 +02:00
for (; i < 7; i++) {
snprintf(cbuf, sizeof(cbuf), "#%02x%02x%02x",
!!(i & 1) * 0x7f,
!!(i & 2) * 0x7f,
!!(i & 4) * 0x7f);
txtcols[i] = cbuf;
}
if (i == 7) {
txtcols[i] = "#000000";
}
if (i == 8) {
txtcols[i] = "#333333";
2023-05-08 23:00:45 +02:00
}
for (; i < 16; i++) {
snprintf(cbuf, sizeof(cbuf), "#%02x%02x%02x",
!!(i & 1) * 0xff,
!!(i & 2) * 0xff,
!!(i & 4) * 0xff);
txtcols[i] = cbuf;
2023-05-08 23:00:45 +02:00
}
for (; i < 6 * 6 * 6 + 16; i++) {
snprintf(cbuf, sizeof(cbuf), "#%02x%02x%02x",
sixd_to_8bit(((i - 16) / 36) % 6),
sixd_to_8bit(((i - 16) / 6) % 6),
sixd_to_8bit(((i - 16)) % 6));
txtcols[i] = cbuf;
2023-05-08 23:00:45 +02:00
}
for (; i < 256; i++) {
snprintf(cbuf, sizeof(cbuf), "#%02x%02x%02x",
0x08 + (i - 6 * 6 * 6 - 16) * 0x0a,
0x08 + (i - 6 * 6 * 6 - 16) * 0x0a,
0x08 + (i - 6 * 6 * 6 - 16) * 0x0a);
txtcols[i] = cbuf;
2023-05-08 23:00:45 +02:00
}
}