A set of functions and objects for creating images using unicode braille characters. This was a very silly evening project that I decided to do one day. I hope I will have a chance to use it for some interesting ncurses UI element or something.
While looking around at examples of ncruses libraries I discovered that one can use braille characters to display images that would normally not be possible with an ncurses library because its granularity is limited to that of a single character. With this library you can translate matrices of ones and zeroes into more granular images. These functions are designed to be used in the terminal in an ncurses-type of setting. There is also functionality for coloring foreground and background of the characters with a basic set of colors.
The standard unit in this module is a Braxel (a set of 8 (4x2) pixels represented by a braille character), but there are also functions for just turning an array into an image. Braxels also have a foreground and a background color which can be black, red, green, yellow, blue, magenta, cyan, or white.
from braxels import pixmap_to_string
print(pixmap_to_str([[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0],
[0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0],
[0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0],
[0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0],
[0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0],
[0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0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