python画八角星_Python画八角星的程序

本文详细介绍了使用特定绘图工具绘制不同形状的方法,包括多边形、五角星、六角星及各种螺旋图案等,并提供了具体的实现代码示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

匿名用户

1级

2018-11-24 回答

多边形的画法

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()

阅读全文

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值