Skip to content

Instantly share code, notes, and snippets.

@GGLinnk
Created October 15, 2020 19:13
Show Gist options
  • Save GGLinnk/e165c0b096e4478d56be7e00ffcf31c2 to your computer and use it in GitHub Desktop.
Save GGLinnk/e165c0b096e4478d56be7e00ffcf31c2 to your computer and use it in GitHub Desktop.
HEXACELS Font for hexagons outputs by GGLinnk
import copy
letters = {
"A" : {
"Width" : 4,
"Matrix" : [
[0, 1, 1, 0],
[1, 0, 1, 0],
[1, 1, 1, 1],
[1, 0, 1, 0],
[1, 0, 0, 1]
],
"Alt" : None
},
"B" : {
"Width" : 3,
"Matrix" : [
[1, 1, 1],
[1, 0, 1],
[1, 1, 1],
[1, 0, 1],
[1, 1, 1]
],
"Alt" : None
},
"C" : {
"Width" : 3,
"Matrix" : [
[0, 1, 1],
[1, 0, 1],
[1, 0, 0],
[1, 0, 1],
[0, 1, 1]
],
"Alt" : None
},
"D" : {
"Width" : 4,
"Matrix" : [
[1, 1, 1, 0],
[1, 0, 1, 0],
[1, 0, 0, 1],
[1, 0, 1, 0],
[1, 1, 1, 0],
],
"Alt" : None
},
"E" : {
"Width" : 3,
"Matrix" : [
[1, 1, 1],
[1, 0, 0],
[1, 1, 0],
[1, 0, 0],
[1, 1, 1]
],
"Alt" : None
},
"F" : {
"Width" : 3,
"Matrix" : [
[1, 1, 1],
[1, 0, 0],
[1, 1, 0],
[1, 0, 0],
[1, 0, 0]
],
"Alt" : None
},
"G" : {
"Width" : 4,
"Matrix" : [
[1, 1, 1, 1],
[1, 0, 0, 0],
[1, 0, 1, 1],
[1, 0, 0, 1],
[1, 1, 1, 1]
],
"Alt" : None
},
"H" : {
"Width" : 5,
"Matrix" : [
[0, 1, 0, 0, 1],
[1, 0, 0, 0, 1],
[0, 1, 1, 1, 1],
[1, 0, 0, 0, 1],
[0, 1, 0, 0, 1]
],
"Alt" : None
},
"I" : {
"Width" : 4,
"Matrix" : [
[1, 1, 1, 1],
[0, 1, 0, 0],
[0, 1, 1, 0],
[0, 1, 0, 0],
[1, 1, 1, 1]
],
"Alt" : None
},
"J" : {
"Width" : 4,
"Matrix" : [
[0, 1, 1, 1],
[0, 0, 1, 0],
[0, 1, 0, 1],
[1, 0, 1, 0],
[0, 1, 1, 1]
],
"Alt" : None
},
"K" : {
"Width" : 4,
"Matrix" : [
[1, 1, 0, 1],
[1, 0, 1, 0],
[1, 1, 1, 0],
[1, 0, 1, 0],
[1, 1, 0, 1]
],
"Alt" : None
},
"L" : {
"Width" : 3,
"Matrix" : [
[1, 0, 0],
[1, 0, 0],
[1, 0, 0],
[1, 0, 0],
[1, 1, 1]
],
"Alt" : None
},
"M" : {
"Width" : 5,
"Matrix" : [
[1, 1, 0, 1, 1],
[1, 1, 1, 1, 0],
[1, 0, 1, 0, 1],
[1, 0, 0, 1, 0],
[1, 0, 0, 0, 1]
],
"Alt" : None
},
"N" : {
"Width" : 5,
"Matrix" : [
[1, 1, 0, 0, 1],
[1, 1, 0, 1, 0],
[1, 0, 1, 0, 1],
[1, 0, 1, 1, 0],
[1, 0, 0, 1, 1]
],
"Alt" : None
},
"O" : {
"Width" : 5,
"Matrix" : [
[0, 1, 1, 1, 0],
[1, 0, 0, 1, 0],
[1, 0, 0, 0, 1],
[1, 0, 0, 1, 0],
[0, 1, 1, 1, 0]
],
"Alt" : None
},
"P" : {
"Width" : 3,
"Matrix" : [
[1, 1, 1],
[1, 0, 1],
[1, 1, 1],
[1, 0, 0],
[1, 0, 0]
],
"Alt" : None
},
"Q" : {
"Width" : 5,
"Matrix" : [
[0, 1, 1, 1, 0],
[1, 0, 0, 1, 0],
[1, 0, 0, 0, 1],
[1, 0, 1, 1, 0],
[0, 1, 1, 1, 1]
],
"Alt" : None
},
"R" : {
"Width" : 4,
"Matrix" : [
[1, 1, 1, 0],
[1, 0, 1, 0],
[1, 1, 1, 0],
[1, 0, 1, 0],
[1, 0, 0, 1]
],
"Alt" : None
},
"S" : {
"Width" : 3,
"Matrix" : [
[0, 1, 1],
[1, 0, 0],
[0, 1, 1],
[0, 0, 1],
[0, 1, 1]
],
"Alt" : None
},
"T" : {
"Width" : 4,
"Matrix" : [
[1, 1, 1, 1],
[0, 1, 0, 0],
[0, 1, 1, 0],
[0, 1, 0, 0],
[0, 1, 1, 0]
],
"Alt" : {
"Width" : 5,
"Matrix" : [
[1, 1, 1, 1, 1],
[0, 1, 1, 0, 0],
[0, 0, 1, 0, 0],
[0, 1, 1, 0, 0],
[0, 0, 1, 0, 0]
]
}
},
"U" : {
"Width" : 4,
"Matrix" : [
[1, 0, 0, 1],
[1, 0, 1, 0],
[1, 0, 0, 1],
[1, 0, 1, 0],
[1, 1, 1, 1]
],
"Alt" : None
},
"V" : {
"Width" : 4,
"Matrix" : [
[1, 0, 0, 1],
[1, 0, 1, 0],
[1, 0, 0, 1],
[1, 0, 1, 0],
[0, 1, 1, 0]
],
"Alt" : {
"Width" : 5,
"Matrix" : [
[1, 0, 0, 0, 1],
[1, 0, 0, 1, 0],
[0, 1, 0, 1, 0],
[0, 1, 1, 0, 0],
[0, 0, 1, 0, 0]
]
}
},
"W" : {
"Width" : 5,
"Matrix" : [
[1, 0, 0, 0, 1],
[1, 0, 0, 1, 0],
[1, 0, 1, 0, 1],
[1, 1, 1, 1, 0],
[0, 1, 0, 1, 0]
],
"Alt" : None
},
"X" : {
"Width" : 4,
"Matrix" : [
[1, 0, 0, 1],
[1, 0, 1, 0],
[0, 1, 1, 0],
[1, 0, 1, 0],
[1, 0, 0, 1]
],
"Alt" : {
"Width" : 5,
"Matrix" : [
[1, 0, 0, 0, 1],
[1, 0, 0, 1, 0],
[0, 1, 1, 1, 0],
[1, 0, 0, 1, 0],
[1, 0, 0, 0, 1]
]
}
},
"Y" : {
"Width" : 3,
"Matrix" : [
[1, 0, 1],
[1, 1, 0],
[0, 1, 0],
[1, 0, 0],
[1, 0, 0]
],
"Alt" : None
},
"Z" : {
"Width" : 3,
"Matrix" : [
[1, 1, 1],
[0, 1, 0],
[0, 1, 0],
[1, 0, 0],
[1, 1, 1]
],
"Alt" : {
"Width" : 4,
"Matrix" : [
[1, 1, 1, 1],
[0, 0, 1, 0],
[0, 1, 1, 0],
[1, 0, 0, 0],
[1, 1, 1, 1]
],
"Alt" : {
"Width" : 5,
"Matrix" : [
[1, 1, 1, 1, 1],
[0, 0, 0, 1, 0],
[0, 1, 1, 1, 0],
[1, 0, 0, 0, 0],
[1, 1, 1, 1, 1]
]
}
}
}
}
def matrix_create(array):
i = 0
j = 0
str_print = [
[" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", '\n'],
[" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", '\n'],
[" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", '\n'],
[" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", '\n'],
[" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", '\n']
]
for array_element in array:
if (i % 2) != 0:
j += 1
for element in array_element:
if element == 1:
str_print[i][j] = "#"
j += 2
i += 1
j = 0
return [e for sl in str_print for e in sl]
def print_letter(letter : str, alt : bool = 0):
letter.upper()
result = [[]]
if letter in list(letters):
if (alt is True) and (letters[letter]["Alt"] is not None):
result = matrix_create(letters[letter]["Alt"]["Matrix"])
else:
result = matrix_create(letters[letter]["Matrix"])
print(''.join(result))
else:
print("Unsupported Letter !")
def print_str(string : str, alt : bool = 0):
for letter in string:
print_letter(letter, alt)
@GGLinnk
Copy link
Author

GGLinnk commented Oct 15, 2020

It's still a work in progress "font", it will be used for my Twitch Animated Background, to show text & numbers !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment