realbasic-games
[Top] [All Lists]

Re: Crossfade effect for Window

To: REALbasic Games <realbasic-games at lists dot realsoftware dot com>
Subject: Re: Crossfade effect for Window
From: Asher Dunn <asher at fireyesoftware dot com>
Date: Thu, 26 May 2005 15:46:09 -0400
Delivered-to: realbasic-games at lists dot realsoftware dot com
References: <BAY103-F31297D883517B52FAFF07AC10F0 at phx dot gbl>

On May 26, 2005, at 9:45 AM, Ken Gish wrote:

I am using OS X Panther (10.3.9). Any example using Declares?

dim error as integer

Declare Function SetWindowAlpha Lib "CarbonLib" (inWindow as windowPtr, inAlpha as single) as integer

error = setWindowAlpha(theWindow, 0.5)//set window to half transparent
if error <> 0 then
        //there was a problem!
end if

Alpha ranges from 0.0 (transparent) to 1.0 (opaque).
Change "CarbonLib" to "Carbon" if you're compiling Mach-O

You can now do something like this in a Timer to fade between two windows in the same place:

Sub Action()
Declare Function SetWindowAlpha Lib "CarbonLib" (inWindow as windowPtr, inAlpha as single) as integer
        call setWindowAlpha(fadeToWindow, currentAlpha)
        call setWindowAlpha(fadeFromWindow, 1.0 - currentAlpha)
        currentAlpha = currentAlpha + 0.1
End Sub

Although it would probably look better if you removed the window shadows first (and turned them back on afterwards!)

To get a window's alpha, use this:
Declare Function GetWindowAlpha Lib "CarbonLib" (inWindow as windowPtr, byref outAlpha as single) as integer

HTH!

Asher Dunn
--------------------------------------------------------
President and Head Developer of Fireye Software <http://www.fireyesoftware.com/>
AIM and Yahoo: fireye7517

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>