python - Mandelbrot 使用枕头库在 python 中设置放大
问题描述
我不知道如何放大曼德布罗集以及如何将坐标更改为缩放。我想知道我应该设置图像的中心,例如:x= -0.3123 和 y = -0.1212 现在缩放它还是将 x,y 更改为任意数字?谁能给我解释一下?我的代码:
import math
from PIL import Image
height = 360
width = 640
#plot window
X_START = -2.5
X_END = 2.5
Y_START = -1.5
Y_END = 1.5
base_zoom = 1
for i in range(1,30):
img = Image.new("HSV", (width, height), 0)
X_START = -2.5 * base_zoom
X_END = 2.5 * base_zoom
Y_START = -1.5 * base_zoom
Y_END = 1.5 * base_zoom
maxIter = 100
pixels = img.load()
for x in range(width):
print(f"Did: {math.floor(x / width * 1000 / 10)} % of picture nr {i}")
for y in range(height):
a = (x / width) * (X_END - X_START) + X_START
b = (y/ height) * (Y_END - Y_START) + Y_START
ca = a
cb = b
n = 0
while n<maxIter:
aa = -2
bb = 2 * a * b
if abs(aa + bb) > 4:
bright = int(255 * n % maxIter)
saturation = 185
value = 218
pixels[x, y] = (bright, saturation, value)
a = aa
b = bb
n+=1
base_zoom *= 0.5
# img.show()
img.convert('RGB').save(f'pictures_mandelbrot\picture{i}.BMP')
解决方案
推荐阅读
- wordpress - 如何使用 .access 将 URL 从 domain.org/xxx/archive/ 重定向到 domain.org/archive /wordpress
- java - 这个链表是循环实现的吗?
- javascript - Electron 中的 Viewheight 单位与具有相同分辨率的两台不同笔记本电脑上的 Windows 缩放不一致
- coq - Coq 战术是右联想还是左联想?
- swift - DateRow 本地不变
- javascript - 如何转换作为 ES 模块的 node_module 依赖项?
- python - 如何绘制从 SQL 获得的数据?
- android - 我可以编写可以在 WebAssembly 和 Android 和 iOS 上运行的 Rust 代码吗?
- c# - 如何在 puppeteer 中禁用图像?
- php - htaccess 重定向不存在文件并显示链接,如存在