猫史档案馆


【Python作品分享】伟大中国【作品秀】

用户:正在加载中qwq正在加载中qwq查看:0 回复:2 评论:0 创建时间:2022-07-17T13:45:53


【作品展示】

center_image

 

【作品介绍】

本人用了喵时才做好!!!

 

【作品源代码】

import turtle as t
import math as m


def wjx(long):  # 画五角星函数
    t.color('yellow')
    t.begin_fill()
    t.rt(180)
    for i in range(5):
        t.fd(long)
        t.rt(144)
    t.end_fill()


flag_w = eval(input("请输入国旗宽度:"))
flag_h = flag_w*2/3
t.setup(flag_w+60, flag_h+40, 0, 0)  # 设置画布大小
c_len = flag_w/30  # 单元格长度


def grid():  # 画出辅助格子函数
    t.color("white")
    for i in range(11):
        t.penup()
        t.goto(-flag_w/2, flag_h/2-i*c_len)
        t.seth(0)
        t.pendown()
        t.fd(c_len*15)

    for i in range(16):
        t.seth(90)
        t.penup()
        t.goto(-i*c_len, 0)
        t.pendown()
        t.fd(c_len*10)


t.color("red")  # 国旗布背景
t.penup()
t.goto(-flag_w/2, flag_h/2)
t.pendown()
t.begin_fill()
t.fd(flag_w)
t.right(90)
t.fd(flag_h)
t.right(90)
t.fd(flag_w)
t.right(90)
t.fd(flag_h)
t.end_fill()

#grid()  #画出格子

t.color("yellow")  # 大五角星
t.penup()
t.bk(c_len*5)
t.rt(90)
t.fd(c_len*5)
t.left(90+72)
r = flag_h/3/2  # 大圆半径
t.fd(r)
t.rt(90+72)
t.pendown()
wjx(r*m.sin(36)*2)

#右上角第一个星
t.penup()
t.goto(-c_len*5, c_len*8)
t.seth(m.atan(3/5)*180/m.pi+180)
r = flag_h/10/2
t.fd(r)
t.rt(162)
t.pendown()
wjx(r*m.sin(36)*2)

#右上角第二个星
t.penup()
t.goto(-c_len*3, c_len*6)
t.seth(m.atan(1/7)*180/m.pi+180)
r = flag_h/10/2
t.fd(r)
t.rt(162)
t.pendown()
wjx(r*m.sin(36)*2)

#右下角第三个星
t.penup()
t.goto(-c_len*3, c_len*3)
t.seth(180-m.atan(2/7)*180/m.pi)
r = flag_h/10/2
t.fd(r)
t.rt(162)
t.pendown()
wjx(r*m.sin(36)*2)

#右下角第四个星
t.penup()
t.goto(-c_len*5, c_len*1)
t.seth(180-m.atan(4/5)*180/m.pi)
r = flag_h/10/2
t.fd(r)
t.rt(162)
t.pendown()
wjx(r*m.sin(36)*2)

'''
#测试连线
t.color("black")
t.pensize(1)

t.penup()
t.goto(-c_len*10,c_len*5)
t.pendown()
t.goto(-c_len*5,c_len*8)

t.penup()
t.goto(-c_len*10,c_len*5)
t.pendown()
t.goto(-c_len*3,c_len*6)

t.penup()
t.goto(-c_len*10,c_len*5)
t.pendown()
t.goto(-c_len*3,c_len*3)

t.penup()
t.goto(-c_len*10,c_len*5)
t.pendown()
t.goto(-c_len*5,c_len*1)
'''
t.penup()
t.goto(-c_len*10, c_len*5)
t.done()

 

【提示】

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

https://python.codemao.cn


回复

上一页1 页 / 共 1下一页
AokenAoken

不错 加油

点赞0


评论


HADOGHADOG

imgsrc="https://static.cod喵/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E5%8A%A0%E6%B2%B9.gif"alt="emotion_编程猫_加油"

点赞0


评论