Last active
March 7, 2018 13:23
-
-
Save JohannesFischer/1955e2820cade1ef64e7ffd7398cb2a7 to your computer and use it in GitHub Desktop.
Prints block letters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const letters = { | |
a: [ | |
0, 1, 1, 1, 0, | |
1, 0, 0, 0, 1, | |
1, 1, 1, 1, 1, | |
1, 0, 0, 0, 1, | |
1, 0, 0, 0, 1 | |
], | |
b: [ | |
1, 1, 1, 1, 0, | |
1, 0, 0, 0, 1, | |
1, 1, 1, 1, 1, | |
1, 0, 0, 0, 1, | |
1, 1, 1, 1, 0 | |
], | |
c: [ | |
0, 1, 1, 1, 1, | |
1, 0, 0, 0, 0, | |
1, 0, 0, 0, 0, | |
1, 0, 0, 0, 0, | |
0, 1, 1, 1, 1 | |
], | |
d: [ | |
1, 1, 1, 1, 0, | |
1, 0, 0, 0, 1, | |
1, 0, 0, 0, 1, | |
1, 0, 0, 0, 1, | |
1, 1, 1, 1, 0 | |
], | |
e: [ | |
1, 1, 1, 1, 1, | |
1, 0, 0, 0, 0, | |
1, 1, 1, 0, 0, | |
1, 0, 0, 0, 0, | |
1, 1, 1, 1, 1 | |
], | |
f: [ | |
1, 1, 1, 1, 1, | |
1, 0, 0, 0, 0, | |
1, 1, 1, 1, 0, | |
1, 0, 0, 0, 0, | |
1, 0, 0, 0, 0 | |
], | |
g: [ | |
0, 1, 1, 1, 0, | |
1, 0, 0, 0, 0, | |
1, 0, 1, 1, 1, | |
1, 0, 0, 0, 1, | |
0, 1, 1, 1, 0 | |
], | |
h: [ | |
1, 0, 0, 0, 1, | |
1, 0, 0, 0, 1, | |
1, 1, 1, 1, 1, | |
1, 0, 0, 0, 1, | |
1, 0, 0, 0, 1 | |
], | |
i: [ | |
1, 1, 1, 1, 1, | |
0, 0, 1, 0, 0, | |
0, 0, 1, 0, 0, | |
0, 0, 1, 0, 0, | |
1, 1, 1, 1, 1 | |
], | |
j: [ | |
1, 1, 1, 1, 1, | |
0, 0, 0, 0, 1, | |
0, 0, 0, 0, 1, | |
1, 0, 0, 0, 1, | |
0, 1, 1, 1, 0, | |
], | |
k: [ | |
1, 0, 0, 0, 1, | |
1, 0, 0, 1, 0, | |
1, 1, 1, 1, 0, | |
1, 0, 0, 1, 0, | |
1, 0, 0, 0, 1 | |
], | |
l: [ | |
1, 0, 0, 0, 0, | |
1, 0, 0, 0, 0, | |
1, 0, 0, 0, 0, | |
1, 0, 0, 0, 0, | |
1, 1, 1, 1, 1 | |
], | |
m: [ | |
1, 0, 0, 0, 1, | |
1, 1, 0, 1, 1, | |
1, 0, 1, 0, 1, | |
1, 0, 0, 0, 1, | |
1, 0, 0, 0, 1 | |
], | |
n: [ | |
1, 0, 0, 0, 1, | |
1, 1, 0, 0, 1, | |
1, 0, 1, 0, 1, | |
1, 0, 0, 1, 1, | |
1, 0, 0, 0, 1 | |
], | |
o: [ | |
0, 1, 1, 1, 0, | |
1, 0, 0, 0, 1, | |
1, 0, 0, 0, 1, | |
1, 0, 0, 0, 1, | |
0, 1, 1, 1, 0 | |
], | |
p: [ | |
1, 1, 1, 1, 0, | |
1, 0, 0, 0, 1, | |
1, 1, 1, 1, 0, | |
1, 0, 0, 0, 0, | |
1, 0, 0, 0, 0 | |
], | |
q: [ | |
0, 1, 1, 1, 0, | |
1, 0, 0, 0, 1, | |
1, 0, 0, 0, 1, | |
1, 0, 0, 1, 0, | |
0, 1, 1, 1, 1 | |
], | |
r: [ | |
1, 1, 1, 1, 0, | |
1, 0, 0, 0, 1, | |
1, 1, 1, 1, 0, | |
1, 0, 0, 1, 0, | |
1, 0, 0, 0, 1 | |
], | |
s: [ | |
0, 1, 1, 1, 0, | |
1, 0, 0, 0, 0, | |
0, 1, 1, 1, 0, | |
0, 0, 0, 0, 1, | |
0, 1, 1, 1, 0 | |
], | |
t: [ | |
1, 1, 1, 1, 1, | |
0, 0, 1, 0, 0, | |
0, 0, 1, 0, 0, | |
0, 0, 1, 0, 0, | |
0, 0, 1, 0, 0, | |
], | |
u: [ | |
1, 0, 0, 0, 1, | |
1, 0, 0, 0, 1, | |
1, 0, 0, 0, 1, | |
1, 0, 0, 0, 1, | |
0, 1, 1, 1, 0 | |
], | |
v: [ | |
1, 0, 0, 0, 1, | |
1, 0, 0, 0, 1, | |
1, 0, 0, 0, 1, | |
0, 1, 0, 1, 0, | |
0, 0, 1, 0, 0 | |
], | |
w: [ | |
1, 0, 0, 0, 1, | |
1, 0, 0, 0, 1, | |
1, 0, 1, 0, 1, | |
1, 0, 1, 0, 1, | |
0, 1, 0, 1, 0 | |
], | |
x: [ | |
1, 0, 0, 0, 1, | |
0, 1, 0, 1, 0, | |
0, 1, 1, 1, 0, | |
0, 1, 0, 1, 0, | |
1, 0, 0, 0, 1 | |
], | |
y: [ | |
1, 0, 0, 0, 1, | |
1, 0, 0, 0, 1, | |
0, 1, 0, 1, 0, | |
0, 0, 1, 0, 0, | |
0, 0, 1, 0, 0 | |
], | |
z: [ | |
1, 1, 1, 1, 1, | |
0, 0, 0, 1, 0, | |
0, 0, 1, 0, 0, | |
0, 1, 0, 0, 0, | |
1, 1, 1, 1, 1, | |
] | |
}; | |
const blocksPerLetter = 5; | |
const rows = letters.a.length / blocksPerLetter; | |
const word = 'abcdefghijklmnopqrstuvwxyz'; | |
const blocks = []; | |
const separator = ' '; | |
const wordAr = word.toLowerCase().split(''); | |
for (let r = 0; r < rows; r++) { | |
for (let i = 0; i < word.length; i++) { | |
const start = r * blocksPerLetter; | |
const letter = letters[wordAr[i]]; | |
blocks.push(...letter.slice(start, start + blocksPerLetter)); | |
} | |
} | |
let str = ''; | |
for (let i = 0; i < blocks.length; i++) { | |
str += blocks[i] ? '█' : ' '; | |
if ((i + 1) % blocksPerLetter === 0) str += separator; | |
if ((i + 1) % (word.length * blocksPerLetter) === 0) str += '\n'; | |
} | |
console.log(str); |
Author
JohannesFischer
commented
Mar 7, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment