2024-10-01 07:48:34 发布
网友
我试图在画布上的多个位置印上同一个形状(我正在给海龟添加的图像)。但是,似乎每次我在第二个形状上盖章时,第一个就消失了
有没有办法使用相同的形状/图像在画布上显示多个邮票?当使用海龟中已有的形状时,这似乎不是问题
您应该能够在同一图像的任意数量的副本上盖章,而不会使它们消失,直到您请求它们这样做。对于自定义多边形形状:
from turtle import Screen, Shape, Turtle POLYGON = ( (10, 10), (0, 10), (-10, 0), (0, -10), (10, -10), ) screen = Screen() screen.register_shape('house', Shape('polygon', POLYGON)) turtle = Turtle('house') turtle.penup() for x in range(-200, 200, 30): turtle.setx(x) turtle.stamp() turtle.hideturtle() screen.exitonclick()
或对于自定义图像形状:
from turtle import Screen, Turtle IMAGE = "home-5-24.gif" # https://www.iconsdb.com/gray-icons/home-5-icon.html screen = Screen() screen.register_shape(IMAGE) turtle = Turtle(IMAGE) turtle.penup() for x in range(-200, 200, 30): turtle.setx(x) turtle.stamp() turtle.hideturtle() screen.exitonclick()
您应该能够在同一图像的任意数量的副本上盖章,而不会使它们消失,直到您请求它们这样做。对于自定义多边形形状:
或对于自定义图像形状:
相关问题 更多 >
编程相关推荐