acircle.getCenter() to (x,y) coordinates in Python

MRAB python at mrabarnett.plus.com
Sat Dec 23 19:29:33 EST 2017


On 2017-12-23 21:30, G Yu wrote:
> I did try that.  The problem is that I already declared a point moving_object_center = (-555,-555), because that's the point I used as the center to draw the moving_object circle itself.  So the moving_object_center.getX() will return -555 no matter what I do.
> 
But your code has:

     moving_circle.move(P_to_R/P_to_E, E_to_R/P_to_E)

so won't that move the circle and change what:

     moving_circle.getCenter()

returns?

> That's why I need to calculate the center using some attribute of the circle, not the center point - because the circle moves, but the point that I declared as the initial center point will never change.
> 
The initial point won't change, but that's just where the circle was 
originally.

Are you sure that it doesn't change? Have you printed out 
moving_circle.getCenter().getX() and moving_circle.getCenter().getY() 
and seen that they aren't changing?

> I'm not totally sure what you mean by "graphics library", but these are all the import statements I'm using at the beginning.
> 
> from graphics import *
> import datetime
> import random
> from math import *
> 
As far as I know, "graphics" isn't part of the standard CPython 
distribution from www.python.org. At least, I have CPython 3.6 for 
Windows, and "graphics" doesn't appear to be present.



More information about the Python-list mailing list