Hello
Am 22.03.2013 01:34, schrieb Chris Barker - NOAA Federal:
> OK -- done. rather than a new method, I"ve added a flag to the Zoom method.
I reviewed youre changes in the repository. You dont use the flag in the
code.
I will post a slightly different method that corrects the problem (also
as patch attached):
def Zoom(self, factor, center = None, centerCoords="world",
keepPointInPlace=False):
"""
Zoom(factor, center) changes the amount of zoom of the image by
factor.
If factor is greater than one, the image gets larger.
If factor is less than one, the image gets smaller.
:param factor: amount to zoom in or out If factor is greater
than one,
the image gets larger. If factor is less than
one, the
image gets smaller.
:param center: a tuple of (x,y) coordinates of the center of
the viewport,
after zooming. If center is not given, the
center will stay the same.
:param centerCoords: flag indicating whether the center given
is in pixel or world
coords. Options are: "world" or "pixel"
:param keepPointInPlace: boolean flag. If False, the center
point is what's given.
If True, the image is shifted so that
the given center point
is kept in the same pixel space. This
facilitates keeping the
same point under the mouse when
zooming with the scroll wheel.
"""
if center is None:
center = self.ViewPortCenter
centerCoords = 'world' #override input if they don't give a
center point.
if centerCoords == "pixel":
oldpoint = self.PixelToWorld( center )
else:
oldpoint = N.array(center, N.float)
self.Scale = self.Scale*factor
if keepPointInPlace:
self.SetToNewScale(False)
if centerCoords == "pixel":
newpoint = self.PixelToWorld( center )
else:
newpoint = N.array(center, N.float)
delta = (newpoint - oldpoint)
self.MoveImage(-delta, 'world')
else:
self.ViewPortCenter = oldpoint
self.SetToNewScale()
> I do notice that the image still drifts a bit as you zoom in and out
> -- maybe some error introduced by converting back and forth between
> world and pixel coordinates?
Im saw this error to. But im not searched for it further. Later i will
search for it.
_______________________________________________
FloatCanvas mailing list
[email protected]
http://paulmcnett.com/cgi-bin/mailman/listinfo/floatcanvas