Original Usenet thread from rec.arts.ascii, started 3 Mar 1995.
_ _ _ _ _ _ | | | |___ ___ _ __ ___| |_ / \ _ __ ___| |__ (_)_ _____ | | | / __|/ _ \ '_ \ / _ \ __| / _ \ | '__/ __| '_ \| \ \ / / _ \ | |_| \__ \ __/ | | | __/ |_ / ___ \| | | (__| | | | |\ V / __/ \___/|___/\___|_| |_|\___|\__| /_/ \_\_| \___|_| |_|_| \_/ \___|
SOURCE: ASCIItrans, ASCII transformation filter
rec.arts.ascii
· 1 message · 3 Mar 1995
This is my third attempt at posting this in as many days - not
a sign of the other two attempts on the normally fast server
here, so I'm trying again!
This program will intelligently rotate90,180,270, flip, mirror, and
doublesize ASCII art. Give it a whirl.
--Adam.
/*************************************************************
asctrans.c - An ASCII art transformation filter.
Copyright (C) 1995 Adam D. Moss
Author:
Adam Moss, mos...@essex.ac.uk (preferred) or
asp...@catnip.cfs.purdue.edu
To compile:
cc asctrans.c -o asctrans
Portability:
Unlikely to compile under DOS because of my 1 Mb static
array. :)
Notes:
Geared towards ASCII art, does not work well on text.
Inspired by Alex Butcher.
Dedicated to Mike Jittlov - wizard, filmmaker, and ASCII
artist!
Usage:
For usage instructions, invoke program with no
parameters.
Revision history:
v1.01: 95.02.28:
Initial release.
License:
Copyright (C) 1995 Adam D. Moss
This program is free software; you can redistribute it
and/or modify it under the terms of the GNU General
Public License as published by the Free Software
Foundation; either version 2 of the License, or (at
your option) any later version.
This program is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public
License for more details. A copy of the GNU General
Public License may be obtained from the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
USA.
Have fun! :)
*************************************************************/
#include <stdlib.h>
#include <stdio.h>
char line[1000][1000]; /* This sucks. :) */
int linecount,linewid,eof,x,c,y;
int optype,filter,doublesize;
char dou[5];
/* operations */
#define NONE 0
#define VERTFLIP 1
#define HORIZFLIP 2
#define ROT90 3
#define ROT180 4
#define ROT270 5
#define TRUE 1
#define FALSE 0
void printusage(char *argv[])
{
puts(" /| // // || || version 1.01: 2/95");
puts(" //| \\\\ << || || T R A N S (C) 1995 Adam Moss");
puts("// | // \\\\ || || mos...@essex.ac.uk\n");
puts("Usage:");
printf(" %s [v|h|1|2|3][n][d]\n",argv[0]);
puts("Example:");
printf(" %s 1d <~/.signature\n",argv[0]);
puts("Options:");
puts(" v: Vertical flip");
puts(" h: Horizontal flip");
puts(" 1: 1/4 rotation clockwise");
puts(" 2: 2/4 rotation clockwise");
puts(" 3: 3/4 rotation clockwise");
puts(" n: No character changes");
puts(" d: Doublesize image\n");
exit(-1);
}
void doargs(int argc,char *argv[])
{
int i;
doublesize = FALSE;
optype = NONE;
filter = TRUE;
if (argc!=2) printusage(argv);
for (i=0;i<strlen(argv[1]);i++)
{
switch(argv[1][i])
{
case 'v':
case 'V': optype=VERTFLIP; break;
case 'h':
case 'H': optype=HORIZFLIP; break;
case '1': optype=ROT90; break;
case '2': optype=ROT180; break;
case '3': optype=ROT270; break;
case 'd':
case 'D': doublesize=TRUE; break;
case 'n':
case 'N': filter=FALSE; break;
default:
{
printf("Unknown switch.\n\n");
printusage(argv);
}
}
}
}
void finddouble(char c)
{
switch(c)
{
case '<': strcpy(dou," /\\ ");break;
case '>': strcpy(dou,"\\ /");break;
case '^': strcpy(dou,"/\\ ");break;
case 'v': strcpy(dou," \\/");break;
case 'V': strcpy(dou,"||\\/");break;
case '/': strcpy(dou," // ");break;
case '\\': strcpy(dou,"\\ \\");break;
case '_': strcpy(dou," __");break;
case '-': strcpy(dou,"__ ");break;
case '~': strcpy(dou,"~~ ");break;
case ',': strcpy(dou," / ");break;
case '`': strcpy(dou,"\\ ");break;
case '\'': strcpy(dou," / ");break;
case '"': strcpy(dou,"|| ");break;
case '.': strcpy(dou," . ");break;
case 'o': strcpy(dou," ()");break;
case 'O': strcpy(dou,"/\\\\/");break;
case 'X': strcpy(dou,"\\//\\");break;
case 'x': strcpy(dou," ><");break;
case '(': strcpy(dou," ( (");break;
case ')': strcpy(dou,") ) ");break;
case ':': strcpy(dou,": : ");break;
case ';': strcpy(dou,": ; ");break;
case '|': strcpy(dou,"| | ");break;
case '+': strcpy(dou,"|_| ");break;
case '=': strcpy(dou,"----");break;
case '%': strcpy(dou,"o//o");break;
case '!': strcpy(dou,"| . ");break;
case '{': strcpy(dou," { {");break;
case '}': strcpy(dou,"} } ");break;
case '[': strcpy(dou," [ [");break;
case ']': strcpy(dou,"] ] ");break;
case 'U': strcpy(dou,"|L|J");break;
case 'L': strcpy(dou,"| L_");break;
case 'C': strcpy(dou,"(~(_");break;
case 'c': strcpy(dou," _(_");break;
case 'n': strcpy(dou,"__||");break;
case 'd': strcpy(dou,"_|L_");break;
case 'D': strcpy(dou,"~|L|");break;
case 'i': strcpy(dou,": | ");break;
case 'I': strcpy(dou,"I I ");break;
case '0': strcpy(dou,"/\\\\/");break;
case 'Z': strcpy(dou,"_//_");break;
case 'N': strcpy(dou,"|\\||");break;
case '8': strcpy(dou,"()()");break;
case 'r': strcpy(dou,"/-| ");break;
case 'm': strcpy(dou," nn");break;
case 'w': strcpy(dou," uu");break;
case 'W': strcpy(dou,"||VV");break;
case 'M': strcpy(dou,"^^||");break;
case 'l': strcpy(dou,"l l ");break;
case 'P': strcpy(dou,"|\\|~");break;
case 'u': strcpy(dou,"|| ");break;
default: dou[0]=dou[1]=dou[2]=dou[3]=c;
}
}
void doubleup(void)
{
linewid*=2;
linecount*=2;
if (filter==FALSE) for (y=linecount-1;y>=0;y--)
for (x=linewid-1;x>=0;x--)
{
line[x*2][y*2]=line[x][y];
line[1+x*2][y*2]=line[x][y];
line[x*2][1+y*2]=line[x][y];
line[1+x*2][1+y*2]=line[x][y];
}
else for (y=linecount-1;y>=0;y--)
for (x=linewid-1;x>=0;x--)
{
finddouble(line[x][y]);
line[x*2][y*2]=dou[0];;
line[1+x*2][y*2]=dou[1];
line[x*2][1+y*2]=dou[2];
line[1+x*2][1+y*2]=dou[3];
}
}
char mirror(char c)
{
switch (c)
{
case '(': return(')');
case ')': return('(');
case '[': return(']');
case ']': return('[');
case '/': return('\\');
case '\\': return('/');
case '{': return('}');
case '}': return('{');
case '\'': return('`');
case '`': return('\'');
case 'd': return('b');
case 'b': return('d');
case 'Q': return('O');
case ',': return('.');
case ';': return(':');
case '<': return('>');
case '>': return('<');
case 'p': return('q');
case 'q': return('p');
case '2': return('S');
case 'S': return('2');
default: return(c);
}
}
char flip(char c)
{
switch (c)
{
case '_': return('~');
case '~': return('_');
case ',': return('`');
case '`': return(',');
case '/': return('\\');
case '\\': return('/');
case '\'': return('.');
case '"': return(',');
case 'P': return('b');
case 'b': return('p');
case 'p': return('b');
case 'v': return('^');
case '^': return('v');
case 'q': return('d');
case 'd': return('q');
case '.': return('\'');
case 'U': return('n');
case 'n': return('u');
case 'u': return('n');
case 'Q': return('O');
case 'W': return('M');
case 'M': return('W');
case 'w': return('m');
case 'm': return('w');
case 'A': return('V');
case 'V': return('A');
case '?': return('j');
case 'j': return('?');
case ';': return(':');
case '2': return('5');
case '5': return('2');
default: return(c);
}
}
char rot90(char c)
{
switch (c)
{
case '_': return('|');
case '~': return('|');
case '-': return('|');
case '|': return('-');
case '/': return('\\');
case '\\': return('/');
case '(': return('-');
case ')': return('-');
case '!': return('-');
case '<': return('^');
case '^': return('>');
case '>': return('V');
case '=': return('H');
case 'H': return('=');
case 'Q': return('O');
case ':': return('-');
case ';': return('-');
case '{': return('-');
case '}': return('-');
case '3': return('W');
case 'W': return('E');
case 'E': return('M');
case 'M': return('3');
case 'A': return('>');
case 'V': return('<');
case 'v': return('<');
case 'c': return('n');
case 'u': return('c');
case '"': return(':');
case 'Z': return('N');
case 'N': return('Z');
case ',': return('`');
case '`': return('\'');
case '\'': return('.');
case '.': return(',');
case 'i': return('-');
case '1': return('-');
case 'l': return('-');
default: return(c);
}
}
char rot180(char c)
{
/* Just an approximation for now */
return(flip(mirror(c)));
}
char rot270(char c)
{
/* Another approximation, even worse :) */
return(rot90(rot180(c)));
}
void main(int argc,char *argv[])
{
doargs(argc,argv);
linecount=0; linewid=1; x=0;
while (1)
{
c=getchar();
if ((c=='\n')||(c==EOF))
{
if (x>linewid) linewid=x;
for (;x<1000;x++) line[x][linecount]=' ';
linecount++;
if (c==EOF) break;
x=0;
}
else
{
line[x++][linecount]=(char)c;
}
}
if (doublesize==TRUE) doubleup();
if (filter==TRUE)
{
for (y=0;y<linecount;y++)
{
for (x=0;x<linewid;x++)
{
switch (optype)
{
case VERTFLIP: line[x][y]=flip(line[x][y]); break;
case HORIZFLIP: line[x][y]=mirror(line[x][y]); break;
case ROT90: line[x][y]=rot90(line[x][y]); break;
case ROT180: line[x][y]=rot180(line[x][y]); break;
case ROT270: line[x][y]=rot270(line[x][y]); break;
}
}
}
}
switch (optype)
{
case NONE:
for (y=0;y<linecount;y++)
{
for (x=0;x<linewid;x++)
{
putchar(line[x][y]);
}
putchar('\n');
};break;
case VERTFLIP:
for (y=linecount-1;y>=0;y--)
{
for (x=0;x<linewid;x++)
{
putchar(line[x][y]);
}
putchar('\n');
};break;
case HORIZFLIP:
for (y=0;y<linecount;y++)
{
for (x=linewid-1;x>=0;x--)
{
putchar(line[x][y]);
}
putchar('\n');
};break;
case ROT90:
for (x=0;x<linewid;x++)
{
for (y=linecount-1;y>=0;y--)
{
putchar(line[x][y]);
}
putchar('\n');
};break;
case ROT180:
for (y=linecount-1;y>=0;y--)
{
for (x=linewid-1;x>=0;x--)
{
putchar(line[x][y]);
}
putchar('\n');
};break;
case ROT270:
for (x=linewid-1;x>=0;x--)
{
for (y=0;y<linecount;y++)
{
putchar(line[x][y]);
}
putchar('\n');
};break;
}
}
--
PGP key & stuff: http://cswww2.essex.ac.uk/Web/mossap.html
|\ /| ------------------------------------------------
/| \_/_| Adam D. Moss mos...@essex.ac.uk
__--|\_/ _\ ------------------------------------------------
/_ (o \___o "A smartass once accused me of being subtle. I
/_ ----= / decked him with a short right over the heart and
/__ \ -----' an elbow in the trachea." - Harlan Ellison
\ // ------------------------------------------------
_/ And the men looked up in wonder
__/_/ And the hounds ran back to hide
/_-/ For the fox had changed to the Devil himself
Where he stood on the other side
Related ASCII art in the Gallery
Explore these categories from our collection of 11,000+ artworks:
Make your own ASCII art
Turn images, text or 3D into ASCII, or draw your own – right in your browser.
About this thread.
These messages were posted publicly to the newsgroup
rec.arts.ascii
in 1995 and are mirrored here unchanged as part of the Historic Archives – only email addresses are masked.
The artwork and text belong to their original authors: if you copy a piece, keep the artist's initials or signature intact and credit them where you can.
Are you one of the authors? Contact us to get your posts attributed, connected to your artist profile, or removed.
Report this message
Help us keep the archive clean and accurate. Reports are reviewed by a person – nothing is changed automatically.