猫史档案馆


【Python作品分享】新的作品【作业帖】

用户:无邪的小黄鸡QPUn无邪的小黄鸡QPUn查看:0 回复:1 评论:0 创建时间:2024-08-05T10:31:39


【作品展示】

center_image

 

【作品介绍】

黑色三角形填充

 

【作品源代码】

import turtle as t
t.hideturtle()
t.fillcolor("black")
t.up()
t.setx(0)
t.sety(200)
t.setheading(315)
t.begin_fill()
t.pd()
for x in range(3):
    t.fd(300)
    t.rt(120)
t.end_fill()
t.mainloop()

 

【提示】

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

https://python.codemao.cn


回复

上一页1 页 / 共 1下一页
code猫的code猫的

import turtle as t

def draw_filled_triangle(color, size):
    t.fillcolor(color)
    t.begin_fill()
    for _ in range(3):
        t.forward(size)
        t.right(120)
    t.end_fill()

t.hideturtle()
t.up()
t.goto(0, 200)  # 使用 goto 更加直观
t.setheading(315)
t.down()  # 直接使用 down() 而不是 pd()

draw_filled_triangle("black", 300)

t.done()  # 改为 t.done(),更符合新的 turtle 使用方式

点赞0


评论