示例#1
0
def fill_dragons(image: Image, indices):
    image = image.copy()
    for x, y in indices:
        for i in range(len(DRAGON)):
            for j in range(len(DRAGON[i])):
                if not image.in_bounds(x + i, y + j):
                    print(f"error: x={x}, y={y}, i: {i}, j: {j}")
                    raise Exception("Unexpected out of bounds while filling")
                if DRAGON[i][j] == "#":
                    if image.get(x + i, y + j) not in ("#", "O"):
                        print(f"error: x={x}, y={y}, i: {i}, j: {j}")
                        raise Exception("Unexpected mismatch while filling")
                    image.put(x+i, y+j, "O")
    return image