猫史档案馆


【Python作品分享】五星红旗【作品秀】

用户:。CcQr。CcQr查看:0 回复:1 评论:0 创建时间:2020-08-10T12:10:00


【作品展示】

center_image

 

【作品介绍】

233333

 

【作品源代码】

import turtle
import time
import os


#
def draw_square(org_x, org_y, x, y):
    turtle.setpos(org_x, org_y)  # to left and bottom connor
    turtle.color('red', 'red')
    turtle.begin_fill()
    turtle.fd(x)
    turtle.lt(90)
    turtle.fd(y)
    turtle.lt(90)
    turtle.fd(x)
    # print(turtle.pos())
    turtle.lt(90)
    turtle.fd(y)
    turtle.end_fill()


def draw_star(center_x, center_y, radius):
    print(center_x, center_y)
    turtle.pencolor('black')
    turtle.setpos(center_x, center_y)
    pt1 = turtle.pos()
    turtle.circle(-radius, 360 / 5)
    pt2 = turtle.pos()
    turtle.circle(-radius, 360 / 5)
    pt3 = turtle.pos()
    turtle.circle(-radius, 360 / 5)
    pt4 = turtle.pos()
    turtle.circle(-radius, 360 / 5)
    pt5 = turtle.pos()
    turtle.color('yellow', 'yellow')
    turtle.begin_fill()
    turtle.goto(pt3)
    turtle.goto(pt1)
    turtle.goto(pt4)
    turtle.goto(pt2)
    turtle.goto(pt5)
    turtle.end_fill()


print(turtle.pos())

turtle.pu()
draw_square(-320, -260, 660, 440)
star_part_x = -320
star_part_y = -260 + 440
star_part_s = 660 / 30
center_x, center_y = star_part_x + star_part_s * 5, star_part_y - star_part_s * 5
turtle.setpos(center_x, center_y)  # big star center
turtle.lt(90)
draw_star(star_part_x + star_part_s * 5, star_part_y -
          star_part_s * 2, star_part_s * 3)

# draw 1st 喵all star
turtle.goto(star_part_x + star_part_s * 10, star_part_y -
            star_part_s * 2)  # go to 1st 喵all star center
turtle.lt(round(turtle.towards(center_x, center_y)) - turtle.heading())
turtle.fd(star_part_s)
turtle.rt(90)
draw_star(turtle.xcor(), turtle.ycor(), star_part_s)

# draw 2nd 喵all star
turtle.goto(star_part_x + star_part_s * 12, star_part_y -
            star_part_s * 4)  # go to 1st 喵all star center
turtle.lt(round(turtle.towards(center_x, center_y)) - turtle.heading())
turtle.fd(star_part_s)
turtle.rt(90)
draw_star(turtle.xcor(), turtle.ycor(), star_part_s)

# draw 3rd 喵all star
turtle.goto(star_part_x + star_part_s * 12, star_part_y -
            star_part_s * 7)  # go to 1st 喵all star center
turtle.lt(round(turtle.towards(center_x, center_y)) - turtle.heading())
turtle.fd(star_part_s)
turtle.rt(90)
draw_star(turtle.xcor(), turtle.ycor(), star_part_s)

# draw 4th 喵all star
turtle.goto(star_part_x + star_part_s * 10, star_part_y -
            star_part_s * 9)  # go to 1st 喵all star center
turtle.lt(round(turtle.towards(center_x, center_y)) - turtle.heading())
turtle.fd(star_part_s)
turtle.rt(90)
draw_star(turtle.xcor(), turtle.ycor(), star_part_s)
turtle.ht()
time.sleep(5)
os._exit(1)

 

【提示】

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

https://python.codemao.cn


回复

上一页1 页 / 共 1下一页
。CcQr。CcQr

国家伟大

国家伟大

国家伟大

点赞0


评论