用python画派大星代码,Python画八角星的程序
用python画派大星代码目录
用python画派大星代码
。
404 Not Found
。
。
。
。
。
。
。
。
Python画八角星的程序
多边形的画法
def ployon(num, distance):
# bob.color('blue', 'red')
bob.color("red", "yellow")
for i in range(num):
bob.fd(distance)
bob.lt(360 / num)
time.sleep(1)
bob.end_fill()
bob.filling()
time.sleep(3)
bob.reset()
# ployon(3, 100)
# ployon(4, 100)
# ployon(5, 100)
# ployon(6, 100)
# ployon(7, 100)
# ployon(8, 100)
# # 五角星的画法
# bob.color("red", "yellow")
# for i in range(5):
# bob.fd(200)
# bob.right(180 - 36)
# time.sleep(0.5)
# bob.end_fill()
#
# bob.reset()
#
# # 八角星
# bob.color("red", "yellow")
# for i in range(8):
# bob.fd(200)
# bob.right(180 - 45)
# time.sleep(0.5)
# time.sleep(10)
#
# bob.reset()
# 六角星
# bob.color("red", "yellow")
# for i in range(3):
# bob.fd(200)
# bob.right(180 - 60)
# time.sleep(0.5)
#
# bob.up()
# bob.lt(30)
# bob.fd(200 / math.sqrt(3))
# bob.rt(90)
# bob.down()
#
# for i in range(3):
# bob.fd(200)
# bob.right(180 - 60)
# time.sleep(0.5)
# time.sleep(2)
#
# bob.reset()
# 迷宫的画法
def squareSpiral(ra):
bob.pencolor("green")
for x in range(100):
bob.forward(x)
bob.left(ra)
time.sleep(3)
bob.reset()
def circleSpiral(ra):
bob.pencolor("green")
for x in range(100):
bob.circle(x)
bob.left(ra)
time.sleep(3)
bob.reset()
# 迷宫
# squareSpiral(90)
# # 大风车
# squareSpiral(91)
# # 漩涡
# circleSpiral(90)
# 花朵
# circleSpiral(60)
def circleSpiral2(ra):
bob.pencolor("green")
a = 0;
n = 360 / ra
while(a + 1 <= n):
bob.circle(50)
bob.left(ra)
a = a + 1
time.sleep(3)
bob.reset()
阅读全文
如何用Python写星星符号
for i in range(1,10):
if (i<=5):
x=i
else
x=11-i
for j in range(1,x):
print("*")
print("\n")
如何用Python画各种著名数学图案
如何用Python画各种著名数学图案 | 附图+代码
用Python绘制著名的数学图片或动画,展示数学中的算法魅力。
Mandelbrot 集
'''
A fast Mandelbrot set wallpaper renderer
reddit discussion:
'''
importnumpy asnp
fromPILimportImage
fromnumba importjit
MAXITERS=200
RADIUS=100
@jit
defcolor(z, i):
v =np.log2(i +1-np.log2(np.log2(abs(z)))) /5
ifv <1.0:
returnv**4, v**2.5, v
else:
v =max(0, 2-v)
returnv, v**1.5, v**3
@jit
defiterate(c):
z =0j
fori inrange(MAXITERS):
ifz.real*z.real +z.imag*z.imag >RADIUS:
returncolor(z, i)
z =z*z +c
return0, 0,0
defmain(xmin, xmax, ymin, ymax, width, height):
x =np.linspace(xmin, xmax, width)
y =np.linspace(ymax, ymin, height)
z =x[None, :] +y[:, None]*1j
red, 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')
if__name__=='__main__':
main(-2.1, 0.8, -1.16, 1.16, 1200, 960)
(随机推荐阅读本站500篇优秀文章点击前往:500篇优秀随机文章)