Zoom Image Widgets Anyone

Henk van der Velden henk at ludisstudio.com
Thu Dec 9 03:50:07 EST 2010


About the design: this way, using a separate drag and zoom interface, zooming in on a specific area of an image is a bit unwieldy. It would be better, I think, to use the scroll wheel, so one can position the mouse at a certain location, and then zoom in or out by using the scroll wheel. Another option is to use drag: dragging upwards means zooming in, dragging downwards means zooming out. Or, like Zoomify, using modifier keys to zoom in and out.

As for the mathematics of zooming: if the mouseloc identifies the spot where one wants to zoom in or out, it's all just a matter of keeping the relative position of the mouse in the picture and the absolute position of the mouse in the window together. So, if the current size of the image is X*Y px, and the current topleft of the picture is x0,y0, and the mouse is at position x1,y1 relative to the window, and the picturesize increases with a factor n, then the new size of the picture is (1+n)X * (1+n)Y px, and the new topleft of the picture is (x1-n(x1-x0)), (y1-n(y1-y0)). This is from the top of my head, but I think this should work.

HTH,
Henk

 
On 09 Dec 2010, at 03:20, use-livecode-request at lists.runrev.com wrote:

>  I'm sitting here making my own zoom tool when I start thinking 
> someelse *must*have done this an a lot better than me.
> 
> I have an image with this script
> 
> on mousedown
>     grab me
> end mousedown
> 
> and a slider with this script....
> 
> where the gWidth and gHeight are the size of the image after import...
> 
> Now the original images are over 3000 pixels wide and 300 DPI..
> 
> I need to the user to be able to really zoom in and get a good quality 
> view of small characters
> 
> This works, but I would like to keep the relative position but of course 
> I am losing this by resetting the topleft to 0,0 each time.
> 
> years ago I though there was a widget right in the IDE that was a zoom 
> tool and you could clone this for your own work...
> 
> ideally you the user has the normal experience of switching to a zoom 
> tool dragging and focusing in on he area of choice..
> 
> Can you share?
> 
> Thanks
> skts
> ------
> 
> global gWidth,gHeight
> on mouseup
>    lock screen
>        set the resizequality of image "displayPage" to "best"
> 
>       put (the thumbposition of me) /100 into pPercent
>       set the rect of image "displayPage" to 
> scaleImageByPercent(gWidth, gHeight, pPercent)
> end mouseup
> 
> function scaleImageByPercent pWidth, pHeight, pPercent
>    return (0,0,(pWidth*pPercent),(pHeight*pPercent))
> end scaleImageByPercent
> 





More information about the use-livecode mailing list