from PIL import Image from PIL import ImageSequence import turtle, time def main(): file_path = "copper/white.gif" pixels = first_step(file_path) """ pixels = [(100, 100), (100, 102), (100, 102), (100, 102), (100, 102), (100, 102), (100, 102), (100, 102), (100, 102), (102, 102), (102, 100), (102, 100), (102, 100), (102, 100), (102, 100), (102, 100), (102, 100), (102, 98), (100, 98), (100, 98), (100, 98), (98, 98), (98, 100), (98, 100), (98, 100), (98, 100), (98, 100), (98, 100), (98, 102), (100, 100), (98, 98), (98, 98), (98, 100), (98, 100), (98, 100), (98, 100), (98, 100), (98, 102), (98, 102), (98, 102), (100, 102), (100, 102), (102, 102), (102, 102), (102, 102), (102, 100), (102, 100), (102, 100), (102, 100), (102, 100), (102, 98), (102, 98), (102, 98), (100, 98), (100, 98), (100, 100), (100, 102), (100, 102), (100, 102), (100, 102), (100, 102), (100, 102), (100, 102), (102, 100), (100, 98), (100, 98), (100, 98), (102, 98), (102, 98), (102, 98), (102, 98), (102, 100), (102, 100), (102, 102), (102, 102), (102, 102), (100, 102), (100, 102), (100, 102), (100, 102), (100, 100), (100, 102), (100, 102), (100, 102), (100, 102), (100, 102), (100, 102), (102, 102), (102, 100), (102, 100), (102, 100), (102, 100), (102, 100), (102, 100), (102, 98), (100, 98), (100, 98), (100, 98), (100, 98), (100, 98), (100, 98), (100, 100), (98, 98), (98, 100), (98, 100), (98, 100), (98, 100), (98, 100), (98, 100), (98, 100), (98, 102), (100, 102), (100, 102), (102, 102), (102, 100), (102, 100), (102, 100), (102, 100), (102, 100), (102, 100), (102, 100), (102, 102), (100, 102), (100, 102), (98, 102), (98, 100), (98, 100), (98, 100), (98, 100), (98, 100), (98, 100), (98, 100), (98, 98)] """ second_step(pixels) def first_step(file_path): im = Image.open(file_path) pixels = [] for frame in ImageSequence.Iterator(im): size = frame.size width = size[0] height = size[1] for x in range(width): for y in range(height): pixel = frame.getpixel((x, y)) if pixel != 0: pixels.append((x, y)) print(pixels) return pixels def second_step(pixels): EXP = 10 x = y = 0 for pilx, pily in pixels: dx = (pilx - 100) // 2 dy = (100 - pily) // 2 x += dx * EXP y += dy * EXP turtle.goto(x, y) if dx == dy == 0: time.sleep(1) turtle.reset() x = y = 0 if __name__ == "__main__": main()