In [1]:
import math # Ez a sor vajon mit csinál?
import random # ljlkj
from PIL import Image
import matplotlib.pyplot
import numpy as np
imgx = 512; imgy = 512
image = Image.new("RGB", (imgx, imgy))
pixels = image.load()
f = random.random() * 20 + 10
p = random.random() * math.pi
n = random.randint(10, 20)
print(f, p, n)
for ky in range(imgy):
y = float(ky) / (imgy - 1) * 4 * math.pi - 2 * math.pi
for kx in range(imgx):
x = float(kx) / (imgx - 1) * 4 * math.pi - 2 * math.pi
z = 0.0
for i in range(n):
r = math.hypot(x, y)
a = math.atan2(y, x) + i * math.pi * 2.0 / n
z += math.cos(r * math.sin(a) * f + p)
c = int(round(255 * z / n))
pixels[kx, ky] = (c, c, c)
In [1]:
%matplotlib inline
matplotlib.pyplot.imshow(np.asarray(image),cmap='PuBu');
In [ ]: