简体   繁体   English

如何在Turtle Graphics Python 3中设置绘图点

[英]How to Set the Drawing Point in Turtle Graphics Python 3

I'm using Turtle Graphics Module in Python 3 and I have drawn a Circle using circle method of Turtle with that i'm using Custom Shape which is a pencil, now problem is that i'ts drawing from the center of the pencil. 我在Python 3中使用Turtle图形模块,并且使用Turtle的圆形方法绘制了一个Circle,使用的是Custom Pencil,这是一支铅笔,现在的问题是我没有从铅笔的中心绘制。 I want it to draw from the tip of the Pencil, so how can i setup turtle to start drawing from the tip of the pencil rather than from the center point. 我希望它从铅笔的笔尖绘制,所以如何设置乌龟从铅笔的笔尖而不是从中心点开始绘图。 Here is my Code: 这是我的代码:

from turtle import Screen, Turtle
screen = Screen()
screen.setup(500, 500)
screen.screensize(500, 500)
screen.register_shape('dpen.gif')
turtle = Turtle('dpen.gif')


def draw_circle():
    turtle.home()
    turtle.clear()
    turtle.circle(90)


screen.listen()
screen.onkeypress(draw_circle, 'space')
screen.mainloop()

屏幕截图示例

Thank You 谢谢

When setting a custom pen, turtle will always draw from the centre of your image. 设置自定义笔时,乌龟将始终从图像中心绘制。 There might be a way to change this, but a far simpler solution is to change your image so that the pencil is in the top right corner, so that the tip points to the middle of the image. 可能有一种更改方法,但是更简单的解决方案是更改图像,使铅笔位于右上角,使笔尖指向图像的中间。 Took me 10 seconds in powerpoint 在Powerpoint中花了我10秒

Very crude example image (demonstrates point): 非常粗糙的示例图像(演示点):

非常粗糙的示例图像(演示点)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM