Skip to content

Instantly share code, notes, and snippets.

@Legend-of-iPhoenix
Created March 10, 2018 20:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Legend-of-iPhoenix/8d1de5af5a612656d7f09567698e864d to your computer and use it in GitHub Desktop.
Save Legend-of-iPhoenix/8d1de5af5a612656d7f09567698e864d to your computer and use it in GitHub Desktop.
Enlarges ascii art.
string = document.getElementById('input').value;
/*
First string is the 'index', with escaped characters for each substitution, in order. First character = first array, second character = second array, etc.
Each array is of the format ['abc','def','ghi'], which maps to
abc
def
ghi
in the output.
*/
var substitutions = [
" /\\_-'",
[' ', ' ', ' '],
['/ ', ' / ', ' /'],
[' \\', ' \\ ', '\\ '],
['___', ' ', ' '],
[' ', '---', ' '],
[' ', '"\\ ', '\\ ']
];
substitutions = substitutions.map(x => ((typeof x) !== "string") ? [x[2], x[1], x[0]] : x)
document.getElementById('output').innerHTML = '<pre>' + string.split('\n')
.map(row => row.split('')
.map(char => substitutions[substitutions[0].indexOf(char)]))
.map(oldRow => oldRow.map(charSet => charSet ? charSet[0] : [])
.join('') + '\n' + oldRow.map(charSet => charSet ? charSet[1] : [])
.join('') + '\n' + oldRow.map(charSet => charSet ? charSet[2] : [])
.join(''))
.join('\n') + '</pre>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment