Add trans filter
This commit is contained in:
parent
3eb9d58037
commit
728ddc4d59
2 changed files with 30 additions and 0 deletions
25
src/filter.c
25
src/filter.c
|
@ -29,6 +29,7 @@
|
||||||
|
|
||||||
static void filter_crop(context_t *);
|
static void filter_crop(context_t *);
|
||||||
static void filter_rainbow(context_t *);
|
static void filter_rainbow(context_t *);
|
||||||
|
static void filter_trans(context_t *);
|
||||||
static void filter_metal(context_t *);
|
static void filter_metal(context_t *);
|
||||||
static void filter_flip(context_t *);
|
static void filter_flip(context_t *);
|
||||||
static void filter_flop(context_t *);
|
static void filter_flop(context_t *);
|
||||||
|
@ -47,6 +48,7 @@ const lookup[] =
|
||||||
{
|
{
|
||||||
{ "crop", filter_crop, "crop unused blanks" },
|
{ "crop", filter_crop, "crop unused blanks" },
|
||||||
{ "rainbow", filter_rainbow, "add a rainbow colour effect" },
|
{ "rainbow", filter_rainbow, "add a rainbow colour effect" },
|
||||||
|
{ "trans", filter_trans, "trans rights uwu~"},
|
||||||
{ "metal", filter_metal, "add a metallic colour effect" },
|
{ "metal", filter_metal, "add a metallic colour effect" },
|
||||||
{ "flip", filter_flip, "flip horizontally" },
|
{ "flip", filter_flip, "flip horizontally" },
|
||||||
{ "flop", filter_flop, "flip vertically" },
|
{ "flop", filter_flop, "flip vertically" },
|
||||||
|
@ -211,6 +213,29 @@ static void filter_rainbow(context_t *cx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void filter_trans(context_t *cx)
|
||||||
|
{
|
||||||
|
static unsigned char const colors[] =
|
||||||
|
{
|
||||||
|
CACA_LIGHTCYAN, CACA_LIGHTRED, CACA_WHITE, CACA_LIGHTRED, CACA_LIGHTCYAN
|
||||||
|
};
|
||||||
|
unsigned int x, y, w, h;
|
||||||
|
|
||||||
|
w = caca_get_canvas_width(cx->torender);
|
||||||
|
h = caca_get_canvas_height(cx->torender);
|
||||||
|
|
||||||
|
for(x = 0; x < w; x++)
|
||||||
|
for(y = 0; y < h; y++)
|
||||||
|
{
|
||||||
|
unsigned long int ch = caca_get_char(cx->torender, x, y);
|
||||||
|
if(ch != (unsigned char)' ')
|
||||||
|
{
|
||||||
|
caca_set_color_ansi(cx->torender, colors[(y - 2) % 5], CACA_TRANSPARENT);
|
||||||
|
caca_put_char(cx->torender, x, y, ch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void filter_flip(context_t *cx)
|
static void filter_flip(context_t *cx)
|
||||||
{
|
{
|
||||||
caca_flip(cx->torender);
|
caca_flip(cx->torender);
|
||||||
|
|
|
@ -66,6 +66,7 @@ int main(int argc, char *argv[])
|
||||||
{ "termwidth", 0, NULL, 't' },
|
{ "termwidth", 0, NULL, 't' },
|
||||||
{ "filter", 1, NULL, 'F' },
|
{ "filter", 1, NULL, 'F' },
|
||||||
{ "gay", 0, NULL, 130 },
|
{ "gay", 0, NULL, 130 },
|
||||||
|
{ "trans", 0, NULL, 160 },
|
||||||
{ "metal", 0, NULL, 131 },
|
{ "metal", 0, NULL, 131 },
|
||||||
{ "rainbow", 0, NULL, 132 },
|
{ "rainbow", 0, NULL, 132 },
|
||||||
{ "export", 1, NULL, 'E' },
|
{ "export", 1, NULL, 'E' },
|
||||||
|
@ -114,6 +115,9 @@ int main(int argc, char *argv[])
|
||||||
case 132: /* --rainbow */
|
case 132: /* --rainbow */
|
||||||
filter_add(cx, "rainbow");
|
filter_add(cx, "rainbow");
|
||||||
break;
|
break;
|
||||||
|
case 160:
|
||||||
|
filter_add(cx, "trans");
|
||||||
|
break;
|
||||||
case 'w': /* --width */
|
case 'w': /* --width */
|
||||||
cx->term_width = atoi(caca_optarg);
|
cx->term_width = atoi(caca_optarg);
|
||||||
break;
|
break;
|
||||||
|
@ -217,6 +221,7 @@ int main(int argc, char *argv[])
|
||||||
" -t, --termwidth adapt to terminal's width\n" \
|
" -t, --termwidth adapt to terminal's width\n" \
|
||||||
" -F, --filter <filters> apply one or several filters to the text\n" \
|
" -F, --filter <filters> apply one or several filters to the text\n" \
|
||||||
" -F, --filter list list available filters\n" \
|
" -F, --filter list list available filters\n" \
|
||||||
|
" --trans traaaaaaaa filter (same as -F trans)\n" \
|
||||||
" --rainbow rainbow filter (same as -F rainbow)\n" \
|
" --rainbow rainbow filter (same as -F rainbow)\n" \
|
||||||
" --metal metal filter (same as -F metal)\n" \
|
" --metal metal filter (same as -F metal)\n" \
|
||||||
" -E, --export <format> select export format\n" \
|
" -E, --export <format> select export format\n" \
|
||||||
|
|
Loading…
Reference in a new issue