想必很多朋友都在动漫里看过魔法阵,今天他来了
以下为代码
import turtle as t
def tcyuan(x, y, r):
t.fillcolor("black")
t.begin_fill()
t.seth(0)
y = y - r
t.penup()
t.goto(x, y)
t.pendown()
t.circle(r)
t.end_fill()
def yuan(x, y, r):
t.seth(0)
y = y-r
t.penup()
t.goto(x, y)
t.pendown()
t.circle(r)
def yueliang():
R = 110 - 1
r = R - 22 - 1
# 月亮填充
t.penup()
t.goto(-350+2*R, 0)
t.seth(90)
t.fillcolor("black")
t.begin_fill()
t.circle(R, 359)
t.left(90)
t.fd(2)
t.left(90)
t.circle(-r, 359)
t.left(90)
t.fd(2)
t.pendown()
t.end_fill()
#轮廓
yuan(-350 + R, 0, R)
yuan(-350 + 44 + r - 2, 0, r - 2)
def zhixian(R, r, count, jiaodu):
t.seth(90+jiaodu)
# t.goto(0, 0)
for i in range(count):
t.penup()
t.goto(0, 0)
t.fd(r)
t.pendown()
t.fd(R-r)
t.left(360/count)
def zfx(R, r):
jiange = 10
# t.pensize(jiange)
t.seth(90)
big = pow((R**2)*2, 0.5)
small = big-2*jiange
for i in range(13):
#大线
t.penup()
t.goto(0, 0)
t.fd(R)
t.pendown()
t.right(135)
t.fd(big)
#小线
t.left(135)
t.penup()
t.goto(0, 0)
t.fd(pow((small**2)/2, 0.5))
t.pendown()
t.right(135)
t.fd(small)
#粗线
t.pensize(8)
t.pencolor("black")
t.left(135)
t.penup()
t.goto(0, 0)
t.fd((R+pow((small ** 2) / 2, 0.5))/2)
t.pendown()
t.right(135)
t.fd((big+small)/2)
t.pensize(2)
t.pencolor("yellow")
t.seth(90+i*30)
else:
# 大线
t.penup()
t.goto(0, 0)
t.fd(R)
t.right(135)
t.fd(big / 2)
t.pendown()
t.fd(big / 2)
# 小线