# Funktionen für das Erstellen und Bearbeiten von ASCII-Grafiken

def new_image(width, height, symbol='.'):
    '''Erzeugt ein (width x height)-Raster gefüllt mit symbol'''
    return [[symbol for j in range(width)] for i in range(height)]

def set_pixel(img, x, y, symbol='X'):
    '''Schreibt symbol an die Position x, y, sofern sie exisitert'''
    width, height = len(img[0]), len(img)
    # Liegt Pixel im Bild?
    if 0 <= x < width and 0 <= y < height:
        i, j = height-y-1, x # Koordinaten -> Indizes
        img[i][j] = symbol

def get_pixel(img, x, y):
    '''Gibt das Symbol an der Position x, y zurück, sofern sie exisitert'''
    ...

        
def show(img):
    '''Gibt das Bild auf der Shell aus'''
    for row in img:
        print(' '.join(row))

def fill4(img, x, y, oldsymbol, newsymbol):
    '''Ersetzt das Symbol an der Position x, y durch newsymbol und
    führt diese Ersetzung rekursiv links, rechts, oben unten durch'''
    ...
    
def draw_line(img, x1, y1, x2, y2, symbol):
    '''Naive Implementierung der Strecke von x1, y1 nach x2, y2'''
    ...


W, H = 20, 20        

bild = new_image(W, H)

# Zeichne Diagonale
#draw_line(bild, 0, 0, W, H, 'X')

# Fülle Teil unten rechts
#fill4(bild, 5, 0, '.', 'o')

# Zeige Bild an
show(bild)
        
    

    
    
    
    








    
