On 12/5/10 2:55 AM, 王瑞聪 wrote: > Dear Sir, > I am now working on a project with the use of FloatCanvas. Hi,
I've forwarded this note to the floatcanvas mailing list: http://paulmcnett.com/cgi-bin/mailman/listinfo/floatcanvas Please post further questions there, so that others may answer, and it will get archived for future users that might have questions. > When I draw a circle on the canvas, I will save it as a picture. I want to know the world coordination of the circle, then I can develop other functionality. > I read on the Internet, there is a function called PixelToWorld, yes: FloatCanvas.PixelToWorld(points) > I though it could help get the world coordination, but it's not. While I could see there is a event function called event.GetPosition(), which can return what I want, but I could't using this function because we don't rely on user's mouse event. > So, can you tell me how to handle this situation? how do you get the pixel coordinates you are using? Are you trying to get the world coordinates of a pixel when working with an image that has been saved? If so, that's tricky. That function relies on the state of the canvas at the time it is called. If you really want to do that however, you could save the required parameter when you save the image. The code for PixelToWorld is pretty simple: def PixelToWorld(self, Points): """ Converts coordinates from Pixel coordinates to world coordinates. Points is a tuple of (x,y) coordinates, or a list of such tuples, or a NX2 Numpy array of x,y coordinates. """ return (((N.asarray(Points, N.float) - (self.PanelSize/2))/self.TransformVector) + self.ViewPortCenter) so if you save Canvas.PanelSize, Canvas.TransformVector and Canvas.ViewPortCenter, you could recalcuate World coordinates later from the image. -Chris _______________________________________________ FloatCanvas mailing list [email protected] http://paulmcnett.com/cgi-bin/mailman/listinfo/floatcanvas
