糖尿病康复,内容丰富有趣,生活中的好帮手!
糖尿病康复 > 分型图z=z*z+c的画法

分型图z=z*z+c的画法

时间:2024-03-12 12:47:46

相关推荐

分型图z=z*z+c的画法

python代码:

import numpy as npfrom PIL import Imagefrom numba import jitMAXITERS = 200RADIUS = 100@jitdef color(z, i):v = np.log2(i+1-np.log2(np.log2(abs(z))))/5if v < 1.0:return v**4, v**2.5, velse:v = max(0, 2-v)return v, v**1.5, v**3@jitdef iterate(c):z = 0jfor i in range(MAXITERS):if z.real*z.real +z.imag*z.imag > RADIUS:return color(z, i)z = z*z + creturn 0, 0, 0def main(xmin, xmax, ymin, ymax, width, height):x = np.linspace(xmin, xmax, width)y = np.linspace(ymax, ymin, height)z = x[None, :] +y[:, None]*1jred, green, blue = np.asarray(np.frompyfunc(iterate, 1, 3)(z)).astype(np.float)img = np.dstack((red, green, blue))Image.fromarray(np.uint8(img*255)).save('mandelbrot.png')main(-2.1, 0.8, -1.16, 1.16, 1200, 960)

效果图:

如果觉得《分型图z=z*z+c的画法》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。