利用cairo画分形树
Fractal Tree
pip install cairocffi
在windows下,还需下载GTK+。...return max(1, TRUNK_RAD * level / ITERATIONS)
def fractal_tree(ctx, # a cairo context to draw...theta - np.random.random() * (perturb / level) * angle
# recursively draw the next branches
fractal_tree...(ctx, level - 1, (x, y), t * r,
r, theta1, angle, perturb)
fractal_tree(ctx, level...ITERATIONS, ROOT, TRUNK_LEN,
RATIO, THETA, ANGLE, PERTURB)
surface.write_to_png("random_fractal_tree.png