python 魔法阵

本文展示了如何使用Python的turtle库创建一个复杂的魔法阵图形,包括大圆、小圆、正方形边框、直线、五角星、月亮和太阳等元素。通过调用不同函数绘制各个部分,最终形成一个完整的魔法阵图案。
摘要由CSDN通过智能技术生成

想必很多朋友都在动漫里看过魔法阵,今天他来了

以下为代码

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)

# 小线

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

mincraftzuo

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值