猫史档案馆


【Python作品分享】国旗【作品秀】

用户:司乘司乘查看:0 回复:0 评论:0 创建时间:2021-05-15T19:16:08


【作品展示】

center_image

 

【作品介绍】

海龟作图画国旗

 

【作品源代码】

import turtle
import turtle as t


# 画国旗

t.speed(1)

# 国旗的旗面
t.penup()
# 从左上角为起始点
t.goto((-200), 200)
t.pendown()
t.begin_fill()
# 旗面填充颜色为红色
t.fillcolor('red')
# 画笔颜色为红色
t.pencolor('red')
# 绘制长方形旗面
for i in range(2):
    # 旗面的长度
    t.forward(438)
    t.right(90)
    # 旗面的宽度
    t.forward(292)
    t.right(90)
t.end_fill()

# 绘制主五角星
# 五角星填充颜色为黄色
t.fillcolor('yellow')
# 画笔颜色为黄色
t.pencolor('yellow')
t.penup()
# 五角星的起始坐标
t.goto((-170), 145)
t.pendown()
t.begin_fill()
# 循环5次画出五角星
for x in range(5):
    t.forward(70)
    t.right(144)
t.end_fill()

# 第一颗辅五角星
t.penup()
# 五角星的起始坐标
t.goto((-100), 180)
# 设置画笔海龟的朝向
t.setheading(305)
t.pendown()
t.begin_fill()
# 循环5次画出五角星
for i in range(5):
    t.forward(20)
    t.right(144)
t.end_fill()

# 第二颗辅五角星
t.penup()
# 五角星的起始坐标
t.goto((-85), 150)
# 设置画笔海龟朝向
t.setheading(30)
t.pendown()
t.begin_fill()
# 循环5次画出五角星
for i in range(5):
    t.forward(20)
    t.right(144)
t.end_fill()

# 第三颗辅五角星
t.penup()
# 五角星的起始坐标
t.goto((-85), 120)
# 设置画笔海龟朝向
t.setheading(3)
t.pendown()
t.begin_fill()
# 循环5次画出五角星
for i in range(5):
    t.forward(20)
    t.right(144)
t.end_fill()

# 第四颗辅五角星
t.penup()
# 五角星的起始坐标
t.goto((-100), 100)
# 设置画笔海龟朝向
t.setheading(300)
t.pendown()
t.begin_fill()
# 循环5次画出五角星
for i in range(5):
    t.forward(20)
    t.right(144)
t.end_fill()

t.hideturtle()
turtle.done()
print('我祝愿祖国繁荣昌盛!')

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 0下一页