from PIL import Image import math # Bildeinstellungen width, height = 800, 800 max_iter = 100 # Bereich der komplexen Ebene x_min, x_max = -1.5, 1.5 y_min, y_max = -1.5, 1.5 # Die Konstante c (hier kannst du experimentieren!) #c = complex(-0.7, 0.27015) #c = complex(-0.4, -0.6) #c= complex(-0.123, 0.745) #c = complex (0.75) #c = complex (0,1) c = complex(-0.391, -0.587) # Neues Bild erstellen (RGB-Modus) img = Image.new('RGB', (width, height), (0, 0, 0)) pixels = img.load() for py in range(height): for px in range(width): # Pixel-Koordinaten in komplexe Zahlen umrechnen zx = x_min + (px / width) * (x_max - x_min) zy = y_min + (py / height) * (y_max - y_min) z = complex(zx, zy) n = 0 while abs(z) <= 2 and n < max_iter: z = z**2 + c n += 1 # Einfärben if n < max_iter: # Die magische Formel für die Glättung # v = n + 1 - log2(log2(|z|)) log_zn = math.log(z.real ** 2 + z.imag ** 2) / 2 nu = math.log(log_zn / math.log(2)) / math.log(2) iteration = n + 1 - nu # Farbe berechnen (Sinus-Wellen erzeugen sanfte Übergänge) r = int(128 + 127 * math.sin(0.3 * iteration + 0.0)) g = int(128 + 127 * math.sin(0.3 * iteration + 2.0)) b = int(128 + 127 * math.sin(0.3 * iteration + 4.0)) pixels[px, py] = (r, g, b) # Ein einfacher Farbverlauf basierend auf n # r = (n * 10) % 256 # g = (n * 5) % 256 # b = (n * 20) % 256 # pixels[px, py] = (r, g, b) else: # Inneres der Menge bleibt schwarz pixels[px, py] = (0, 0, 0) # Speichern und anzeigen img.save("julia_set.png") img.show()