3

How would I go about creating a similar kind of animation as the “genie minimizing effect” in Mac OS X? That is, I want the animation to start at some given point (or a small rectangle), and then “swoop” into its bigger rectangle form with the “genie” effect.

How could such an animation be achieved? Does Core Animation provide anything to do this?

If I have to do this manually, i.e. frame by frame, I believe I could do the mathematical calculations needed to determine the curves at each frame. However, the question is, how would I actually draw the rectangular NSImage (or CGImage) within the specified curves?

Enchilada
  • 3,859
  • 1
  • 36
  • 69
  • possible duplicate of [How can I replicate the trashing animation of Mail.app](http://stackoverflow.com/questions/428110/how-can-i-replicate-the-trashing-animation-of-mail-app) and [UIView "suck" animation](http://stackoverflow.com/questions/2664472/uiview-suck-animation) – Jano Sep 14 '11 at 10:39
  • 1
    @Jano: You sure those are duplicates? Both of those links are for the iPhone, and not the Mac. Just thought I'd mention. – sudo rm -rf Sep 14 '11 at 17:54

2 Answers2

2

The only built-in way to do this is to use the private CGSCreateGenieWindowAnimation function of Core Graphics. Because this is not a public method, you can't use it in app store apps.

There is a simple example showing how to use it here.

Warping the image yourself would be more complex. You could do it by deconstructing the image of the window line by line and shrinking each line of pixels while moving the whole lot down the screen. However, you'd be better off with some sort of warping algorithm, which is beyond my knowledge.

Rob Keniger
  • 45,830
  • 6
  • 101
  • 134
2

It can be done with Core Image and a bit of work. Please see my blog post here (sadly, the Quartz Composer sample project no longer works out of the box, it needs a bit of updating. The source is still there though):

The Genie Effect

Aderstedt
  • 6,301
  • 5
  • 28
  • 44