From 3bdbfdc1c86bdb72ce4ee33160abedd7cc128ce2 Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Mon, 16 Jul 2018 14:14:52 -0400 Subject: Add -m option to glitch --- bin/README | 1 + bin/glitch.c | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/README b/bin/README index 0ea3970a..3e53eba2 100644 --- a/bin/README +++ b/bin/README @@ -76,6 +76,7 @@ PNG glitcher based on pngo. -r reconstruct when filtering -d LIST declare pattern of comma-separated filters -a LIST apply pattern of comma-separated filters + -m mirror scanlines after filtering hnel diff --git a/bin/glitch.c b/bin/glitch.c index 3d58fa33..f62ee1fc 100644 --- a/bin/glitch.c +++ b/bin/glitch.c @@ -276,6 +276,7 @@ static struct { uint8_t applyFilter; enum Filter declareFilters[255]; enum Filter applyFilters[255]; + bool mirror; } options; struct Bytes { @@ -396,6 +397,16 @@ static void filterData(void) { } } +static void mirror(void) { + for (uint32_t y = 0; y < header.height; ++y) { + for (size_t i = 0, j = lineSize() - 1; i < j; ++i, --j) { + uint8_t t = lines[y]->data[i]; + lines[y]->data[i] = lines[y]->data[j]; + lines[y]->data[j] = t; + } + } +} + static void glitch(const char *inPath, const char *outPath) { if (inPath) { path = inPath; @@ -415,6 +426,7 @@ static void glitch(const char *inPath, const char *outPath) { scanlines(); reconData(); filterData(); + if (options.mirror) mirror(); free(lines); if (outPath) { @@ -462,7 +474,7 @@ int main(int argc, char *argv[]) { char *output = NULL; int opt; - while (0 < (opt = getopt(argc, argv, "a:cd:fo:pr"))) { + while (0 < (opt = getopt(argc, argv, "a:cd:fmo:pr"))) { switch (opt) { break; case 'a': options.applyFilter = parseFilters(options.applyFilters, optarg); @@ -470,6 +482,7 @@ int main(int argc, char *argv[]) { break; case 'd': options.declareFilter = parseFilters(options.declareFilters, optarg); break; case 'f': options.filt = true; + break; case 'm': options.mirror = true; break; case 'o': output = optarg; break; case 'p': options.brokenPaeth = true; break; case 'r': options.recon = true; -- cgit 1.4.1 1&showmsg=1&follow=1'>cgram (unfollow)
Commit message (Collapse)Author
2019-04-19Simplify ENV default value in catsh.1June McEnroe
2019-04-18Factor out XDG_CONFIG_HOME and XDG_DATA_HOMEJune McEnroe
2019-04-18Clean up catsh configJune McEnroe
2019-04-18Rename cash config to catshJune McEnroe
2019-04-18Rename cash to catshJune McEnroe
2019-04-15Color python imports as StatementJune McEnroe
2019-04-13Add The Demolished ManJune McEnroe
2019-04-07Add AmatkaJune McEnroe
2019-04-03Add Space OperaJune McEnroe
2019-03-22Add An Unkindness of GhostsJune McEnroe
2019-03-14Highlight line continuations in line commentsJune McEnroe
2019-03-14Add The Long Way to a Small Angry PlanetJune McEnroe
2019-03-10Add Bleachers Tiny Desk ConcertJune McEnroe
2019-02-28Add Station ElevenJune McEnroe
2019-02-27Use getsubopt(3) to parse -o options in hiJune McEnroe
2019-02-27Add type and ulimit shell keywordsJune McEnroe
2019-02-27Fix make target pattern whitespace in hiJune McEnroe
2019-02-27Delete extraneous <pre> in html.shJune McEnroe
2019-02-24Use setopt in upJune McEnroe
2019-02-24Add setoptJune McEnroe
2019-02-20Match make targets as TagJune McEnroe
2019-02-20Use $PWD in html.sh to pass absolute path to manJune McEnroe
2019-02-20Factor out html.sh and produce html for all sourcesJune McEnroe
Except for gfx-cocoa because I don't have an Objective-C highlighter. Also hypothetically the .h rule could match up headers with .3 manual pages if I cared to write them.
2019-02-20Add Dirk Gently's Holistic Detective AgencyJune McEnroe
2019-02-20Move /opt/pkg after /usr in PATHJune McEnroe
Installing mandoc from pkgsrc also installs a man executable which is horribly broken. Keep using the system man.
2019-02-20Set man_hard_wrap in nvimJune McEnroe
Vendoring man.vim until <https://github.com/neovim/neovim/pull/9633> is merged and appears in a release.
2019-02-18Use hi -o anchor in upJune McEnroe
2019-02-18Don't match nested parentheses in Tag for CJune McEnroe
Fixes mistaken highlight of: pngWrite(file, (uint8_t []) { 0, 0, 0 }, 3);
2019-02-18Match whitespace between * [] {}June McEnroe
2019-02-18Fix function-like #define regexJune McEnroe
A define like #define FOO (1) is not function-like.
2019-02-18Match Tag in RustJune McEnroe
2019-02-18Match sh functions as TagJune McEnroe
2019-02-18Match Sh and Ss as Tag in mdocJune McEnroe
2019-02-18Match statics and typedefs as TagJune McEnroe
2019-02-18Clean up htmlHeaderJune McEnroe
2019-02-18Remove hi line numberingJune McEnroe
Tags are much better for referring to specific parts of a file and line numbering is better done by a post-processing tool such as cat -n or producing a two-column HTML <table>.
2019-02-18Add Tag class to hiJune McEnroe
2019-02-17Generate HTML with hi -n -f html -o anchorJune McEnroe
Running hi twice to insert stuff between the head and the content is a bit of a hack but oh well.
2019-02-17Add hi -f html -o anchor for line number linksJune McEnroe
2019-02-17Simplify temp trap in upJune McEnroe
2019-02-17Add line numbers to hiJune McEnroe
Renames previous -n option to -m to stay consistent with cat -n. Prefixing lines with line numbers affects where the first tab indent ends up relative to the text above it. Not sure if it's worth fixing somehow.
2019-02-17Always split spans after newlinesJune McEnroe
Simplifies ANSI and IRC output code, and prepares for line numbered output.
2019-02-15Color format specifiers light cyan in vimJune McEnroe
2019-02-15Highlight Interp as yellowJune McEnroe
2019-02-15Highlight strings in sh command substitutionsJune McEnroe
2019-02-15Add nmap gpJune McEnroe
2019-02-14Avoid newline when copying URL to pasteboardJune McEnroe
2019-02-13Add forgotten "sixth" book of H2G2June McEnroe