Farben und verschiedene Julia-Formeln
This commit is contained in:
@@ -40,6 +40,7 @@ for x in range(width):
|
|||||||
img.putpixel((x, y), color)
|
img.putpixel((x, y), color)
|
||||||
|
|
||||||
img.save("mandelbrot.png")
|
img.save("mandelbrot.png")
|
||||||
print("Bild wurde als mandelbrot.png gespeichert!")
|
img.show()
|
||||||
|
#print("Bild wurde als mandelbrot.png gespeichert!")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
27
julia.py
27
julia.py
@@ -1,4 +1,5 @@
|
|||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
import math
|
||||||
|
|
||||||
# Bildeinstellungen
|
# Bildeinstellungen
|
||||||
width, height = 800, 800
|
width, height = 800, 800
|
||||||
@@ -9,7 +10,12 @@ x_min, x_max = -1.5, 1.5
|
|||||||
y_min, y_max = -1.5, 1.5
|
y_min, y_max = -1.5, 1.5
|
||||||
|
|
||||||
# Die Konstante c (hier kannst du experimentieren!)
|
# Die Konstante c (hier kannst du experimentieren!)
|
||||||
c = complex(-0.7, 0.27015)
|
#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)
|
# Neues Bild erstellen (RGB-Modus)
|
||||||
img = Image.new('RGB', (width, height), (0, 0, 0))
|
img = Image.new('RGB', (width, height), (0, 0, 0))
|
||||||
@@ -29,11 +35,22 @@ for py in range(height):
|
|||||||
|
|
||||||
# Einfärben
|
# Einfärben
|
||||||
if n < max_iter:
|
if n < max_iter:
|
||||||
# Ein einfacher Farbverlauf basierend auf n
|
# Die magische Formel für die Glättung
|
||||||
r = (n * 10) % 256
|
# v = n + 1 - log2(log2(|z|))
|
||||||
g = (n * 5) % 256
|
log_zn = math.log(z.real ** 2 + z.imag ** 2) / 2
|
||||||
b = (n * 20) % 256
|
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)
|
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:
|
else:
|
||||||
# Inneres der Menge bleibt schwarz
|
# Inneres der Menge bleibt schwarz
|
||||||
pixels[px, py] = (0, 0, 0)
|
pixels[px, py] = (0, 0, 0)
|
||||||
|
|||||||
BIN
julia_set.png
Normal file
BIN
julia_set.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 295 KiB |
Reference in New Issue
Block a user