Re: Animation and crossfading of windows
Re: Animation and crossfading of windows
- Subject: Re: Animation and crossfading of windows
- From: Scott Thompson <email@hidden>
- Date: Sat, 31 Jul 2004 10:14:30 -0500
On Jul 31, 2004, at 5:38 AM, Oskar Lissheim-Boethius wrote:
>
We all know how the System Preferences "window-morphing" looks. It
>
resizes the window to exactly fit the new panel and at the same time
>
cross-fade the content of the old and new one. Very spiffy.
>
>
How do this in code? Is this yet another of Apple's mysterious
>
"cooler-than-any-other" GUI-tricks? I know how to do the
>
window-morphing works, but have never seen info about the cross-fading
>
of contents.
I'm not sure how you access it from Cocoa, but the "Window-Morphing" is
accessible through Carbon using the TransitionWindow API. If there is
no similar API in Cocoa then you could probably set it up yourself
using an NSTimer that occasionally resizes your window over time.
That's all the TransitionWindow API does.
As for the cross fades. The System Preferences is probably using
OpenGL. The basic technique would be to create a texture that contains
the image of the contents of your window (both where is, and where it's
going). Then you repeatedly draw the two contents at differing alpha
levels until one has ramped up to full opacity and one has ramped down
to transparency. This is the same way that the Apple screen savers,
for example do their little coss fade trick.
Another way to accomplish it would be to use the QuickTime image effect
that handles cross fades. The QuickTime effects can be used outside of
a movie to cross fade between any two images and the QuickTime
documentation can show you how. The QuickTime path will require you to
work with GWorlds and other Carbon concepts that may be unfamiliar to
the Cocoa programmer.
Still another way to do it would be to collect the before image and the
after image as CGImages and use CGDrawImage with the CGContextSetAlpha
to perform the same alpha fading trick.
There are probably other ways to accomplish it as well. Of the three I
mentioned OpenGL and QuickTime probably tie in terms of complexity
(with the OpenGL one maybe edging QuickTime out as being a bit more
complex). With the complexity, however, comes performance. The OpenGL
technique is likely to result in the best performance followed by
QuickTIme and then CGImage.
--
Macintosh Software Engineering Consulting Services
Visit my resume at <
http://homepage.mac.com/easco/RSTResume.html>
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.