mac-style fisheye effect

Started by
0 comments, last by dwahler 15 years, 5 months ago
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!
Advertisement
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.

This topic is closed to new replies.

Advertisement