猫史档案馆


神了!Python画国旗

用户:昙陌祁冥昙陌祁冥查看:0 回复:3 评论:0 创建时间:2019-10-06T21:24:33


 

 作品代码:

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


回复

上一页1 页 / 共 1下一页
Him_YXRWHim_YXRW

emotion_编程猫_点赞

点赞0


评论


司乘司乘

加个鸡腿!

点赞0


评论


司乘司乘

emotion_编程猫_谢谢老板

点赞0


评论