|
|
@ -6,8 +6,8 @@ from colors import Colors |
|
|
|
class Layer: |
|
|
|
def __init__(self, x, y): |
|
|
|
self.screen = {} |
|
|
|
self.x = x |
|
|
|
self.y = y |
|
|
|
self.x = x #largeur |
|
|
|
self.y = y #hauteur |
|
|
|
|
|
|
|
def clear(self): |
|
|
|
self.screen = {} |
|
|
@ -30,8 +30,8 @@ class Layer: |
|
|
|
class CLI: |
|
|
|
def __init__(self): |
|
|
|
size = os.get_terminal_size() |
|
|
|
self.x = size[1] - 2 #hauteur |
|
|
|
self.y = size[0] #largeur |
|
|
|
self.x = size.columns #largeur |
|
|
|
self.y = size.lines - 2 #hauteur |
|
|
|
self.screen = {} |
|
|
|
self.__layers = {} |
|
|
|
|
|
|
@ -44,35 +44,39 @@ class CLI: |
|
|
|
def get_layers(self) -> Dict[str, Layer]: |
|
|
|
return self.__layers |
|
|
|
|
|
|
|
def __combine_layers(self): |
|
|
|
def combine_layers(self): |
|
|
|
layers = self.get_layers() |
|
|
|
#for layer in layers: |
|
|
|
# for y in range(layer.x): |
|
|
|
# for x in range(layer.y): |
|
|
|
# if (x, y) in layer.screen: |
|
|
|
# content += layer.screen[(x, y)] |
|
|
|
# else: |
|
|
|
# content += " " |
|
|
|
# content += "\n" |
|
|
|
|
|
|
|
#def draw(self): |
|
|
|
# print("\033[H\033[J", end="") |
|
|
|
# content = "" |
|
|
|
# for y in range(self.x): |
|
|
|
# for x in range(self.y): |
|
|
|
# if (x, y) in self.screen: |
|
|
|
# content += self.screen[(x, y)] |
|
|
|
# else: |
|
|
|
# content += " " |
|
|
|
# content += "\n" |
|
|
|
# print(content) |
|
|
|
self.screen = {} |
|
|
|
for layer_name in layers: |
|
|
|
for x in range(layers[layer_name].x): |
|
|
|
for y in range(layers[layer_name].y): |
|
|
|
if (x, y) in layers[layer_name].screen: |
|
|
|
self.screen[(x, y)] = layers[layer_name].screen[(x, y)] |
|
|
|
|
|
|
|
def draw(self): |
|
|
|
cli.combine_layers() |
|
|
|
content = "" |
|
|
|
for y in range(self.y): |
|
|
|
#content += "\n" |
|
|
|
for x in range(self.x): |
|
|
|
if (x, y) in self.screen: |
|
|
|
content += self.screen[(x, y)] |
|
|
|
else: |
|
|
|
content += "a" |
|
|
|
content += "\n" |
|
|
|
print("\033[H\033[J", end="") |
|
|
|
print(content) |
|
|
|
|
|
|
|
cli = CLI() |
|
|
|
cli.put_char("t", 5, 6, Colors.BLUEBG, Colors.BLACK) |
|
|
|
cli.put_string("tttaaaaaa ttt \n ttttttttttnnnnnn t", 8, 9, Colors.BEIGEBG) |
|
|
|
layer = Layer(cli.x, cli.y) |
|
|
|
layer.put_char("t", 5, 6, Colors.BLUEBG, Colors.BLACK) |
|
|
|
layer.put_string("""test""", 8, 9, Colors.BEIGEBG) |
|
|
|
|
|
|
|
cli.set_layer("test", layer) |
|
|
|
##cli.put_char("t", 5, 6, Colors.BLUEBG, Colors.BLACK) |
|
|
|
#cli.put_string("tttaaaaaa ttt \n ttttttttttnnnnnn t", 8, 9, Colors.BEIGEBG) |
|
|
|
#cli.draw() |
|
|
|
|
|
|
|
while True: |
|
|
|
cli.draw() |
|
|
|
sleep(0.1) |
|
|
|
sleep(1) |