def generate(width, height, s, output):
canvas = np.zeros((height, width), dtype='float64')
max_d = math.sqrt(width**2 + height**2) / 2
offset_angular = 0
if (width >= height):
offset_angular = math.pi / 4
for (i, j), _ in np.ndenumerate(canvas):
y = height // 2 - i
x = j - width // 2
d = math.sqrt(x**2 + y**2)
t = math.atan2(y, x)
canvas[i,j] = (255 / 4) * \
(2 + radial_sin(d, s, t) + angular_sin (
d, t, max_d, s, offset_angular))
f = open(output, 'wb')
w = png.Writer(width, height, greyscale=True)
w.write(f, canvas)
f.close()
评论列表
文章目录