Sign in to follow this  
ElysianEagle

mac-style fisheye effect

Recommended Posts

hey, can anyone point me to some resources where i can understand the math/physics behind achieving the fisheye-like effect you see for the dock on Macs?? i basically have a bunch of rectangles of the same size stacked vertically and as the mouse moves over them, i want them to change size based on proximity to the mouse pointer, just like it happens on the dock on a Mac. i've found code elsewhere that acheives the effect, but i want to understand the theory behind it... thanks!

Share this post


Link to post
Share on other sites
There isn't really any "theory" to it. You'll just want to calculate the distance from the mouse pointer to the center of each box, and compute a scaling factor that is roughly 1 at large distances and increases as the distance decreases. The simplest example is probably the function scale=k/distance+1 (where k is a constant), limited to a reasonable maximum value. You can use other functions that might give smoother results, depending on how exactly you want the sizes to change.

P.S. This isn't a fisheye effect, since there's no nonlinear distortion, only scaling.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this