Topic: Automatically calculating best zoom precentages

I've been doing some heavy modification of the source code tonight (adding description support, making shuffle configurable, etc) however the one thing I'm wanting to do that I haven't yet gotten around to is automatically calculating the best zoomOutPerc and zoomInPerc values.

In my case I want the pictures to zoom "in" so that they fit as much of the screen as possible. When zooming "out" I want it to zoom to a level in which all of the images are shown, but it makes them as big as possible.

Has anyone messed around w/the algorithms to accomplish this?


Re: Automatically calculating best zoom precentages

Ok, here's how to calculate the zoomOutPerc automatically.

These changes go in the file. Place this code before the line:


And after the line:
var zoomOutPerc = Number(gXMLRoot.attributes.zoomOutPerc);

In my code I set a new variable called _global.maxImageRotation (which is the same as the maxRot constant in the variable--this defaults to 10.)

If the zoomOutPerc attribute isn't supplied, then it'll calculate the best percentage to use based on the width/height of the stage and the ViewArea.

        // if the zoom out percentage was supplied, calculate it out by ViewArea
        if( isNaN(zoomOutPerc) ){
            // get the maximum rotation percentage
            var iMaxRotation =  _global.maxImageRotation/100;
            // calculate the maximum width percentage
            // Stage Width / (ViewArea Width + (ViewArea Width * Maximum Rotation) )
            var iWidthPerc = Math.floor((_global.sWidth/(gmcViewArea.width + (gmcViewArea.width * iMaxRotation))) * 100);
            // calculate the maximum height percentage
            // Stage Height / (ViewArea Height + (ViewArea Height * Maximum Rotation) )
            var iHeightPerc = Math.floor((_global.sHeight/(gmcViewArea.height + (gmcViewArea.height * iMaxRotation))) * 100);
            // use which ever percentage is smaller--this guarantees all portions
            // of images are displayed
            zoomOutPerc = (iHeightPerc < iWidthPerc) ? iHeightPerc : iWidthPerc;

I'll be working on the zoomInPerc later. Same idea, just need to grab the max image width/height.


Re: Automatically calculating best zoom precentages

Hi Dan

Did you ever manage to get the ZoomIn mod sorted? Would appreciate it if you could post it.