Julia begonnen
This commit is contained in:
43
julia.py
Normal file
43
julia.py
Normal file
@@ -0,0 +1,43 @@
|
||||
from PIL import Image
|
||||
|
||||
# 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)
|
||||
|
||||
# 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:
|
||||
# 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()
|
||||
Reference in New Issue
Block a user