Reputation: 13
I'm working on a python program to create circles and ellipses in Minecraft, or for whatever pegboard system you can think of. It will be basically the same thing as this tool right here, but I'm writing my own code. I'm using the turtle module to draw a grid first, and then go back through with the circle/ellipse. However, I need a way to extract the coordinates of the turtle.
If t=turtle.Turtle(), then using the command t.position() returns something like (200.00,180.00). I need to be able to extract the y coordinate and do operations with it. Any ideas?
Thank you for your suggestions!
Upvotes: 1
Views: 707
Reputation: 41872
You can extract just the Y coordinate via:
y = t.ycor()
When you extract the position via t.position()
, you get back a Vec2D
. This is essentially a tuple of floats but prints in a more truncated (two decimal places) form than a regular tuple of floats. But it has the same precision:
>>> t.circle(100, 36)
>>> t.position()
(58.78,19.10)
>>> t.ycor()
19.09830056250525
>>>
Upvotes: 1
Reputation: 375594
You can extract the second element of the tuple: t.position()[1]
Upvotes: 1