Browse Source

* Make the --metal filter only change the colour, not the characters.

pull/1/head
Sam Hocevar sam 19 years ago
parent
commit
d9bb31a40e
1 changed files with 10 additions and 20 deletions
  1. +10
    -20
      src/filters.c

+ 10
- 20
src/filters.c View File

@@ -60,23 +60,12 @@ void filter_autocrop(cucul_canvas_t *cv)


void filter_metal(cucul_canvas_t *cv) void filter_metal(cucul_canvas_t *cv)
{ {
static struct
static unsigned char const palette[] =
{ {
char ch[6];
unsigned char fg, bg;
}
const palette[] =
{
{ " ", CUCUL_COLOR_LIGHTBLUE, CUCUL_COLOR_LIGHTBLUE },
{ "░", CUCUL_COLOR_BLUE, CUCUL_COLOR_LIGHTBLUE },
{ "▒", CUCUL_COLOR_BLUE, CUCUL_COLOR_LIGHTBLUE },
{ "░", CUCUL_COLOR_LIGHTBLUE, CUCUL_COLOR_BLUE },
{ " ", CUCUL_COLOR_BLUE, CUCUL_COLOR_BLUE },
{ " ", CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_LIGHTGRAY },
{ "░", CUCUL_COLOR_DARKGRAY, CUCUL_COLOR_LIGHTGRAY },
{ "▒", CUCUL_COLOR_DARKGRAY, CUCUL_COLOR_LIGHTGRAY },
{ "░", CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_DARKGRAY },
{ " ", CUCUL_COLOR_DARKGRAY, CUCUL_COLOR_DARKGRAY },
CUCUL_COLOR_LIGHTBLUE,
CUCUL_COLOR_BLUE,
CUCUL_COLOR_LIGHTGRAY,
CUCUL_COLOR_DARKGRAY,
}; };


unsigned int x, y, w, h; unsigned int x, y, w, h;
@@ -87,14 +76,15 @@ void filter_metal(cucul_canvas_t *cv)
for(y = 0; y < h; y++) for(y = 0; y < h; y++)
for(x = 0; x < w; x++) for(x = 0; x < w; x++)
{ {
unsigned long int ch = cucul_getchar(cv, x, y);
int i; int i;


if(cucul_getchar(cv, x, y) == (unsigned char)' ')
if(ch == (unsigned char)' ')
continue; continue;


i = y * 10 / h;
cucul_set_color(cv, palette[i].fg, palette[i].bg);
cucul_putstr(cv, x, y, palette[i].ch);
i = y * 4 / h;
cucul_set_color(cv, palette[i], CUCUL_COLOR_TRANSPARENT);
cucul_putchar(cv, x, y, ch);
} }
} }




Loading…
Cancel
Save