(Blast from the past.)
On Wed, Apr 30, 2003 at 09:55:12PM -0400, Mike C. Fletcher wrote:
> Okay, I just fixed this one. I didn't do anything fancy, just limited
> total scaling to within 1:1000 through 1000:1 of current scale. I'm
> unable to provoke the situation of pushing past the focus point with the
> current code, though I could imagine having it occur just through
> successively scaling in so that the scale just disappears entirely (i.e.
> the floating-point value becomes so small as to be effectively 0), but
> if you're zooming in that far, well, expect problems.
I've been doing some stuff on my own version of OpenGL window (OpenGL
embedded in wxPython window, with whole bunch of extra defaul
functionality), and I ended up revisiting how my code does scaling. I
found a scaling/zooming method which IMHO works better.
currently tkScale() does this:
scale = 1 - 0.01 * (event.y - self.ymouse)
self.distance = self.distance * scale
what I think works/*feels* better:
scaler_speed = 0.98
dist = event.y - self.ymouse
scale = scaler_speed ** dist
self.distance *= scale
you might also want to put in a threshold so that you can't go down to scale =
0, which would be unescapable.
# make sure that `eye_dist' doesn't hit 0, else we won't be able to
# zoom out
zero_thresh = 0.0001
if self.distance < zero_thresh:
self.distance = zero_thresh
Benefits of new method:
* no hysterisis: as long as you keep the mouse button down,
each mouse position corresponds to a unique zoom setting, no
matter how you move the mouse to that position; (this might not be
so clear, so here's a more practical example: put mouse in center
of screen, hold mouse button down for zooming, go crazy with the
mouse, move it everywhere, bring it back to center: you'll be at
the original zoom level.)
* the bug from the OT is impossible here
* it might be just me, but the zooming speed at various zoom-in
levels feels more resonable and comfortable.
--
Maciej Kalisiak|mac@] "The person who says it cannot be done should not
dgp.toronto.edu|www.] interrupt the person doing it." -- Chinese Proverb
dgp.toronto.edu/~mac]
|