【Python】五行红旗


```python
# 人生苦短,我用Python,争取早日成为党和国家需要的人才
import turtle as t
import math

cell = 20
t.speed(8)
# 开始绘制旗面
t.penup()
t.goto(-15 * cell, -10 * cell)
t.pendown()
t.fillcolor('red')
t.pencolor('red')
t.begin_fill()
for i in range(2):
    t.fd(30 * cell)
    t.left(90)
    t.fd(20 * cell)
    t.left(90)
t.end_fill()


#
# # 开始绘制大五角星
dis1 = 6 * cell * math.cos(18 / 180 * math.pi)
dis2 = dis1 / 3
t.goto(-10 * cell, 5 * cell)
t.seth(90)
t.fd(3 * cell)
t.right(162)
t.fillcolor('yellow')
t.begin_fill()
t.pencolor('yellow')
for i in range(5):
    t.fd(dis1)
    t.right(144)
t.end_fill()




# # 开始绘制小五角星
smallcircle = [(-5 * cell, 8 * cell), (-3 * cell, 6 * cell), (-3 * cell, 3 * cell), (-5 * cell, cell)]
angle1 = math.atan(3 / 5) / math.pi * 180
angle2 = math.atan(1 / 7) / math.pi * 180
angle3 = -(math.atan(2 / 7) / math.pi * 180)
angle4 = -(math.atan(4 / 5) / math.pi * 180)
smallangle = [angle1, angle2, angle3, angle4]
for k in range(4):
    t.penup()
    t.goto(smallcircle[k])  # 定位到五角星中心
    t.seth(0)  # 这是海龟头部的角度为0
    t.left(smallangle[k])  # 旋转角度,以背向指向大五角星的角尖
    t.backward(cell)  # 从五角星中心到指向大五角星的角尖(龟倒着爬)退一个小圆半径
    t.left(18)  # 五角星的半角角度
    t.pendown()
    t.begin_fill()
    for i in range(5):
        t.forward(dis2)  # 小星一划的边长
        t.right(144)
    t.end_fill()
t.hideturtle()
#
#
#
#
t.pencolor('blue')
t.penup()
t.goto(0, -250)
t.pendown()
t.write("王东祝伟大祖国生日快乐!", align="center", font=('宋体', 20, 'normal'))

t.done()

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值