Skip to content

Instantly share code, notes, and snippets.

@chrismcfee
Last active August 29, 2015 14:12
Show Gist options
  • Select an option

  • Save chrismcfee/45892dfb0a7ce072afd2 to your computer and use it in GitHub Desktop.

Select an option

Save chrismcfee/45892dfb0a7ce072afd2 to your computer and use it in GitHub Desktop.

add-america-filter.patch

Adds a fantastically patriotic filter to toilet's repertoire.

Example usage

Usage

$ cd toilet-src/
$ patch -p1 < add-america-filter.patch
$ ./bootstrap
$ ./configure
$ make
$ sudo make install

Toilet requirements

toilet requires at least libcaca-dev to be installed.

I don't know what else it might require.

Toilet

toilet can be found at svn://svn.zoy.org/libcaca/toilet/trunk

License

I don't care, man. I guess this is released under whatever license toilet itself is under.

--- toilet-clean/src/filter.c 2014-12-24 14:04:47.715465588 -0600
+++ toilet/src/filter.c 2014-12-24 14:07:35.048748321 -0600
@@ -30,6 +30,7 @@
static void filter_crop(context_t *);
static void filter_gay(context_t *);
static void filter_metal(context_t *);
+static void filter_america(context_t *);
static void filter_flip(context_t *);
static void filter_flop(context_t *);
static void filter_180(context_t *);
@@ -48,6 +49,7 @@ const lookup[] =
{ "crop", filter_crop, "crop unused blanks" },
{ "gay", filter_gay, "add a rainbow colour effect" },
{ "metal", filter_metal, "add a metallic colour effect" },
+ { "america", filter_america, "add an american color effect (with color spelled right)" },
{ "flip", filter_flip, "flip horizontally" },
{ "flop", filter_flop, "flip vertically" },
{ "rotate", filter_180, NULL }, /* backwards compatibility */
@@ -183,6 +185,33 @@ static void filter_metal(context_t *cx)
caca_set_color_ansi(cx->torender, palette[i], CACA_TRANSPARENT);
caca_put_char(cx->torender, x, y, ch);
}
+}
+
+static void filter_america(context_t *cx)
+{
+ static unsigned char const palette[] =
+ {
+ CACA_RED, CACA_WHITE, CACA_BLUE,
+ };
+
+ unsigned int x, y, w, h;
+
+ w = caca_get_canvas_width(cx->torender);
+ h = caca_get_canvas_height(cx->torender);
+
+ for(y = 0; y < h; y++)
+ for(x = 0; x < w; x++)
+ {
+ unsigned long int ch = caca_get_char(cx->torender, x, y);
+ int i;
+
+ if(ch == (unsigned char)' ')
+ continue;
+
+ i = ((cx->lines + y + x / 8) / 2) % 3;
+ caca_set_color_ansi(cx->torender, palette[i], CACA_TRANSPARENT);
+ caca_put_char(cx->torender, x, y, ch);
+ }
}
static void filter_gay(context_t *cx)
--- toilet-clean/bootstrap 2014-12-24 14:04:48.115449517 -0600
+++ toilet/bootstrap 2014-12-24 14:04:57.431075575 -0600
@@ -36,7 +36,7 @@ aclocalflags="`sed -ne 's/^[ \t]*ACLOCAL
# Check for automake
amvers="no"
-for v in 13 12 11 10 9 8 7 6 5; do
+for v in 14 13 12 11 10 9 8 7 6 5; do
if automake-1.${v} --version >/dev/null 2>&1; then
amvers="-1.${v}"
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment