test
This commit is contained in:
parent
b1f24b17ad
commit
eb388826ac
42
main.py
42
main.py
@ -9,7 +9,12 @@ import numpy as np
|
||||
import PIL
|
||||
from dataclasses import dataclass
|
||||
|
||||
img = './b.png'
|
||||
img = './a.png'
|
||||
character = '#'
|
||||
size = (170, 200)
|
||||
# size=(4,4)
|
||||
# size=(1,1)
|
||||
|
||||
scale = 1
|
||||
windows: bool = True
|
||||
|
||||
@ -61,7 +66,7 @@ if windows:
|
||||
# text=f'{Fore.RED}TEst{Fore.RESET}'
|
||||
# pyperclip.copy(text)
|
||||
|
||||
# text=f"[2;31mred[0mred"
|
||||
# text=f"redred"
|
||||
# text2=f"{Fore.RED}red{Fore.RESET}red"
|
||||
# text3=f"{Fore.RED}red{Fore.RESET}red".encode().replace(b'\x1b[',b'\x1b[2;').decode()
|
||||
# print(text)
|
||||
@ -95,7 +100,7 @@ if windows:
|
||||
|
||||
img_data = PIL.Image.open(img)
|
||||
# print(img_data.info)
|
||||
img_data = img_data.resize((2, 2), Resampling.NEAREST)
|
||||
img_data = img_data.resize(size, Resampling.NEAREST)
|
||||
img_arr = np.array(img_data)
|
||||
h, w = img_data.size
|
||||
print(h)
|
||||
@ -124,35 +129,38 @@ for n, pxl_line in enumerate(img_arr):
|
||||
# rgb_map[n] = []
|
||||
rgb_map_line = rgb_map[n]
|
||||
for pxl in pxl_line:
|
||||
print(pxl)
|
||||
r, g, b, _ = pxl
|
||||
print(r, g, b)
|
||||
# print(pxl)
|
||||
r, g, b = pxl[:3]
|
||||
# print(r, g, b)
|
||||
_rgb = RGB(red=r, green=g, blue=b)
|
||||
print(f'>> {_rgb.__str__()}')
|
||||
rgb_map_line.append(_rgb)
|
||||
# rgb_map_line.append('[31m')
|
||||
# print(f'>> {_rgb.__str__()}')
|
||||
# rgb_map_line.append('')
|
||||
|
||||
txt = ""
|
||||
|
||||
character = '#'
|
||||
|
||||
|
||||
txt += """```ansi\n"""
|
||||
for line in rgb_map:
|
||||
for rgb in line:
|
||||
rgb: RGB
|
||||
# print(rgb)
|
||||
# txt += rgb.__hex__()
|
||||
txt += rgb
|
||||
|
||||
ansi = fg(f'#{rgb.__hex__()}')
|
||||
# print(f'>> {rgb.__str__()}')
|
||||
txt += ansi
|
||||
txt += '#'
|
||||
txt += '[39m\n'
|
||||
txt += '\n'
|
||||
txt += attr('reset')
|
||||
txt += """```"""
|
||||
print(txt)
|
||||
|
||||
pyperclip.copy(txt)
|
||||
# print(txt.encode())
|
||||
|
||||
# pyperclip.copy(txt)
|
||||
|
||||
|
||||
# x = """
|
||||
# [31mTEXT
|
||||
# FF[39m
|
||||
# TEXT
|
||||
# FF
|
||||
# """
|
||||
# print(x.encode())
|
||||
|
Loading…
x
Reference in New Issue
Block a user