open in
main.py
```1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
```
```import time
#print('\033[?25l')
class sixel():
def __init__(self):
print('\033Pq')
self.colors = []
self.data = ''

self.setcol(0,0,0)
self.draw_column('111111')
self.draw_column('111111')
self.draw_column('111111')
self.draw_column('111111')
self.draw_column('111111')
self.draw_column('111111')
self.data+='\$'

def setcol(self,r,g,b,newblock=False):
if not newblock:
self.data+='\$'
r,g,b=int(r/2.55),int(g/2.55),int(b/2.55)
if (r,g,b) in self.colors:
colorid = self.colors.index((r,g,b))
else:
self.colors.append((r,g,b))
colorid = len(self.colors)-1
self.data+=f'\n#{colorid}'
def draw_column(self,*data):
if len(data) == 6 and type(data) in (list,tuple):
(a,b,c,d,e,*f)=(data)
binchar = '1' if a else '0'
binchar += '1' if b else '0'
binchar += '1' if c else '0'
binchar += '1' if d else '0'
binchar += '1' if e else '0'
binchar += '1' if f else '0'
elif len(data) == 1:
try:
assert len(data[0]) == 6
data=data[0].replace(' ','0')
int(data,2)
binchar = ''.join(data)
except:
raise Exception('idk lol')
else:
raise Exception('idk '+str(len(data))+str(type(data))+str(data))

intchar = int(binchar,2)
asciichar = chr(intchar+63)
self.data += asciichar
def draw_row(self):
pass
def render(self):
self.coldata = ''
for i,col in enumerate(self.colors):
self.coldata += f'#{i};2;{col[0]};{col[1]};{col[2]}'
print(self.coldata+self.data+'\033\\')

s = sixel()

s.setcol(255,255,0)

s.draw_column(' 1111 ')
s.draw_column('111111')
s.draw_column('111111')
s.draw_column('111111')
s.draw_column('111111')
s.draw_column(' 1111 ')

s.setcol(255,0,0)

s.draw_column('      ')
s.draw_column('  1 1 ')
s.draw_column(' 1    ')
s.draw_column(' 1    ')
s.draw_column('  1 1 ')
s.draw_column('      ')

s.render()```