设置图像的位置 python turtle
Setting the position of an image python turtle
我已经添加了带有相关代码的图像。我的挑战是设置图像的所需位置。默认位置是canvas的中心,请问怎么改,求助。
谢谢
假设您已经加载了一些 *.gif 图像作为乌龟的图像,然后您可以 turtle.goto()
(或 turtle.setposition()
等)在 canvas 上的任意位置和 turtle.stamp()
留下的图像:
from turtle import Turtle, Screen
# https://cdn-img.easyicon.net/png/10757/1075705.gif
SQUIRREL_IMAGE = '1075705.gif'
screen = Screen()
screen.register_shape(SQUIRREL_IMAGE)
turtle = Turtle(shape=SQUIRREL_IMAGE)
turtle.penup()
turtle.goto(100, 100)
turtle.stamp()
turtle.goto(-100, -100)
turtle.stamp()
turtle.hideturtle()
screen.exitonclick()
输出
我已经添加了带有相关代码的图像。我的挑战是设置图像的所需位置。默认位置是canvas的中心,请问怎么改,求助。 谢谢
假设您已经加载了一些 *.gif 图像作为乌龟的图像,然后您可以 turtle.goto()
(或 turtle.setposition()
等)在 canvas 上的任意位置和 turtle.stamp()
留下的图像:
from turtle import Turtle, Screen
# https://cdn-img.easyicon.net/png/10757/1075705.gif
SQUIRREL_IMAGE = '1075705.gif'
screen = Screen()
screen.register_shape(SQUIRREL_IMAGE)
turtle = Turtle(shape=SQUIRREL_IMAGE)
turtle.penup()
turtle.goto(100, 100)
turtle.stamp()
turtle.goto(-100, -100)
turtle.stamp()
turtle.hideturtle()
screen.exitonclick()
输出