Use alpha channel in text rendering in terminal

This commit is contained in:
Kevin Lange 2013-03-29 00:39:23 -07:00
parent 8e48ee8cfa
commit e2d5411a96
2 changed files with 8 additions and 2 deletions

View File

@ -415,7 +415,6 @@ static void _ansi_put(char c) {
state.bg = c;
state.flags |= ANSI_SPECBG;
} else if (atoi(argv[i-1]) == 38) {
/* we can't actually use alphas with fg */
state.fg = c;
}
i += 4;
@ -732,7 +731,9 @@ void drawChar(FT_Bitmap * bitmap, int x, int y, uint32_t fg, uint32_t bg) {
int y_max = y + bitmap->rows;
for (j = y, q = 0; j < y_max; j++, q++) {
for ( i = x, p = 0; i < x_max; i++, p++) {
uint32_t tmp = (fg & 0xFFFFFF) | 0x1000000 * bitmap->buffer[q * bitmap->width + p];
uint32_t a = _ALP(fg);
a = (a * bitmap->buffer[q * bitmap->width + p]) / 255;
uint32_t tmp = rgba(_RED(fg),_GRE(fg),_BLU(fg),a);
term_set_point(i,j, alpha_blend_rgba(premultiply(bg), premultiply(tmp)));
}
}

View File

@ -18,6 +18,11 @@ int main(int argc, char ** argv) {
}
printf("\n");
for (int i = 0; i < 256; i += 3) {
printf("\033[48;6;255;0;0;0;m\033[38;6;255;0;0;%dmX\033[0m", i);
}
printf("\n");
return 0;
}