51 lines
1.4 KiB
Python
51 lines
1.4 KiB
Python
|
#!/bin/python3
|
||
|
from os import get_terminal_size
|
||
|
tx,ty = get_terminal_size().columns ,get_terminal_size().lines
|
||
|
|
||
|
def genfeld():
|
||
|
return [[' ' for _ in range(tx)] for _ in range(ty)]
|
||
|
|
||
|
def bg_char(feld, char=' '):
|
||
|
for a in range(len(feld)):
|
||
|
for b in range(len(feld[0])):
|
||
|
feld[a][b] = char
|
||
|
return feld
|
||
|
|
||
|
def strfeld(feld):
|
||
|
return '\n'.join([''.join(row) for row in feld])
|
||
|
|
||
|
def change_char(feld, character, position):
|
||
|
feld[position[0]][position[1]] = character
|
||
|
|
||
|
def change_block(feld, block, position):
|
||
|
position = [position[0]+1,position[1]]
|
||
|
pposition = position
|
||
|
for zeichen in block:
|
||
|
if zeichen == '\n':
|
||
|
pposition = [pposition[0] + 1, position[1]]
|
||
|
else:
|
||
|
pposition = [pposition[0], pposition[1] + 1]
|
||
|
feld[pposition[0]][pposition[1]] = zeichen
|
||
|
return feld
|
||
|
|
||
|
def clear():
|
||
|
print('\033c', end='')
|
||
|
|
||
|
def draw_border(feld, border_char='+'):
|
||
|
for i in range(len(feld)):
|
||
|
feld[i][0] = feld[i][-1] = border_char
|
||
|
for j in range(len(feld[0])):
|
||
|
feld[0][j] = feld[-1][j] = border_char
|
||
|
global tx,ty
|
||
|
tx -= 2;ty -= 2
|
||
|
return feld
|
||
|
|
||
|
#def move_cursor(x, y):
|
||
|
# print(f'\033[{y};{x}H', end='')
|
||
|
|
||
|
def viereck(feld, start_pos, width, height, fill_char='#'):
|
||
|
for i in range(height):
|
||
|
for j in range(width):
|
||
|
feld[start_pos[0] + i][start_pos[1] + j] = fill_char
|
||
|
return feld
|