Print black-and-white image to terminal in braille unicode characters.
(img, threshold=128)
| 48 | return self._grid[pos[1]][pos[0]] |
| 49 | |
| 50 | def print_image(img, threshold=128): |
| 51 | '''Print black-and-white image to terminal in braille unicode characters.''' |
| 52 | x_blocks = (img.size[0] + BW - 1) // BW |
| 53 | y_blocks = (img.size[1] + BH - 1) // BH |
| 54 | |
| 55 | for yb in range(y_blocks): |
| 56 | line = [] |
| 57 | for xb in range(x_blocks): |
| 58 | ch = BASE |
| 59 | for y in range(BH): |
| 60 | for x in range(BW): |
| 61 | try: |
| 62 | val = img.getpixel((xb * BW + x, yb * BH + y)) |
| 63 | except IndexError: |
| 64 | pass |
| 65 | else: |
| 66 | if val[0] < threshold: |
| 67 | ch |= BIT_PER_PIXEL[y][x] |
| 68 | line.append(chr(ch)) |
| 69 | print(''.join(line)) |
| 70 | |
| 71 | parser = argparse.ArgumentParser(description='Script to get coins from a faucet.', epilog='You may need to start with double-dash (--) when providing bitcoin-cli arguments.') |
| 72 | parser.add_argument('-c', '--cmd', dest='cmd', default='bitcoin-cli', help='bitcoin-cli command to use') |
no test coverage detected