Created
July 14, 2018 19:45
-
-
Save danidask/f11126a3e5220f0a9f68be37008e6ef8 to your computer and use it in GitHub Desktop.
Rotar imagenes para matriz de leds
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
# https://xantorohara.github.io/led-matrix-editor/#003f0c0c0c0c0e0c|003f33061c30331e|001e33301c30331e|0078307f33363c38|001e3330301f033f|001e33331f03061c|000c0c0c1830333f|001e33331e33331e|000e18303e33331e|003e676f7b73633e | |
caracteres= [ | |
[0,0,0,0,0,0,0,0,], | |
[0,0,0,1,1,0,0,0,], | |
[0,0,0,1,1,0,0,0,], | |
[0,0,1,1,1,0,0,0,], | |
[0,0,0,1,1,0,0,0,], | |
[0,0,0,1,1,0,0,0,], | |
[0,0,0,1,1,0,0,0,], | |
[0,1,1,1,1,1,1,0, | |
]], [ | |
[0,0,0,0,0,0,0,0,], | |
[0,0,1,1,1,1,0,0,], | |
[0,1,1,0,0,1,1,0,], | |
[0,0,0,0,0,1,1,0,], | |
[0,0,0,0,1,1,0,0,], | |
[0,0,1,1,0,0,0,0,], | |
[0,1,1,0,0,0,0,0,], | |
[0,1,1,1,1,1,1,0, | |
]] | |
def rotar(matriz): | |
nuevamatriz = [] | |
for i in range(8): | |
nuevamatriz.append([0,0,0,0,0,0,0,0]) | |
ladocuadrado = 8 | |
for i in range(ladocuadrado): | |
for j in range(ladocuadrado): | |
nuevamatriz[j][i] = matriz[i][j] | |
return nuevamatriz | |
def reflejar(caracter): | |
nuevamatriz = [] | |
for fila in caracter: | |
nuevamatriz.append(fila[::-1]) | |
return nuevamatriz | |
def formatear(caracter): | |
formateado = "" | |
for linea in caracter: | |
bbyte = "B" | |
for bbits in linea: | |
bbyte += '1' if bbits else '0' | |
formateado += bbyte + ", " | |
formateado = formateado[:-2] | |
formateado += ',' | |
return formateado | |
for caracter in caracteres: | |
caracter = rotar(caracter) | |
caracter = reflejar(caracter) | |
print(formatear(caracter)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment