使用samila
库可以生成美丽的图案, 例如:
# pip install samila==1.1 or pip3 install samila==1.1
import matplotlib.pyplot as plt
from samila import GenerativeImage
# g = GenerativeImage()
# g.generate()
# g.plot()
# plt.show()
import random
import math
def f1(x, y):
result = random.uniform(-1, 1) * x**2 - math.sin(y**2) + abs(y-x)
return result
def f2(x, y):
result = random.uniform(-1, 1) * y**3 - math.cos(x**2) + 2*x
return result
g = GenerativeImage(f1, f2)
g.generate()
g.plot()
plt.show()
g = GenerativeImage(f1, f2)
g.generate()
g.plot(color="yellow", bgcolor="black", projection=Projection.POLAR)
g.seed
1018273
plt.show()
生成结果:
作者:艾孜尔江
标签:f1,plt,Python,图案,美丽,GenerativeImage,import,samila,result From: https://blog.51cto.com/u_15127808/8613638