Re: Animated Ripple Effect
Re: Animated Ripple Effect
- Subject: Re: Animated Ripple Effect
- From: Scott Thompson <email@hidden>
- Date: Tue, 18 Apr 2006 20:53:12 -0500
On Apr 18, 2006, at 7:12 PM, Steve Sheets wrote:
Most of the animated transition effects are fairly obvious how to
create (fade in, zoom in, slide in, spin in, etc), but how does one
create the Ripple effect using Cocoa & Quartz? I do not want to
know there is a Quicktime Transition (assuming there in), but
instead what type of calls (with Math) could be used to create the
animation. I have created lots of code (using NSTimers & NSImages)
to animate windows and custom views, but would like to duplicate
the cool ripple effect inside a window. Any suggestions, source
code or pointers would be appreciated!
Trying to do the math yourself would be annoying. The basic function
is going to look something like:
z = A*sin(sqrt((x-xc)^2 + (y -yc)^2))
Where A is the amplitude of the ripple centered at (xc, yc).
The tricky part is figuring out how to map the z into something that
you can display. A good place to look would be in literature on Ray
Tracing. Most of the ripple-type code I've seen takes general ray
tracing techniques and simplifies the process down to something that
can be computed efficiently.
It would be much, much (MUCH) easier just to use the Core Image
Transition to provide this effect for you. If you want an
introduction to Core Image, I might shamelessly suggest my book:
<http://www.amazon.com/gp/product/0321336631/sr=8-1/qid=1145411120/
ref=sr_1_1/104-1980383-7789565?_encoding=UTF8>
which has a brief, but informative introduction to Core Image
(including a sample transition) in Chapter 10.
If you don't care to buy a book, you can read Apple's documentation at:
http://developer.apple.com/documentation/GraphicsImaging/Conceptual/
CoreImaging/ci_intro/chapter_1_section_1.html
In particular you can look up the "Ripple Transition" which sounds
like just what you need. As an added bonus, a little Core Image can
open the door to a lot of effects pretty quickly.
Scott
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden